diff --git a/src/client/java/co/secretonline/accessiblestep/AccessibleStepEndTick.java b/src/client/java/co/secretonline/accessiblestep/AccessibleStepEndTick.java index ca4a04d..004f7b9 100644 --- a/src/client/java/co/secretonline/accessiblestep/AccessibleStepEndTick.java +++ b/src/client/java/co/secretonline/accessiblestep/AccessibleStepEndTick.java @@ -39,7 +39,7 @@ public void onEndTick(MinecraftClient client) { } private void setStepHeight(ClientPlayerEntity player, double height) { - EntityAttributeInstance stepHeightAttribute = player.getAttributeInstance(EntityAttributes.STEP_HEIGHT); + EntityAttributeInstance stepHeightAttribute = player.getAttributeInstance(EntityAttributes.GENERIC_STEP_HEIGHT); stepHeightAttribute.setBaseValue(height); } } diff --git a/src/client/java/co/secretonline/accessiblestep/Constants.java b/src/client/java/co/secretonline/accessiblestep/Constants.java index 807cfd5..5ac6343 100644 --- a/src/client/java/co/secretonline/accessiblestep/Constants.java +++ b/src/client/java/co/secretonline/accessiblestep/Constants.java @@ -3,7 +3,7 @@ import net.minecraft.entity.attribute.EntityAttributes; public class Constants { - public static final double VANILLA_STEP_HEIGHT = EntityAttributes.STEP_HEIGHT.value().getDefaultValue(); + public static final double VANILLA_STEP_HEIGHT = EntityAttributes.GENERIC_STEP_HEIGHT.value().getDefaultValue(); public static final double MOD_DEFAULT_STEP_HEIGHT = 1.25; public static final double MOD_DEFAULT_SNEAK_HEIGHT = VANILLA_STEP_HEIGHT; public static final double MOD_DEFAULT_SPRINT_HEIGHT = MOD_DEFAULT_STEP_HEIGHT; diff --git a/src/client/java/co/secretonline/accessiblestep/modmenu/AccessibleStepOptionsScreen.java b/src/client/java/co/secretonline/accessiblestep/modmenu/AccessibleStepOptionsScreen.java index 72f9746..f0b2b72 100644 --- a/src/client/java/co/secretonline/accessiblestep/modmenu/AccessibleStepOptionsScreen.java +++ b/src/client/java/co/secretonline/accessiblestep/modmenu/AccessibleStepOptionsScreen.java @@ -5,7 +5,7 @@ import co.secretonline.accessiblestep.options.AccessibleStepConfig; import co.secretonline.accessiblestep.options.AccessibleStepOptions; import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.gui.screen.option.GameOptionsScreen; +import net.minecraft.client.gui.screen.option.SimpleOptionsScreen; import net.minecraft.client.gui.widget.CyclingButtonWidget; import net.minecraft.client.gui.widget.PressableWidget; import net.minecraft.client.gui.widget.SliderWidget; @@ -13,7 +13,7 @@ import net.minecraft.client.option.SimpleOption; import net.minecraft.text.Text; -public class AccessibleStepOptionsScreen extends GameOptionsScreen { +public class AccessibleStepOptionsScreen extends SimpleOptionsScreen { private static SimpleOption[] getOptions() { return new SimpleOption[] { AccessibleStepOptions.getPerWorldOption(), @@ -29,12 +29,13 @@ public AccessibleStepOptionsScreen(Screen parent, GameOptions gameOptions) { super( parent, gameOptions, - Text.translatable("options.accessiblestep.title")); + Text.translatable("options.accessiblestep.title"), + getOptions()); } @Override - protected void addOptions() { - this.body.addAll(getOptions()); + protected void init() { + super.init(); // The values in the options may not be correct as the player might have // switched worlds before opening the screen. As such we need to reset the @@ -46,7 +47,7 @@ public void resetOptionsForWorld() { // Update per world option AccessibleStepOptions.getPerWorldOption().setValue(State.config.hasConfigForWorld()); // Also need to disable the button if no world is selected - var widget = this.body.getWidgetFor(AccessibleStepOptions.getPerWorldOption()); + var widget = this.buttonList.getWidgetFor(AccessibleStepOptions.getPerWorldOption()); if (widget != null && widget instanceof PressableWidget) { if (State.worldName == null) { @@ -89,7 +90,7 @@ private void resetWidgets() { } private void resetCyclingButtonWidget(SimpleOption option) { - var widget = this.body.getWidgetFor(option); + var widget = this.buttonList.getWidgetFor(option); if (widget != null && widget instanceof CyclingButtonWidget) { @SuppressWarnings("unchecked") CyclingButtonWidget button = (CyclingButtonWidget) widget; @@ -99,7 +100,7 @@ private void resetCyclingButtonWidget(SimpleOption option) { } private void resetSliderWidget(SimpleOption option, double maxHeight) { - var widget = this.body.getWidgetFor(option); + var widget = this.buttonList.getWidgetFor(option); if (widget != null && widget instanceof SliderWidget) { // Widget needs value in range of 0-1 instead of option's value