Use enum for chainstone setting
And very minor cleanup in `CarpetSettings`
This commit is contained in:
2 files changed
+13
-35
No files matched your search
@@ -32,7 +32,6 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import static carpet.api.settings.RuleCategory.BUGFIX;
|
import static carpet.api.settings.RuleCategory.BUGFIX;
|
||||||
@@ -56,8 +55,6 @@ public class CarpetSettings
|
|||||||
public static final ThreadLocal<Boolean> skipGenerationChecks = ThreadLocal.withInitial(() -> false);
|
public static final ThreadLocal<Boolean> skipGenerationChecks = ThreadLocal.withInitial(() -> false);
|
||||||
public static final ThreadLocal<Boolean> impendingFillSkipUpdates = ThreadLocal.withInitial(() -> false);
|
public static final ThreadLocal<Boolean> impendingFillSkipUpdates = ThreadLocal.withInitial(() -> false);
|
||||||
public static int runPermissionLevel = 2;
|
public static int runPermissionLevel = 2;
|
||||||
public static boolean doChainStone = false;
|
|
||||||
public static boolean chainStoneStickToAll = false;
|
|
||||||
public static Block structureBlockIgnoredBlock = Blocks.STRUCTURE_VOID;
|
public static Block structureBlockIgnoredBlock = Blocks.STRUCTURE_VOID;
|
||||||
private static class LanguageValidator extends Validator<String> {
|
private static class LanguageValidator extends Validator<String> {
|
||||||
@Override public String validate(CommandSourceStack source, CarpetRule<String> currentRule, String newValue, String string) {
|
@Override public String validate(CommandSourceStack source, CarpetRule<String> 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} )
|
@Rule( desc = "Pistons can push block entities, like hoppers, chests etc.", category = {EXPERIMENTAL, FEATURE} )
|
||||||
public static boolean movableBlockEntities = false;
|
public static boolean movableBlockEntities = false;
|
||||||
|
|
||||||
|
public enum ChainStoneMode {
|
||||||
private static class ChainStoneSetting extends Validator<String> {
|
TRUE, FALSE, STICK_TO_ALL;
|
||||||
@Override public String validate(CommandSourceStack source, CarpetRule<String> currentRule, String newValue, String string) {
|
public boolean enabled() {
|
||||||
CarpetSettings.doChainStone = !newValue.toLowerCase(Locale.ROOT).equals("false");
|
return this != FALSE;
|
||||||
CarpetSettings.chainStoneStickToAll = newValue.toLowerCase(Locale.ROOT).equals("stick_to_all");
|
|
||||||
|
|
||||||
return newValue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -402,11 +396,9 @@ public class CarpetSettings
|
|||||||
"and will stick to other blocks that connect to them directly.",
|
"and will stick to other blocks that connect to them directly.",
|
||||||
"With stick_to_all: it will stick even if not visually connected"
|
"With stick_to_all: it will stick even if not visually connected"
|
||||||
},
|
},
|
||||||
category = {EXPERIMENTAL, FEATURE},
|
category = {EXPERIMENTAL, FEATURE}
|
||||||
options = {"true", "false", "stick_to_all"},
|
|
||||||
validate = ChainStoneSetting.class
|
|
||||||
)
|
)
|
||||||
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 )
|
@Rule( desc = "Saplings turn into dead shrubs in hot climates and no water access", category = FEATURE )
|
||||||
public static boolean desertShrubs = false;
|
public static boolean desertShrubs = false;
|
||||||
@@ -487,18 +479,10 @@ public class CarpetSettings
|
|||||||
private static class ModulePermissionLevel extends Validator<String> {
|
private static class ModulePermissionLevel extends Validator<String> {
|
||||||
@Override public String validate(CommandSourceStack source, CarpetRule<String> currentRule, String newValue, String string) {
|
@Override public String validate(CommandSourceStack source, CarpetRule<String> currentRule, String newValue, String string) {
|
||||||
int permissionLevel = switch (newValue) {
|
int permissionLevel = switch (newValue) {
|
||||||
case "false":
|
case "false" -> 0;
|
||||||
yield 0;
|
case "true", "ops" -> 2;
|
||||||
case "true":
|
case "0", "1", "2", "3", "4" -> Integer.parseInt(newValue);
|
||||||
case "ops":
|
default -> throw new IllegalArgumentException(); // already checked by previous validator
|
||||||
yield 2;
|
|
||||||
case "0":
|
|
||||||
case "1":
|
|
||||||
case "2":
|
|
||||||
case "3":
|
|
||||||
case "4":
|
|
||||||
yield Integer.parseInt(newValue);
|
|
||||||
default: throw new IllegalArgumentException();
|
|
||||||
};
|
};
|
||||||
if (source != null && !source.hasPermission(permissionLevel))
|
if (source != null && !source.hasPermission(permissionLevel))
|
||||||
return null;
|
return null;
|
||||||
@@ -591,13 +575,6 @@ public class CarpetSettings
|
|||||||
)
|
)
|
||||||
public static boolean smoothClientAnimations;
|
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<Integer> {
|
private static class PushLimitLimits extends Validator<Integer> {
|
||||||
@Override public Integer validate(CommandSourceStack source, CarpetRule<Integer> currentRule, Integer newValue, String string) {
|
@Override public Integer validate(CommandSourceStack source, CarpetRule<Integer> currentRule, Integer newValue, String string) {
|
||||||
return (newValue>0 && newValue <= 1024) ? newValue : null;
|
return (newValue>0 && newValue <= 1024) ? newValue : null;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package carpet.mixins;
|
|||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
|
||||||
import carpet.CarpetSettings;
|
import carpet.CarpetSettings;
|
||||||
|
import carpet.CarpetSettings.ChainStoneMode;
|
||||||
import carpet.fakes.BlockBehaviourInterface;
|
import carpet.fakes.BlockBehaviourInterface;
|
||||||
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
@@ -20,7 +21,7 @@ public class ChainBlock_customStickyMixin implements BlockBehaviourInterface {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSticky(BlockState state) {
|
public boolean isSticky(BlockState state) {
|
||||||
return CarpetSettings.doChainStone;
|
return CarpetSettings.chainStone.enabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -31,7 +32,7 @@ public class ChainBlock_customStickyMixin implements BlockBehaviourInterface {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CarpetSettings.chainStoneStickToAll) {
|
if (CarpetSettings.chainStone == ChainStoneMode.STICK_TO_ALL) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (neighborState.is((Block)(Object)this)) {
|
if (neighborState.is((Block)(Object)this)) {
|
||||||
|
|||||||
Reference in new issue
Block a user