-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9d4ad79
commit 485550f
Showing
10 changed files
with
105 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 0 additions & 81 deletions
81
src/client/java/co/secretonline/accessiblestep/AccessibleStepOptions.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
src/client/java/co/secretonline/accessiblestep/options/AccessibleStepOptions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package co.secretonline.accessiblestep.options; | ||
|
||
import java.util.Arrays; | ||
|
||
import net.minecraft.client.MinecraftClient; | ||
import net.minecraft.client.gui.tooltip.Tooltip; | ||
import net.minecraft.client.option.SimpleOption; | ||
import net.minecraft.text.Text; | ||
|
||
public class AccessibleStepOptions { | ||
public static final String STEP_MODE_OPTIONS_KEY = "accessibleStep"; | ||
|
||
private static final Text STEP_MODE_OFF_TOOLTIP = Text.translatable("options.accessiblestep.off.tooltip"); | ||
private static final Text STEP_MODE_STEP_TOOLTIP = Text.translatable("options.accessiblestep.step.tooltip"); | ||
private static final Text STEP_MODE_AUTO_JUMP_TOOLTIP = Text.translatable("options.accessiblestep.autojump.tooltip"); | ||
|
||
private static final SimpleOption<StepMode> stepModeOption = new SimpleOption<StepMode>( | ||
"options.accessiblestep.option", | ||
AccessibleStepOptions::getStepModeTooltip, | ||
SimpleOption.enumValueText(), | ||
new SimpleOption.PotentialValuesBasedCallbacks<StepMode>( | ||
Arrays.asList(StepMode.values()), | ||
StepMode.CODEC), | ||
StepMode.OFF, | ||
AccessibleStepOptions::onStepModeChange); | ||
|
||
private static Tooltip getStepModeTooltip(StepMode value) { | ||
return switch (value) { | ||
case StepMode.OFF -> Tooltip.of(STEP_MODE_OFF_TOOLTIP); | ||
case StepMode.STEP -> Tooltip.of(STEP_MODE_STEP_TOOLTIP); | ||
case StepMode.AUTO_JUMP -> Tooltip.of(STEP_MODE_AUTO_JUMP_TOOLTIP); | ||
default -> throw new MatchException(null, null); | ||
}; | ||
} | ||
|
||
private static void onStepModeChange(StepMode value) { | ||
MinecraftClient client = MinecraftClient.getInstance(); | ||
|
||
// Also update auto-jump option behind the scenes | ||
if (value == StepMode.AUTO_JUMP) { | ||
client.options.getAutoJump().setValue(true); | ||
} else { | ||
client.options.getAutoJump().setValue(false); | ||
} | ||
} | ||
|
||
public static SimpleOption<StepMode> getStepModeOption() { | ||
return stepModeOption; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/client/java/co/secretonline/accessiblestep/options/StepMode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package co.secretonline.accessiblestep.options; | ||
|
||
import com.mojang.serialization.Codec; | ||
|
||
import net.minecraft.util.StringIdentifiable; | ||
import net.minecraft.util.TranslatableOption; | ||
|
||
public enum StepMode implements TranslatableOption, StringIdentifiable { | ||
OFF(0, "false", "options.off"), | ||
STEP(1, "step", "options.accessiblestep.step"), | ||
AUTO_JUMP(2, "autojump", "options.autoJump"); | ||
|
||
public static final Codec<StepMode> CODEC; | ||
private final int id; | ||
private final String serializedId; | ||
private final String translationKey; | ||
|
||
private StepMode(int id, String serializedId, String translationKey) { | ||
this.id = id; | ||
this.serializedId = serializedId; | ||
this.translationKey = translationKey; | ||
} | ||
|
||
public String asString() { | ||
return this.serializedId; | ||
} | ||
|
||
public int getId() { | ||
return this.id; | ||
} | ||
|
||
public String getTranslationKey() { | ||
return this.translationKey; | ||
} | ||
|
||
static { | ||
CODEC = StringIdentifiable.createCodec(StepMode::values); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters