Allow setting qc range with quasiConnectivity setting (#1617)

* add quasiConnectivityRange setting

* make sure qc range respects different world heights

* check if source == null in qc range validator

* merge the two qc settings

* Set minimum range down to zero (no qc)
This commit is contained in:
Space Walker authored and GitHub committed 2023-01-25 17:28:05 +01:00
1 parent f2c658bf03
commit 0e2f6df4d3
4 files changed
+86 -34

No files matched your search

+26 -2
View File
@@ -341,8 +341,32 @@ public class CarpetSettings
)
public static boolean antiCheatDisabled = false;
@Rule(desc = "Pistons, droppers and dispensers react if block above them is powered", category = CREATIVE)
public static boolean quasiConnectivity = true;
private static class QuasiConnectivityValidator extends Validator<Integer> {
@Override
public Integer validate(CommandSourceStack source, CarpetRule<Integer> changingRule, Integer newValue, String userInput) {
int minRange = 0;
int maxRange = 1;
if (source == null) {
maxRange = Integer.MAX_VALUE;
} else {
for (Level level : source.getServer().getAllLevels()) {
maxRange = Math.max(maxRange, level.getHeight() - 1);
}
}
return (newValue >= minRange && newValue <= maxRange) ? newValue : null;
}
}
@Rule(
desc = "Pistons, droppers, and dispensers check for power to the block(s) above them.",
extra = { "Defines the range at which pistons, droppers, and dispensers check for 'quasi power'." },
category = CREATIVE,
validate = QuasiConnectivityValidator.class
)
public static int quasiConnectivity = 1;
@Rule(
desc = "Players can flip and rotate blocks when holding cactus",