Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ org.gradle.configuration-cache=false

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.21.10
yarn_mappings=1.21.10+build.3
minecraft_version=1.21.11
yarn_mappings=1.21.11+build.4
loader_version=0.19.2
loom_version=1.17.2

Expand All @@ -17,4 +17,4 @@ mod_version=0.0.0
maven_group=de.rettichlp

# Dependencies
fabric_api_version=0.138.4+1.21.10
fabric_api_version=0.141.3+1.21.11
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package de.rettichlp.ucutils.common.gui.screens.components;

import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.input.AbstractInput;
import net.minecraft.text.Text;

import java.util.function.Consumer;

import static net.minecraft.client.gui.DrawContext.HoverType.NONE;
import static net.minecraft.screen.ScreenTexts.OFF;
import static net.minecraft.screen.ScreenTexts.ON;
import static net.minecraft.text.Text.empty;
Expand All @@ -16,11 +17,11 @@

public class ToggleButtonWidget extends ButtonWidget {

private final Text text;
private final net.minecraft.text.Text text;
private final Consumer<Boolean> changeListener;
private boolean state;

public ToggleButtonWidget(Text text, Consumer<Boolean> changeListener, boolean defaultState) {
public ToggleButtonWidget(net.minecraft.text.Text text, Consumer<Boolean> changeListener, boolean defaultState) {
super(0, 0, 150, 20, empty(), button -> {}, DEFAULT_NARRATION_SUPPLIER);
this.text = text;
this.changeListener = changeListener;
Expand All @@ -36,11 +37,17 @@ public void onPress(AbstractInput input) {
setMessage(getText());
}

@Override
protected void drawIcon(DrawContext context, int mouseX, int mouseY, float deltaTicks) {
drawButton(context);
drawLabel(context.getHoverListener(this, NONE));
}

public void updateText() {
setMessage(getText());
}

private Text getText() {
private net.minecraft.text.Text getText() {
return this.text.copy()
.append(of(":").copy().formatted(GRAY)).append(" ")
.append(this.state ? ON.copy().formatted(GREEN) : OFF.copy().formatted(RED));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,8 @@ public static class Configuration extends UCUtilsWidgetConfiguration implements

@Override
public Widget optionsWidget() {
return CyclingButtonWidget.builder(Style::getDisplayName)
return CyclingButtonWidget.builder(Style::getDisplayName, this.style)
.values(Style.values())
.initially(this.style)
.tooltip(Style::getTooltip)
.build(WIDGETS_CAR_LOCKED_OPTIONS_STYLE_NAME, (button, style) -> this.style = style);
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/de/rettichlp/ucutils/common/models/Sound.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;

import static net.minecraft.client.sound.PositionedSoundInstance.master;
import static net.minecraft.client.sound.PositionedSoundInstance.ui;

@Getter
@AllArgsConstructor
Expand Down Expand Up @@ -37,12 +37,12 @@ public enum Sound {
}

public void play() {
PositionedSoundInstance positionedSoundInstance = master(getSoundEvent(), 1.0F, 1.0F);
PositionedSoundInstance positionedSoundInstance = ui(getSoundEvent(), 1.0F, 1.0F);
MinecraftClient.getInstance().getSoundManager().play(positionedSoundInstance);
}

public void play(float pitch, float volume) {
PositionedSoundInstance positionedSoundInstance = master(getSoundEvent(), pitch, volume);
PositionedSoundInstance positionedSoundInstance = ui(getSoundEvent(), pitch, volume);
MinecraftClient.getInstance().getSoundManager().play(positionedSoundInstance);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ public <E extends CyclingButtonEntry> void addCyclingButton(@NotNull Directional
BiConsumer<Options, E> onValueChange,
@NotNull Function<Options, E> currentValue,
int width) {
CyclingButtonWidget<E> cyclingButton = CyclingButtonWidget.builder(displayNameFunction)
E initialValue = currentValue.apply(configuration.getOptions());
CyclingButtonWidget<E> cyclingButton = CyclingButtonWidget.builder(displayNameFunction, initialValue)
.values(values)
.initially(currentValue.apply(configuration.getOptions()))
.tooltip(CyclingButtonEntry::getTooltip)
.build(name, (button, value) -> onValueChange.accept(configuration.getOptions(), value));

Expand Down