diff --git a/src/main/java/carpet/CarpetSettings.java b/src/main/java/carpet/CarpetSettings.java index 13e7995b..e8ffeabc 100644 --- a/src/main/java/carpet/CarpetSettings.java +++ b/src/main/java/carpet/CarpetSettings.java @@ -32,7 +32,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.util.Iterator; -import java.util.Locale; import java.util.Optional; import static carpet.api.settings.RuleCategory.BUGFIX; @@ -56,8 +55,6 @@ public class CarpetSettings public static final ThreadLocal skipGenerationChecks = ThreadLocal.withInitial(() -> false); public static final ThreadLocal impendingFillSkipUpdates = ThreadLocal.withInitial(() -> false); public static int runPermissionLevel = 2; - public static boolean doChainStone = false; - public static boolean chainStoneStickToAll = false; public static Block structureBlockIgnoredBlock = Blocks.STRUCTURE_VOID; private static class LanguageValidator extends Validator { @Override public String validate(CommandSourceStack source, CarpetRule currentRule, String newValue, String string) { @@ -386,13 +383,10 @@ public class CarpetSettings @Rule( desc = "Pistons can push block entities, like hoppers, chests etc.", category = {EXPERIMENTAL, FEATURE} ) public static boolean movableBlockEntities = false; - - private static class ChainStoneSetting extends Validator { - @Override public String validate(CommandSourceStack source, CarpetRule currentRule, String newValue, String string) { - CarpetSettings.doChainStone = !newValue.toLowerCase(Locale.ROOT).equals("false"); - CarpetSettings.chainStoneStickToAll = newValue.toLowerCase(Locale.ROOT).equals("stick_to_all"); - - return newValue; + public enum ChainStoneMode { + TRUE, FALSE, STICK_TO_ALL; + public boolean enabled() { + return this != FALSE; } } @@ -402,11 +396,9 @@ public class CarpetSettings "and will stick to other blocks that connect to them directly.", "With stick_to_all: it will stick even if not visually connected" }, - category = {EXPERIMENTAL, FEATURE}, - options = {"true", "false", "stick_to_all"}, - validate = ChainStoneSetting.class + category = {EXPERIMENTAL, FEATURE} ) - public static String chainStone = "false"; + public static ChainStoneMode chainStone = ChainStoneMode.FALSE; @Rule( desc = "Saplings turn into dead shrubs in hot climates and no water access", category = FEATURE ) public static boolean desertShrubs = false; @@ -487,18 +479,10 @@ public class CarpetSettings private static class ModulePermissionLevel extends Validator { @Override public String validate(CommandSourceStack source, CarpetRule currentRule, String newValue, String string) { int permissionLevel = switch (newValue) { - case "false": - yield 0; - case "true": - case "ops": - yield 2; - case "0": - case "1": - case "2": - case "3": - case "4": - yield Integer.parseInt(newValue); - default: throw new IllegalArgumentException(); + case "false" -> 0; + case "true", "ops" -> 2; + case "0", "1", "2", "3", "4" -> Integer.parseInt(newValue); + default -> throw new IllegalArgumentException(); // already checked by previous validator }; if (source != null && !source.hasPermission(permissionLevel)) return null; @@ -591,13 +575,6 @@ public class CarpetSettings ) public static boolean smoothClientAnimations; - //@Rule( - // desc="Fixes mining ghost blocks by trusting clients with block breaking", - // extra="Increases player allowed mining distance to 32 blocks", - // category = SURVIVAL - //) - //public static boolean miningGhostBlockFix = false; - private static class PushLimitLimits extends Validator { @Override public Integer validate(CommandSourceStack source, CarpetRule currentRule, Integer newValue, String string) { return (newValue>0 && newValue <= 1024) ? newValue : null; diff --git a/src/main/java/carpet/mixins/ChainBlock_customStickyMixin.java b/src/main/java/carpet/mixins/ChainBlock_customStickyMixin.java index 2e2d1e01..9cad0aea 100644 --- a/src/main/java/carpet/mixins/ChainBlock_customStickyMixin.java +++ b/src/main/java/carpet/mixins/ChainBlock_customStickyMixin.java @@ -3,6 +3,7 @@ package carpet.mixins; import org.spongepowered.asm.mixin.Mixin; import carpet.CarpetSettings; +import carpet.CarpetSettings.ChainStoneMode; import carpet.fakes.BlockBehaviourInterface; import net.minecraft.core.BlockPos; @@ -20,7 +21,7 @@ public class ChainBlock_customStickyMixin implements BlockBehaviourInterface { @Override public boolean isSticky(BlockState state) { - return CarpetSettings.doChainStone; + return CarpetSettings.chainStone.enabled(); } @Override @@ -31,7 +32,7 @@ public class ChainBlock_customStickyMixin implements BlockBehaviourInterface { return false; } - if (CarpetSettings.chainStoneStickToAll) { + if (CarpetSettings.chainStone == ChainStoneMode.STICK_TO_ALL) { return true; } if (neighborState.is((Block)(Object)this)) {