diff --git a/src/main/java/net/earthcomputer/clientcommands/Configs.java b/src/main/java/net/earthcomputer/clientcommands/Configs.java index c28734a8..9ad28747 100644 --- a/src/main/java/net/earthcomputer/clientcommands/Configs.java +++ b/src/main/java/net/earthcomputer/clientcommands/Configs.java @@ -24,13 +24,9 @@ public class Configs { @Config(readOnly = true, temporary = true) public static PlayerRandCracker.CrackState playerCrackState = PlayerRandCracker.CrackState.UNCRACKED; - @Config(setter = @Config.Setter("setEnchantingPrediction"), temporary = true) - private static boolean enchantingPrediction = false; - public static boolean getEnchantingPrediction() { - return enchantingPrediction; - } - public static void setEnchantingPrediction(boolean enchantingPrediction) { - Configs.enchantingPrediction = enchantingPrediction; + @Config(onChange = "onChangeEnchantingPrediction", temporary = true) + public static boolean enchantingPrediction = false; + private static void onChangeEnchantingPrediction(boolean oldEnchantingPrediction, boolean enchantingPrediction) { if (enchantingPrediction) { ServerBrandManager.rngWarning(); } else { @@ -53,13 +49,9 @@ public boolean isEnabled() { } } - @Config(setter = @Config.Setter("setFishingManipulation"), temporary = true, condition = "conditionLessThan1_20") - private static FishingManipulation fishingManipulation = FishingManipulation.OFF; - public static FishingManipulation getFishingManipulation() { - return fishingManipulation; - } - public static void setFishingManipulation(FishingManipulation fishingManipulation) { - Configs.fishingManipulation = fishingManipulation; + @Config(onChange = "onChangeFishingManipulation", temporary = true, condition = "conditionLessThan1_20") + public static FishingManipulation fishingManipulation = FishingManipulation.OFF; + private static void onChangeFishingManipulation(FishingManipulation oldFishingManipulation, FishingManipulation fishingManipulation) { if (fishingManipulation.isEnabled()) { ServerBrandManager.rngWarning(); } else { @@ -122,13 +114,9 @@ public static void setMaxEnchantLevels(int maxEnchantLevels) { Configs.minEnchantLevels = Math.min(Configs.minEnchantLevels, Configs.maxEnchantLevels); } - @Config(setter = @Config.Setter("setChorusManipulation"), temporary = true) - private static boolean chorusManipulation = false; - public static boolean getChorusManipulation() { - return chorusManipulation; - } - public static void setChorusManipulation(boolean chorusManipulation) { - Configs.chorusManipulation = chorusManipulation; + @Config(onChange = "onChangeChorusManipulation", temporary = true) + public static boolean chorusManipulation = false; + public static void onChangeChorusManipulation(boolean oldChorusManipulation, boolean chorusManipulation) { if (chorusManipulation) { ServerBrandManager.rngWarning(); ChorusManipulation.onChorusManipEnabled(); diff --git a/src/main/java/net/earthcomputer/clientcommands/command/CEnchantCommand.java b/src/main/java/net/earthcomputer/clientcommands/command/CEnchantCommand.java index 75836816..678e2b83 100644 --- a/src/main/java/net/earthcomputer/clientcommands/command/CEnchantCommand.java +++ b/src/main/java/net/earthcomputer/clientcommands/command/CEnchantCommand.java @@ -54,7 +54,7 @@ private static boolean enchantmentPredicate(Item item, Holder ench) } private static int cenchant(FabricClientCommandSource source, ItemAndEnchantmentsPredicate itemAndEnchantmentsPredicate) throws CommandSyntaxException { - if (!Configs.getEnchantingPrediction()) { + if (!Configs.enchantingPrediction) { Component component = Component.translatable("commands.cenchant.needEnchantingPrediction") .withStyle(ChatFormatting.RED) .append(" ") diff --git a/src/main/java/net/earthcomputer/clientcommands/command/FishCommand.java b/src/main/java/net/earthcomputer/clientcommands/command/FishCommand.java index c6bc964e..2b4d35bf 100644 --- a/src/main/java/net/earthcomputer/clientcommands/command/FishCommand.java +++ b/src/main/java/net/earthcomputer/clientcommands/command/FishCommand.java @@ -56,7 +56,7 @@ public static void register(CommandDispatcher dispatc } private static int listGoals(FabricClientCommandSource source) throws CommandSyntaxException { - if (!Configs.getFishingManipulation().isEnabled()) { + if (!Configs.fishingManipulation.isEnabled()) { throw NEED_FISHING_MANIPULATION_EXCEPTION.create(); } @@ -73,7 +73,7 @@ private static int listGoals(FabricClientCommandSource source) throws CommandSyn } private static int addGoal(FabricClientCommandSource source, WithStringArgument.Result goal) throws CommandSyntaxException { - if (!Configs.getFishingManipulation().isEnabled()) { + if (!Configs.fishingManipulation.isEnabled()) { throw NEED_FISHING_MANIPULATION_EXCEPTION.create(); } @@ -85,7 +85,7 @@ private static int addGoal(FabricClientCommandSource source, WithStringArgument. } private static int addEnchantedGoal(FabricClientCommandSource source, WithStringArgument.Result stringAndItemAndEnchantments) throws CommandSyntaxException { - if (!Configs.getFishingManipulation().isEnabled()) { + if (!Configs.fishingManipulation.isEnabled()) { throw NEED_FISHING_MANIPULATION_EXCEPTION.create(); } @@ -102,7 +102,7 @@ private static int addEnchantedGoal(FabricClientCommandSource source, WithString } private static int removeGoal(FabricClientCommandSource source, int index) throws CommandSyntaxException { - if (!Configs.getFishingManipulation().isEnabled()) { + if (!Configs.fishingManipulation.isEnabled()) { throw NEED_FISHING_MANIPULATION_EXCEPTION.create(); } diff --git a/src/main/java/net/earthcomputer/clientcommands/features/ChorusManipulation.java b/src/main/java/net/earthcomputer/clientcommands/features/ChorusManipulation.java index 1bb3c1c6..beff4284 100644 --- a/src/main/java/net/earthcomputer/clientcommands/features/ChorusManipulation.java +++ b/src/main/java/net/earthcomputer/clientcommands/features/ChorusManipulation.java @@ -33,7 +33,7 @@ public static void onChorusManipEnabled() { TaskManager.addNonConflictingTask("chorusManipRenderer", new SimpleTask() { @Override public boolean condition() { - return Configs.getChorusManipulation() && Minecraft.getInstance().player != null; + return Configs.chorusManipulation && Minecraft.getInstance().player != null; } @Override @@ -48,7 +48,7 @@ protected void onTick() { } public static int setGoal(Vec3 v1, Vec3 v2, boolean relative) { - if (!Configs.getChorusManipulation()) { + if (!Configs.chorusManipulation) { Component component = Component.translatable("chorusManip.needChorusManipulation") .withStyle(ChatFormatting.RED) .append(" ") diff --git a/src/main/java/net/earthcomputer/clientcommands/features/EnchantmentCracker.java b/src/main/java/net/earthcomputer/clientcommands/features/EnchantmentCracker.java index ad764ad1..0418ec90 100644 --- a/src/main/java/net/earthcomputer/clientcommands/features/EnchantmentCracker.java +++ b/src/main/java/net/earthcomputer/clientcommands/features/EnchantmentCracker.java @@ -557,7 +557,7 @@ public String toString() { // MISCELLANEOUS HELPER METHODS & ENCHANTING SIMULATION public static boolean isEnchantingPredictionEnabled() { - return Configs.getEnchantingPrediction(); + return Configs.enchantingPrediction; } private static int getEnchantPower(Level level, BlockPos tablePos) { diff --git a/src/main/java/net/earthcomputer/clientcommands/features/FishingCracker.java b/src/main/java/net/earthcomputer/clientcommands/features/FishingCracker.java index 6bffef57..d8f709f4 100644 --- a/src/main/java/net/earthcomputer/clientcommands/features/FishingCracker.java +++ b/src/main/java/net/earthcomputer/clientcommands/features/FishingCracker.java @@ -250,7 +250,7 @@ public static boolean throwFishingBobber() { } public static boolean canManipulateFishing() { - return Configs.getFishingManipulation().isEnabled() && !goals.isEmpty(); + return Configs.fishingManipulation.isEnabled() && !goals.isEmpty(); } private static void handleFishingRodThrow(ItemStack stack) { @@ -267,7 +267,7 @@ public static void reset() { synchronized (STATE_LOCK) { state = State.NOT_MANIPULATING; - if (canManipulateFishing() && Configs.getFishingManipulation() == Configs.FishingManipulation.AFK) { + if (canManipulateFishing() && Configs.fishingManipulation == Configs.FishingManipulation.AFK) { state = State.WAITING_FOR_RETRHOW; TaskManager.addNonConflictingTask("cfishRethrow", new LongTask() { private int counter; @@ -340,7 +340,7 @@ public static void registerEvents() { } }); MoreClientEvents.TIME_SYNC_ON_NETWORK_THREAD.register(packet -> { - if (Configs.getFishingManipulation().isEnabled()) { + if (Configs.fishingManipulation.isEnabled()) { onTimeSync(); } }); @@ -590,7 +590,7 @@ private static void onTimeSync() { int delay = (totalTicksToWait - estimatedTicksElapsed) * serverMspt - magicMillisecondsCorrection - PingCommand.getLocalPing() - timeToStartOfTick + serverMspt / 2; long targetTime = (delay) * 1000000L + System.nanoTime(); DELAY_EXECUTOR.schedule(() -> { - if (!Configs.getFishingManipulation().isEnabled() || state != State.ASYNC_WAITING_FOR_FISH) { + if (!Configs.fishingManipulation.isEnabled() || state != State.ASYNC_WAITING_FOR_FISH) { return; } LocalPlayer oldPlayer = Minecraft.getInstance().player; diff --git a/src/main/java/net/earthcomputer/clientcommands/features/PlayerRandCracker.java b/src/main/java/net/earthcomputer/clientcommands/features/PlayerRandCracker.java index fc093f38..e80bf2bd 100644 --- a/src/main/java/net/earthcomputer/clientcommands/features/PlayerRandCracker.java +++ b/src/main/java/net/earthcomputer/clientcommands/features/PlayerRandCracker.java @@ -162,7 +162,7 @@ public static void onConsume(ItemStack stack, Vec3 pos, int particleCount, int i } } - if (Configs.getChorusManipulation() && stack.getItem() == Items.CHORUS_FRUIT) { + if (Configs.chorusManipulation && stack.getItem() == Items.CHORUS_FRUIT) { ChorusManipulation.onEat(pos, particleCount, itemUseTimeLeft); if (particleCount == 16) { //Consumption randoms