Merge pull request #35 from gnembon/settings

Settings - should help with future expansions
This commit is contained in:
gnembon authored and GitHub committed 2019-06-12 01:30:08 -03:00
commit 27fc57dbf6
87 files changed
+1763 -1002

No files matched your search

+466
View File
@@ -1,3 +1,469 @@
# Fabric Carpet
Cause all carpets are made of fabric?
# Carpet Settings
## antiCheatSpeed
Prevents players from rubberbanding when moving too fast
Puts more trust in clients positioning
* Type: `boolean`
* Default value: `false`
* Required options: `true`, `false`
* Categories: `CREATIVE`, `SURVIVAL`
* Additional notes:
* Its not yet fully implemented - we are working on it
## calmNetherFires
Permanent fires don't schedule random updates
* Type: `boolean`
* Default value: `false`
* Required options: `true`, `false`
* Categories: `OPTIMIZATION`
* Additional notes:
* Its not yet fully implemented - we are working on it
## carpets
Placing carpets may issue carpet commands for non-op players
* Type: `boolean`
* Default value: `false`
* Required options: `true`, `false`
* Categories: `SURVIVAL`
## combineXPOrbs
XP orbs combine with other into bigger orbs
* Type: `boolean`
* Default value: `false`
* Required options: `true`, `false`
* Categories: `FEATURE`
## commandCameramode
Enables /c and /s commands to quickly switch between camera and survival modes
/c and /s commands are available to all players regardless of their permission levels
* Type: `boolean`
* Default value: `true`
* Required options: `true`, `false`
* Categories: `COMMAND`
* Additional notes:
* It has an accompanying command
## commandDistance
Enables /distance command to measure in game distance between points
Also enables brown carpet placement action if 'carpets' rule is turned on as well
* Type: `boolean`
* Default value: `true`
* Required options: `true`, `false`
* Categories: `COMMAND`
* Additional notes:
* It has an accompanying command
## commandDraw
Enables /draw commands
... allows for drawing simple shapes
* Type: `boolean`
* Default value: `true`
* Required options: `true`, `false`
* Categories: `COMMAND`
* Additional notes:
* It has an accompanying command
## commandInfo
Enables /info command for blocks
Also enables gray carpet placement action
if 'carpets' rule is turned on as well
* Type: `boolean`
* Default value: `true`
* Required options: `true`, `false`
* Categories: `COMMAND`
* Additional notes:
* It has an accompanying command
## commandLog
Enables /log command to monitor events in the game via chat and overlays
* Type: `boolean`
* Default value: `true`
* Required options: `true`, `false`
* Categories: `COMMAND`
* Additional notes:
* It has an accompanying command
## commandPerimeterInfo
Enables /perimeterinfo command
... that scans the area around the block for potential spawnable spots
* Type: `boolean`
* Default value: `true`
* Required options: `true`, `false`
* Categories: `COMMAND`
* Additional notes:
* It has an accompanying command
## commandPlayer
Enables /player command to control/spawn players
* Type: `boolean`
* Default value: `true`
* Required options: `true`, `false`
* Categories: `COMMAND`
* Additional notes:
* Its not yet fully implemented - we are working on it
* It has an accompanying command
## commandScript
Enables /script command
An in-game scripting API for Scarpet programming language
* Type: `boolean`
* Default value: `true`
* Required options: `true`, `false`
* Categories: `COMMAND`
* Additional notes:
* It has an accompanying command
## commandSpawn
Enables /spawn command for spawn tracking
* Type: `boolean`
* Default value: `true`
* Required options: `true`, `false`
* Categories: `COMMAND`
* Additional notes:
* It has an accompanying command
## commandTick
Enables /tick command to control game clocks
* Type: `boolean`
* Default value: `true`
* Required options: `true`, `false`
* Categories: `COMMAND`
* Additional notes:
* It has an accompanying command
## ctrlQCraftingFix
Dropping entire stacks works also from on the crafting UI result slot
* Type: `boolean`
* Default value: `false`
* Required options: `true`, `false`
* Categories: `BUGFIX`, `SURVIVAL`
## customMOTD
Sets a different motd message on client trying to connect to the server
use '_' to use the startup setting from server.properties
* Type: `String`
* Default value: `_`
* Suggested options: `_`
* Categories: `CREATIVE`
* Additional notes:
* Its not yet fully implemented - we are working on it
## desertShrubs
Saplings turn into dead shrubs in hot climates and no water access
* Type: `boolean`
* Default value: `false`
* Required options: `true`, `false`
* Categories: `FEATURE`
## disableSpawnChunks
Allows spawn chunks to unload
* Type: `boolean`
* Default value: `false`
* Required options: `true`, `false`
* Categories: `CREATIVE`
* Additional notes:
* Its not yet fully implemented - we are working on it
## explosionNoBlockDamage
Explosions won't destroy blocks
* Type: `boolean`
* Default value: `false`
* Required options: `true`, `false`
* Categories: `CREATIVE`
## fastRedstoneDust
Lag optimizations for redstone dust
by Theosib
* Type: `boolean`
* Default value: `false`
* Required options: `true`, `false`
* Categories: `EXPERIMENTAL`, `OPTIMIZATION`
* Additional notes:
* Its not yet fully implemented - we are working on it
## fillLimit
Customizable fill/clone volume limit
* Type: `int`
* Default value: `32768`
* Suggested options: `32768`, `250000`, `1000000`
* Categories: `CREATIVE`
* Additional notes:
* You must choose a value from 1 to 20M
## fillUpdates
fill/clone/setblock and structure blocks cause block updates
* Type: `boolean`
* Default value: `true`
* Required options: `true`, `false`
* Categories: `CREATIVE`
## flippinCactus
Players can flip and rotate blocks when holding cactus
Doesn't cause block updates when rotated/flipped
Applies to pistons, observers, droppers, repeaters, stairs, glazed terracotta etc...
* Type: `boolean`
* Default value: `false`
* Required options: `true`, `false`
* Categories: `CREATIVE`, `SURVIVAL`, `FEATURE`
## hopperCounters
hoppers pointing to wool will count items passing through them
Enables /counter command, and actions while placing red and green carpets on wool blocks
Use /counter <color?> reset to reset the counter, and /counter <color?> to query
In survival, place green carpet on same color wool to query, red to reset the counters
Counters are global and shared between players, 16 channels available
Items counted are destroyed, count up to one stack per tick per hopper
* Type: `boolean`
* Default value: `false`
* Required options: `true`, `false`
* Categories: `COMMAND`, `CREATIVE`, `FEATURE`
* Additional notes:
* It has an accompanying command
## huskSpawningInTemples
Only husks spawn in desert temples
* Type: `boolean`
* Default value: `false`
* Required options: `true`, `false`
* Categories: `FEATURE`
* Additional notes:
* Its not yet fully implemented - we are working on it
## kelpGenerationGrowthLimit
limits growth limit of newly naturally generated kelp to this amount of blocks
* Type: `int`
* Default value: `25`
* Suggested options: `0`, `2`, `25`
* Categories: `FEATURE`
* Additional notes:
* You must choose a value from 0 to 25. 25 and all natural kelp can grow 25 blocks, choose 0 to make all generated kelp not to grow
## lagFreeSpawning
Spawning requires much less CPU and Memory
* Type: `boolean`
* Default value: `false`
* Required options: `true`, `false`
* Categories: `OPTIMIZATION`
## leadFix
Fixes leads breaking/becoming invisible in unloaded chunks
You may still get visibly broken leash links on the client side, but server side the link is still there.
* Type: `boolean`
* Default value: `false`
* Required options: `true`, `false`
* Categories: `BUGFIX`
* Additional notes:
* Its not yet fully implemented - we are working on it
## maxEntityCollisions
Customizable maximal entity collision limits, 0 for no limits
* Type: `int`
* Default value: `0`
* Suggested options: `0`, `1`, `20`
* Categories: `OPTIMIZATION`
* Additional notes:
* Must be a positive number
## missingTools
Pistons, Glass and Sponge can be broken faster with their appropriate tools
* Type: `boolean`
* Default value: `false`
* Required options: `true`, `false`
* Categories: `SURVIVAL`
* Additional notes:
* Its not yet fully implemented - we are working on it
## movableTileEntities
Pistons can push tile entities, like hoppers, chests etc.
* Type: `boolean`
* Default value: `false`
* Required options: `true`, `false`
* Categories: `EXPERIMENTAL`, `FEATURE`
## onePlayerSleeping
One player is required on the server to cause night to pass
* Type: `boolean`
* Default value: `false`
* Required options: `true`, `false`
* Categories: `SURVIVAL`
## persistentParrots
Parrots don't get of your shoulders until you receive damage
* Type: `boolean`
* Default value: `false`
* Required options: `true`, `false`
* Categories: `SURVIVAL`, `FEATURE`
* Additional notes:
* Its not yet fully implemented - we are working on it
## placementRotationFix
fixes block placement rotation issue when player rotates quickly while placing blocks
* Type: `boolean`
* Default value: `false`
* Required options: `true`, `false`
* Categories: `BUGFIX`
## portalCaching
Alternative, persistent caching strategy for nether portals
* Type: `boolean`
* Default value: `false`
* Required options: `true`, `false`
* Categories: `SURVIVAL`, `CREATIVE`
## portalCreativeDelay
Portals won't let a creative player go through instantly
Holding obsidian in either hand won't let you through at all
* Type: `boolean`
* Default value: `false`
* Required options: `true`, `false`
* Categories: `CREATIVE`
## portalSuffocationFix
Nether portals correctly place entities going through
Entities shouldn't suffocate in obsidian
* Type: `boolean`
* Default value: `false`
* Required options: `true`, `false`
* Categories: `BUGFIX`
* Additional notes:
* Its not yet fully implemented - we are working on it
## pushLimit
Customizable piston push limit
* Type: `int`
* Default value: `12`
* Suggested options: `10`, `12`, `14`, `100`
* Categories: `CREATIVE`
* Additional notes:
* You must choose a value from 1 to 1024
## quasiConnectivity
Pistons, droppers and dispensers react if block above them is powered
* Type: `boolean`
* Default value: `true`
* Required options: `true`, `false`
* Categories: `CREATIVE`
* Additional notes:
* Its not yet fully implemented - we are working on it
## railPowerLimit
Customizable powered rail power range
* Type: `int`
* Default value: `9`
* Suggested options: `9`, `15`, `30`
* Categories: `CREATIVE`
* Additional notes:
* You must choose a value from 1 to 1024
## renewableCoral
Coral structures will grow with bonemeal from coral plants
* Type: `boolean`
* Default value: `false`
* Required options: `true`, `false`
* Categories: `FEATURE`
## renewableSponges
Guardians turn into Elder Guardian when struck by lightning
* Type: `boolean`
* Default value: `false`
* Required options: `true`, `false`
* Categories: `FEATURE`
## rotatorBlock
Cactus in dispensers rotates blocks.
Rotates block anti-clockwise if possible
* Type: `boolean`
* Default value: `false`
* Required options: `true`, `false`
* Categories: `FEATURE`
## shulkerSpawningInEndCities
Shulkers will respawn in end cities
* Type: `boolean`
* Default value: `false`
* Required options: `true`, `false`
* Categories: `FEATURE`
## silverFishDropGravel
Silverfish drop a gravel item when breaking out of a block
* Type: `boolean`
* Default value: `false`
* Required options: `true`, `false`
* Categories: `FEATURE`
## stackableShulkerBoxes
Empty shulker boxes can stack to 64 when dropped on the ground
To move them around between inventories, use shift click to move entire stacks
* Type: `boolean`
* Default value: `false`
* Required options: `true`, `false`
* Categories: `SURVIVAL`, `FEATURE`
## summonNaturalLightning
summoning a lightning bolt has all the side effects of natural lightning
* Type: `boolean`
* Default value: `false`
* Required options: `true`, `false`
* Categories: `CREATIVE`
## superSecretSetting
Gbhs sgnf sadsgras fhskdpri!
* Type: `boolean`
* Default value: `false`
* Required options: `true`, `false`
* Categories: `EXPERIMENTAL`
## tntDoNotUpdate
TNT doesn't update when placed against a power source
* Type: `boolean`
* Default value: `false`
* Required options: `true`, `false`
* Categories: `CREATIVE`
## tntPrimerMomentumRemoved
Removes random TNT momentum when primed
* Type: `boolean`
* Default value: `false`
* Required options: `true`, `false`
* Categories: `CREATIVE`
## unloadedEntityFix
Entities pushed or moved into unloaded chunks no longer disappear
* Type: `boolean`
* Default value: `false`
* Required options: `true`, `false`
* Categories: `EXPERIMENTAL`, `BUGFIX`
* Additional notes:
* Its not yet fully implemented - we are working on it
## viewDistance
Changes the view distance of the server.
Set to 0 to not override the value in server settings.
* Type: `int`
* Default value: `0`
* Suggested options: `0`, `12`, `16`, `32`
* Categories: `CREATIVE`
* Additional notes:
* You must choose a value from 0 (use server settings) to 32
## watchdogCrashFix
Fixes server crashing supposedly on falling behind 60s in ONE tick, yeah bs.
Fixed 1.12 watchdog crash in 1.13 pre-releases, reintroduced with 1.13, GG.
* Type: `boolean`
* Default value: `false`
* Required options: `true`, `false`
* Categories: `BUGFIX`
* Additional notes:
* Its not yet fully implemented - we are working on it
## xpNoCooldown
Players absorb XP instantly, without delay
* Type: `boolean`
* Default value: `false`
* Required options: `true`, `false`
* Categories: `CREATIVE`
+13 -4
View File
@@ -14,10 +14,13 @@ import carpet.commands.PerimeterInfoCommand;
import carpet.commands.PlayerCommand;
import carpet.commands.ScriptCommand;
import carpet.commands.SpawnCommand;
import carpet.commands.TestCommand;
import carpet.commands.TickCommand;
import carpet.helpers.TickSpeed;
import carpet.logging.LoggerRegistry;
import carpet.script.CarpetScriptServer;
import carpet.settings.CarpetSettings;
import carpet.settings.SettingsManager;
import carpet.utils.HUDController;
import com.mojang.brigadier.CommandDispatcher;
import net.minecraft.server.command.ServerCommandSource;
@@ -28,17 +31,24 @@ public class CarpetServer // static for now - easier to handle all around the co
public static final Random rand = new Random((int)((2>>16)*Math.random()));
public static MinecraftServer minecraft_server;
public static CarpetScriptServer scriptServer;
public static SettingsManager settingsManager;
static
{
SettingsManager.parseSettingsClass(CarpetSettings.class);
//...
}
public static void init(MinecraftServer server) //aka constructor of this static singleton class
{
CarpetServer.minecraft_server = server;
}
public static void onServerLoaded(MinecraftServer server)
{
CarpetSettings.apply_settings_from_conf(server);
settingsManager = new SettingsManager(server);
scriptServer = new CarpetScriptServer();
}
// Separate from onServerLoaded, because a server can be loaded multiple times in singleplayer
public static void onGameStarted() {
public static void onGameStarted()
{
LoggerRegistry.initLoggers();
}
@@ -53,7 +63,6 @@ public class CarpetServer // static for now - easier to handle all around the co
public static void registerCarpetCommands(CommandDispatcher<ServerCommandSource> dispatcher)
{
CarpetCommand.register(dispatcher);
TickCommand.register(dispatcher);
CounterCommand.register(dispatcher);
LogCommand.register(dispatcher);
@@ -65,7 +74,7 @@ public class CarpetServer // static for now - easier to handle all around the co
PerimeterInfoCommand.register(dispatcher);
DrawCommand.register(dispatcher);
ScriptCommand.register(dispatcher);
CarpetCommand.register(dispatcher);
//TestCommand.register(dispatcher);
}
}
-729
View File
@@ -1,729 +0,0 @@
package carpet;
import carpet.fakes.MinecraftServer_motdInterface;
import carpet.fakes.PortalForcerInterface;
import carpet.utils.Messenger;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.dedicated.DedicatedServer;
import net.minecraft.server.network.ServerPlayerEntity;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.BiConsumer;
import java.util.stream.Collectors;
import java.util.stream.Stream;
//import carpet.helpers.SpawnChunks;
public class CarpetSettings
{
public static boolean locked = false;
public static final String carpetVersion = "v19_06_04alpha";
public static final Logger LOG = LogManager.getLogger();
private static final Map<String, CarpetSettingEntry> settings_store;
public static final CarpetSettingEntry FalseEntry = CarpetSettingEntry.create("void","all","Error").choices("None","");
public static final String[] default_tags = {"tnt","fix","survival","creative", "experimental","optimizations","feature","commands"}; //tab completion only
public static boolean skipGenerationChecks = false;
public static boolean impendingFillSkipUpdates = false;
static {
settings_store = new HashMap<>();
set_defaults();
}
//those don't have to mimic defaults - defaults will be '
//static store
public static int n_pushLimit = 12;
public static int n_maxEntityCollisions = 0;
public static boolean b_hopperCounters = false;
public static boolean b_shulkerSpawningInEndCities = false;
public static boolean b_fastRedstoneDust = false;
public static int railPowerLimitAdjusted = 8;
public static boolean b_disableSpawnChunks = false;
public static boolean b_movableTileEntities = false;
public static boolean b_huskSpawningInTemples = false;
public static boolean b_stackableShulkerBoxes = false;
public static boolean b_fillUpdates = true;
public static boolean b_lagFreeSpawning = false;
private static CarpetSettingEntry rule(String s1, String s2, String s3) { return CarpetSettingEntry.create(s1,s2,s3);}
private static void set_defaults()
{
CarpetSettingEntry[] RuleList = new CarpetSettingEntry[] {
rule("watchdogCrashFix", "fix", "Fixes server crashing supposedly on falling behind 60s in ONE tick, yeah bs.").
extraInfo("Fixed 1.12 watchdog crash in 1.13 pre-releases, reintroduced with 1.13, GG.").wip(),
rule("portalSuffocationFix", "fix", "Nether portals correctly place entities going through")
.extraInfo("Entities shouldn't suffocate in obsidian").wip(),
rule("superSecretSetting", "experimental","Gbhs sgnf sadsgras fhskdpri!"),
rule("portalCreativeDelay", "creative", "Portals won't let a creative player go through instantly")
.extraInfo("Holding obsidian in either hand won't let you through at all"),
rule("ctrlQCraftingFix", "fix survival", "Dropping entire stacks works also from on the crafting UI result slot"),
rule("persistentParrots", "survival feature", "Parrots don't get of your shoulders until you receive damage"),
//!rule("growingUpWallJump", "fix", "Mobs growing up won't glitch into walls or go through fences"),
//!rule("reloadSuffocationFix", "fix experimental", "Won't let mobs glitch into blocks when reloaded.")
// .extraInfo("Can cause slight differences in mobs behaviour"),
rule("xpNoCooldown", "creative", "Players absorb XP instantly, without delay"),
rule("combineXPOrbs", "creative", "XP orbs combine with other into bigger orbs"),
rule("stackableShulkerBoxes", "survival", "Empty shulker boxes can stack to 64 when dropped on the ground")
.extraInfo("To move them around between inventories, use shift click to move entire stacks").boolAccelerate().defaultFalse(),
rule("explosionNoBlockDamage", "tnt", "Explosions won't destroy blocks"),
rule("tntPrimerMomentumRemoved", "tnt", "Removes random TNT momentum when primed"),
rule("fastRedstoneDust", "experimental optimizations", "Lag optimizations for redstone dust")
.extraInfo("by Theosib").boolAccelerate().defaultFalse().wip(),
rule("huskSpawningInTemples", "experimental feature", "Only husks spawn in desert temples").boolAccelerate().wip(),
rule("shulkerSpawningInEndCities", "feature experimental", "Shulkers will respawn in end cities").boolAccelerate(),
rule("unloadedEntityFix", "experimental creative", "Entities pushed or moved into unloaded chunks no longer disappear").wip(),
rule("TNTDoNotUpdate", "tnt", "TNT doesn't update when placed against a power source"),
rule("antiCheatSpeed", "creative surival", "Prevents players from rubberbanding when moving too fast").wip(),
rule("quasiConnectivity", "creative", "Pistons, droppers and dispensers react if block above them is powered")
.defaultTrue().wip(),
rule("flippinCactus", "creative survival", "Players can flip and rotate blocks when holding cactus")
.extraInfo("Doesn't cause block updates when rotated/flipped",
"Applies to pistons, observers, droppers, repeaters, stairs, glazed terracotta etc..."),
rule("hopperCounters", "commands creative survival","hoppers pointing to wool will count items passing through them")
.extraInfo("Enables /counter command, and actions while placing red and green carpets on wool blocks",
"Use /counter <color?> reset to reset the counter, and /counter <color?> to query",
"In survival, place green carpet on same color wool to query, red to reset the counters",
"Counters are global and shared between players, 16 channels available",
"Items counted are destroyed, count up to one stack per tick per hopper")
.isACommand().boolAccelerate().defaultFalse(),
rule("renewableSponges", "experimental feature", "Guardians turn into Elder Guardian when struck by lightning"),
rule("movableTileEntities", "experimental", "Pistons can push tile entities, like hoppers, chests etc.").boolAccelerate(),
rule("desertShrubs", "feature", "Saplings turn into dead shrubs in hot climates and no water access when it attempts to grow into a tree"),
rule("silverFishDropGravel", "experimental", "Silverfish drop a gravel item when breaking out of a block"),
rule("summonNaturalLightning","creative", "summoning a lightning bolt has all the side effects of natural lightning"),
rule("commandSpawn", "commands", "Enables /spawn command for spawn tracking").isACommand(),
rule("commandTick", "commands", "Enables /tick command to control game speed").isACommand(),
rule("commandLog", "commands", "Enables /log command to monitor events in the game via chat and overlays").isACommand().wip(),
rule("commandDistance", "commands", "Enables /distance command to measure in game distance between points").isACommand()
.extraInfo("Also enables brown carpet placement action if 'carpets' rule is turned on as well"),
rule("commandInfo", "commands", "Enables /info command for blocks and entities").isACommand()
.extraInfo("Also enables gray carpet placement action ")
.extraInfo("and yellow carpet placement action for entities if 'carpets' rule is turned on as well"),
rule("commandCameramode", "commands", "Enables /c and /s commands to quickly switch between camera and survival modes").isACommand()
.extraInfo("/c and /s commands are available to all players regardless of their permission levels"),
rule("commandPerimeterInfo", "commands", "Enables /perimeterinfo command").isACommand()
.extraInfo("... that scans the area around the block for potential spawnable spots"),
rule("commandDraw", "commands", "Enables /draw commands").isACommand()
.extraInfo("... allows for drawing simple shapes"),
rule("commandScript", "commands", "Enables /script command").isACommand()
.extraInfo("a powerful in-game scripting API"),
rule("commandPlayer", "commands", "Enables /player command to control/spawn players").isACommand().wip(),
rule("carpets", "survival", "Placing carpets may issue carpet commands for non-op players"),
rule("missingTools", "survival", "Pistons, Glass and Sponge can be broken faster with their appropriate tools").wip(),
rule("portalCaching", "survival experimental", "Alternative, persistent caching strategy for nether portals").validate(
(s, n) -> s.getMinecraftServer().getWorlds().forEach(w -> ((PortalForcerInterface)w.getPortalForcer()).invalidateCache())
),
rule("calmNetherFires", "experimental", "Permanent fires don't schedule random updates").wip(),
rule("fillUpdates", "creative", "fill/clone/setblock and structure blocks cause block updates").defaultTrue().boolAccelerate(),
rule("pushLimit", "creative","Customizable piston push limit")
.choices("12","10 12 14 100").setNotStrict().numAccelerate(),
rule("railPowerLimit", "creative", "Customizable powered rail power range")
.choices("9","9 15 30").setNotStrict().validate( (s, n) ->
railPowerLimitAdjusted = CarpetSettings.getInt("railPowerLimit") - 1),
rule("fillLimit", "creative","Customizable fill/clone volume limit")
.choices("32768","32768 250000 1000000").setNotStrict(),
rule("maxEntityCollisions", "optimizations", "Customizable maximal entity collision limits, 0 for no limits")
.choices("0","0 1 20").setNotStrict().numAccelerate(),
//???rule("pistonGhostBlocksFix", "fix", "Fix for piston ghost blocks")
// .extraInfo("true(serverOnly) option works with all clients, including vanilla",
// "clientAndServer option requires compatible carpet clients and messes up flying machines")
// .choices("false","false true clientAndServer"),
//???rule("waterFlow", "optimizations", "fixes water flowing issues")
// .choices("vanilla","vanilla optimized correct"),
rule("onePlayerSleeping", "survival", "One player is required on the server to cause night to pass"),
rule("customMOTD", "creative","Sets a different motd message on client trying to connect to the server")
.extraInfo("use '_' to use the startup setting from server.properties")
.choices("_","_").setNotStrict().validate((s, n) ->
((MinecraftServer_motdInterface)CarpetServer.minecraft_server).checkMOTD()),
rule("rotatorBlock", "experimental", "Cactus in dispensers rotates blocks.")
.extraInfo("Cactus in a dispenser gives the dispenser the ability to rotate the blocks " +
"that are in front of it anti-clockwise if possible."),
rule("viewDistance", "creative", "Changes the view distance of the server.")
.extraInfo("Set to 0 to not override the value in server settings.")
.choices("0", "0 12 16 32 64").setNotStrict()
.validate( (s, n) -> {
int viewDistance = getInt("viewDistance");
if (CarpetServer.minecraft_server.isDedicated())
{
if (viewDistance < 2)
{
viewDistance = ((DedicatedServer) CarpetServer.minecraft_server).getProperties().viewDistance;
}
if (viewDistance > 64)
{
viewDistance = 64;
}
if (viewDistance != CarpetServer.minecraft_server.getPlayerManager().getViewDistance())
CarpetServer.minecraft_server.getPlayerManager().setViewDistance(viewDistance);
}
else
{
CarpetSettings.get(n).setForce("0");
if (s != null)
Messenger.m(s, "w view distance can only be changed on a server");
}
}),
rule("disableSpawnChunks", "creative", "Removes the spawn chunks.")
.validate((s, n) -> {
if (!CarpetSettings.getBool("disableSpawnChunks"))
if (s != null)
Messenger.m(s, "w Spawn chunks re-enabled. Visit spawn to load it.");
}).boolAccelerate().wip(),
rule("kelpGenerationGrowLimit", "feature", "limits growth limit of newly naturally generated kelp to this amount of blocks")
.choices("25", "0 2 25").setNotStrict(),
rule("renewableCoral", "feature", "Coral structures will grow with bonemeal from coral plants"),
rule("placementRotationFix", "fix", "fixes block placement rotation issue when player rotates quickly while placing blocks"),
rule("leadFix", "fix", "Fixes leads breaking/becoming invisible in unloaded chunks")
.extraInfo("You may still get visibly broken leash links on the client side, but server side the link is still there.").wip(),
rule("lagFreeSpawning", "optimizations", "Spawning requires much less CPU and Memory").boolAccelerate()
};
for (CarpetSettingEntry rule: RuleList)
{
settings_store.put(rule.getName(), rule);
}
}
public static void notifyPlayersCommandsChanged()
{
if (CarpetServer.minecraft_server == null || CarpetServer.minecraft_server.getPlayerManager() == null)
{
return;
}
for (ServerPlayerEntity entityplayermp : CarpetServer.minecraft_server.getPlayerManager().getPlayerList())
{
CarpetServer.minecraft_server.getCommandManager().sendCommandTree(entityplayermp);
}
}
public static void apply_settings_from_conf(MinecraftServer server)
{
Map<String, String> conf = read_conf(server);
boolean is_locked = locked;
locked = false;
if (is_locked)
{
LOG.info("[CM]: Carpet Mod is locked by the administrator");
}
for (String key: conf.keySet())
{
set(server.getCommandSource(), key, conf.get(key));
LOG.info("[CM]: loaded setting "+key+" as "+conf.get(key)+" from carpet.conf");
}
locked = is_locked;
}
private static void disable_commands_by_default()
{
for (CarpetSettingEntry entry: settings_store.values())
{
if (entry.getName().startsWith("command"))
{
entry.defaultFalse();
}
}
}
private static Map<String, String> read_conf(MinecraftServer server)
{
try
{
File settings_file = server.getLevelStorage().resolveFile(server.getLevelName(), "carpet.conf");
BufferedReader b = new BufferedReader(new FileReader(settings_file));
String line = "";
Map<String,String> result = new HashMap<String, String>();
while ((line = b.readLine()) != null)
{
line = line.replaceAll("\\r|\\n", "");
if ("locked".equalsIgnoreCase(line))
{
disable_commands_by_default();
locked = true;
}
String[] fields = line.split("\\s+",2);
if (fields.length > 1)
{
if (get(fields[0])==FalseEntry)
{
LOG.error("[CM]: Setting " + fields[0] + " is not a valid - ignoring...");
continue;
}
if (!(Arrays.asList(get(fields[0]).getOptions()).contains(fields[1])) && get(fields[0]).isStrict())
{
LOG.error("[CM]: The value of " + fields[1] + " for " + fields[0] + " is not valid - ignoring...");
continue;
}
result.put(fields[0],fields[1]);
}
}
b.close();
return result;
}
catch(FileNotFoundException e)
{
return new HashMap<>();
}
catch (IOException e)
{
e.printStackTrace();
return new HashMap<>();
}
}
private static void write_conf(MinecraftServer server, Map<String, String> values)
{
if (locked) return;
try
{
File settings_file = server.getLevelStorage().resolveFile(server.getLevelName(), "carpet.conf");
FileWriter fw = new FileWriter(settings_file);
for (String key: values.keySet())
{
fw.write(key+" "+values.get(key)+"\n");
}
fw.close();
}
catch (IOException e)
{
e.printStackTrace();
LOG.error("[CM]: failed write the carpet.conf");
}
}
// stores different defaults in the file
public static boolean setDefaultRule(ServerCommandSource source, String setting_name, String string_value)
{
if (locked) return false;
if (settings_store.containsKey(setting_name))
{
Map<String, String> conf = read_conf(source.getMinecraftServer());
conf.put(setting_name, string_value);
write_conf(source.getMinecraftServer(), conf);
set(source, setting_name,string_value);
return true;
}
return false;
}
// removes overrides of the default values in the file
public static boolean removeDefaultRule(ServerCommandSource source, String setting_name)
{
if (locked) return false;
if (settings_store.containsKey(setting_name))
{
Map<String, String> conf = read_conf(source.getMinecraftServer());
conf.remove(setting_name);
write_conf(source.getMinecraftServer(), conf);
set(source, setting_name,get(setting_name).getDefault());
return true;
}
return false;
}
//changes setting temporarily
public static boolean set(ServerCommandSource source, String setting_name, String string_value)
{
CarpetSettingEntry en = get(setting_name);
if (en != FalseEntry)
{
en.set(source, string_value);
//reload_stat(setting_name);
//CarpetClientRuleChanger.updateCarpetClientsRule(setting_name, string_value);
return true;
}
return false;
}
// used as CarpetSettings.get("pushLimit").integer to get the int value of push limit
public static CarpetSettingEntry get(String setting_name)
{
if (!settings_store.containsKey(setting_name) )
{
return FalseEntry;
}
return settings_store.get(setting_name);
}
public static int getInt(String setting_name)
{
return get(setting_name).getIntegerValue();
}
public static boolean getBool(String setting_name)
{
return get(setting_name).getBoolValue();
}
public static String getString(String setting_name) { return get(setting_name).getStringValue(); }
public static float getFloat(String setting_name)
{
return get(setting_name).getFloatValue();
}
public static CarpetSettingEntry[] findAll(String tag)
{
ArrayList<CarpetSettingEntry> res = new ArrayList<CarpetSettingEntry>();
for (String rule: settings_store.keySet().stream().sorted().collect(Collectors.toList()))
{
if (tag == null || settings_store.get(rule).matches(tag))
{
res.add(settings_store.get(rule));
}
}
return res.toArray(new CarpetSettingEntry[0]);
}
public static CarpetSettingEntry[] find_nondefault(MinecraftServer server)
{
ArrayList<CarpetSettingEntry> res = new ArrayList<CarpetSettingEntry>();
Map <String,String> defaults = read_conf(server);
for (String rule: settings_store.keySet().stream().sorted().collect(Collectors.toList()))
{
if (!settings_store.get(rule).isDefault() || defaults.containsKey(rule))
{
res.add(settings_store.get(rule));
}
}
return res.toArray(new CarpetSettingEntry[0]);
}
public static CarpetSettingEntry[] findStartupOverrides(MinecraftServer server)
{
ArrayList<CarpetSettingEntry> res = new ArrayList<CarpetSettingEntry>();
if (locked) return res.toArray(new CarpetSettingEntry[0]);
Map <String,String> defaults = read_conf(server);
for (String rule: settings_store.keySet().stream().sorted().collect(Collectors.toList()))
{
if (defaults.containsKey(rule))
{
res.add(settings_store.get(rule));
}
}
return res.toArray(new CarpetSettingEntry[0]);
}
public static String[] toStringArray(CarpetSettingEntry[] entry_array)
{
return Stream.of(entry_array).map(CarpetSettingEntry::getName).toArray( String[]::new );
}
public static ArrayList<CarpetSettingEntry> getAllCarpetSettings()
{
ArrayList<CarpetSettingEntry> res = new ArrayList<CarpetSettingEntry>();
for (String rule: settings_store.keySet().stream().sorted().collect(Collectors.toList()))
{
res.add(settings_store.get(rule));
}
return res;
}
public static CarpetSettingEntry getCarpetSetting(String rule)
{
return settings_store.get(rule);
}
public static void resetToVanilla(ServerCommandSource source)
{
for (String rule: settings_store.keySet())
{
get(rule).reset(source);
//reload_stat(rule);
}
}
public static void resetToUserDefaults(ServerCommandSource source)
{
resetToVanilla(source);
apply_settings_from_conf(source.getMinecraftServer());
}
public static void resetToCreative(ServerCommandSource source)
{
resetToBugFixes(source);
set(source, "fillLimit","500000");
set(source, "fillUpdates","false");
set(source, "portalCreativeDelay","true");
set(source, "portalCaching","true");
set(source, "flippinCactus","true");
set(source, "hopperCounters","true");
set(source, "antiCheatSpeed","true");
}
public static void resetToSurvival(ServerCommandSource source)
{
resetToBugFixes(source);
set(source, "ctrlQCraftingFix","true");
set(source, "persistentParrots", "true");
set(source, "stackableEmptyShulkerBoxes","true");
set(source, "flippinCactus","true");
set(source, "hopperCounters","true");
set(source, "carpets","true");
set(source, "missingTools","true");
set(source, "portalCaching","true");
set(source, "miningGhostBlocksFix","true");
}
public static void resetToBugFixes(ServerCommandSource source)
{
resetToVanilla(source);
set(source, "portalSuffocationFix","true");
set(source, "pistonGhostBlocksFix","serverOnly");
set(source, "portalTeleportationFix","true");
set(source, "entityDuplicationFix","true");
set(source, "inconsistentRedstoneTorchesFix","true");
set(source, "llamaOverfeedingFix","true");
set(source, "invisibilityFix","true");
set(source, "potionsDespawnFix","true");
set(source, "liquidsNotRandom","true");
set(source, "mobsDontControlMinecarts","true");
set(source, "breedingMountingDisabled","true");
set(source, "growingUpWallJump","true");
set(source, "reloadSuffocationFix","true");
set(source, "watchdogFix","true");
set(source, "unloadedEntityFix","true");
set(source, "hopperDuplicationFix","true");
set(source, "calmNetherFires","true");
}
public static class CarpetSettingEntry
{
private String rule;
private String string;
private int integer;
private boolean bool;
private float flt;
private String[] options;
private String[] tags;
private String toast;
private String[] extra_info;
private String default_string_value;
private boolean isFloat;
private boolean strict;
private List<BiConsumer<ServerCommandSource, String>> validators;
//factory
public static CarpetSettingEntry create(String rule_name, String tags, String toast)
{
return new CarpetSettingEntry(rule_name, tags, toast);
}
private CarpetSettingEntry(String rule_name, String tags_string, String toast_string)
{
set(null, "false");
rule = rule_name;
default_string_value = string;
tags = tags_string.split("\\s+"); // never empty
toast = toast_string;
options = "true false".split("\\s+");
isFloat = false;
extra_info = null;
strict = true;
validators = null;
}
public CarpetSettingEntry defaultTrue()
{
set(null, "true");
default_string_value = string;
options = "true false".split("\\s+");
return this;
}
public CarpetSettingEntry validate(BiConsumer<ServerCommandSource, String> method)
{
if (validators == null)
{
validators = new ArrayList<>();
}
validators.add(method);
return this;
}
public CarpetSettingEntry boolAccelerate()
{
BiConsumer<ServerCommandSource, String> validator = (source, name) -> {
try
{
Field f = CarpetSettings.class.getDeclaredField("b_"+name);
f.setBoolean(null, CarpetSettings.getBool(name));
}
catch (IllegalAccessException e)
{
CarpetSettings.LOG.error("[CM Error] rule "+name+" has wrong access to boolean accelerator");
}
catch (NoSuchFieldException e)
{
CarpetSettings.LOG.error("[CM Error] rule "+name+" doesn't have a boolean accelerator");
}
};
return validate(validator);
}
public CarpetSettingEntry numAccelerate()
{
BiConsumer<ServerCommandSource, String> validator = (source, name) -> {
try
{
Field f = CarpetSettings.class.getDeclaredField("n_"+name);
if (CarpetSettings.get(name).isFloat)
{
f.setDouble(null, (double) CarpetSettings.getFloat(name));
}
else
{
f.setInt(null, CarpetSettings.getInt(name));
}
}
catch (IllegalAccessException e)
{
CarpetSettings.LOG.error("[CM Error] rule "+name+" wrong type of numerical accelerator");
}
catch (NoSuchFieldException e)
{
CarpetSettings.LOG.error("[CM Error] rule "+name+" doesn't have a numerical accelerator");
}
};
return validate(validator);
}
public CarpetSettingEntry isACommand()
{
return this.defaultTrue().validate( (s, n) -> notifyPlayersCommandsChanged());
}
public CarpetSettingEntry defaultFalse()
{
set(null, "false");
default_string_value = string;
options = "true false".split("\\s+");
return this;
}
public CarpetSettingEntry choices(String defaults, String options_string)
{
set(null, defaults);
default_string_value = string;
options = options_string.split("\\s+");
return this;
}
public CarpetSettingEntry extraInfo(String ... extra_info_string)
{
extra_info = extra_info_string;
return this;
}
public CarpetSettingEntry setFloat()
{
isFloat = true;
strict = false;
return this;
}
public CarpetSettingEntry setNotStrict()
{
strict = false;
return this;
}
private void set(ServerCommandSource source, String unparsed)
{
setForce(unparsed);
if (validators != null)
{
validators.forEach((r) -> r.accept(source, this.getName()));
}
}
private void setForce(String unparsed)
{
string = unparsed;
try
{
integer = Integer.parseInt(unparsed);
}
catch(NumberFormatException e)
{
integer = 0;
}
try
{
flt = Float.parseFloat(unparsed);
}
catch(NumberFormatException e)
{
flt = 0.0F;
}
bool = (integer > 0) || Boolean.parseBoolean(unparsed);
}
//accessors
public boolean isDefault() { return string.equals(default_string_value); }
public String getDefault() { return default_string_value; }
public String toString() { return rule + ": " + string; }
public String getToast() { return toast; }
public String[] getInfo() { return extra_info == null?new String[0]:extra_info; }
public String[] getOptions() { return options;}
public String[] getTags() { return tags; }
public String getName() { return rule; }
public String getStringValue() { return string; }
public boolean getBoolValue() { return bool; }
public int getIntegerValue() { return integer; }
public float getFloatValue() { return flt; }
public boolean getIsFloat() { return isFloat;}
//actual stuff
public void reset(ServerCommandSource s)
{
set(s, default_string_value);
}
public boolean matches(String tag)
{
tag = tag.toLowerCase();
if (rule.toLowerCase().contains(tag))
{
return true;
}
for (String t: tags)
{
if (tag.equalsIgnoreCase(t))
{
return true;
}
}
return false;
}
public String getNextValue()
{
int i;
for(i = 0; i < options.length; i++)
{
if(options[i].equals(string))
{
break;
}
}
i++;
return options[i % options.length];
}
public boolean isStrict()
{
return strict;
}
public CarpetSettingEntry wip()
{
return validate( (s, n) -> {
if (s != null)
try
{
Messenger.m(s, "r Work in progress - limited or no functionality available for "+n);
}
catch (NullPointerException ignored) { }
});
}
}
}
@@ -1,6 +1,6 @@
package carpet.commands;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
@@ -19,13 +19,13 @@ public class CameraModeCommand
public static void register(CommandDispatcher<ServerCommandSource> dispatcher)
{
LiteralArgumentBuilder<ServerCommandSource> camera = literal("c").
requires((player) -> CarpetSettings.getBool("commandCameramode")).
requires((player) -> CarpetSettings.commandCameramode).
executes((c) -> cameraMode(c.getSource(), c.getSource().getPlayer())).
then(argument("player", EntityArgumentType.player()).
executes( (c) -> cameraMode(c.getSource(), EntityArgumentType.getPlayer(c, "player"))));
LiteralArgumentBuilder<ServerCommandSource> survival = literal("s").
requires((player) -> CarpetSettings.getBool("commandCameramode")).
requires((player) -> CarpetSettings.commandCameramode).
executes((c) -> survivalMode(
c.getSource(),
c.getSource().getPlayer())).
@@ -1,19 +1,20 @@
package carpet.commands;
import carpet.CarpetSettings;
import carpet.CarpetSettings.CarpetSettingEntry;
import carpet.CarpetServer;
import carpet.settings.CarpetSettings;
import carpet.settings.ParsedRule;
import carpet.settings.SettingsManager;
import carpet.utils.Messenger;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.command.CommandManager;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.text.BaseText;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import static net.minecraft.server.command.CommandManager.argument;
@@ -25,46 +26,49 @@ public class CarpetCommand
public static void register(CommandDispatcher<ServerCommandSource> dispatcher)
{
LiteralArgumentBuilder<ServerCommandSource> literalargumentbuilder = literal("carpet").requires((player) ->
player.hasPermissionLevel(2) && !CarpetSettings.locked);
player.hasPermissionLevel(2) && !CarpetServer.settingsManager.locked);
literalargumentbuilder.executes((context)->listAllSettings(context.getSource())).
then(literal("list").
executes( (c) -> listSettings(c.getSource(),
"All CarpetMod Settings",
CarpetSettings.findAll(null))).
SettingsManager.getRules())).
then(literal("defaults").
executes( (c)-> listSettings(c.getSource(),
"Current CarpetMod Startup Settings from carpet.conf",
CarpetSettings.findStartupOverrides(c.getSource().getMinecraftServer())))).
CarpetServer.settingsManager.findStartupOverrides()))).
then(argument("tag",StringArgumentType.word()).
suggests( (c, b)->suggestMatching(CarpetSettings.default_tags, b)).
suggests( (c, b)->suggestMatching(SettingsManager.getCategories(), b)).
executes( (c) -> listSettings(c.getSource(),
String.format("CarpetMod Settings matching \"%s\"", StringArgumentType.getString(c, "tag")),
CarpetSettings.findAll(StringArgumentType.getString(c, "tag"))))));
CarpetServer.settingsManager.getRulesMatching(StringArgumentType.getString(c, "tag"))))));
for (CarpetSettingEntry rule: CarpetSettings.getAllCarpetSettings())
for (ParsedRule<?> rule: SettingsManager.getRules())
{
literalargumentbuilder.then(literal(rule.getName()).executes( (context) ->
literalargumentbuilder.then(literal(rule.name).executes( (context) ->
displayRuleMenu(context.getSource(),rule)));
literalargumentbuilder.then(literal("removeDefault").
then(literal(rule.getName()).executes((context) ->
requires(s -> !CarpetServer.settingsManager.locked).
then(literal(rule.name).executes((context) ->
removeDefault(context.getSource(), rule))));
literalargumentbuilder.then(literal(rule.getName()).
literalargumentbuilder.then(literal(rule.name).
requires(s -> !CarpetServer.settingsManager.locked).
then(argument("value", StringArgumentType.word()).
suggests((c, b)-> suggestMatching(rule.getOptions(),b)).
suggests((c, b)-> suggestMatching(rule.options,b)).
executes((context) ->
setRule(context.getSource(), rule, StringArgumentType.getString(context, "value")))));
literalargumentbuilder.then(literal("setDefault").
then(literal(rule.getName()).
requires(s -> !CarpetServer.settingsManager.locked).
then(literal(rule.name).
then(argument("value", StringArgumentType.word()).
suggests((c, b)-> suggestMatching(rule.getOptions(),b)).
suggests((c, b)-> suggestMatching(rule.options,b)).
executes((context) ->
setDefault(context.getSource(), rule, StringArgumentType.getString(context, "value"))))));
}
dispatcher.register(literalargumentbuilder);
}
private static int displayRuleMenu(ServerCommandSource source, CarpetSettingEntry rule)
private static int displayRuleMenu(ServerCommandSource source, ParsedRule<?> rule)
{
PlayerEntity player;
try
@@ -73,19 +77,19 @@ public class CarpetCommand
}
catch (CommandSyntaxException e)
{
Messenger.m(source, "w "+rule.getName() +" is set to: ","wb "+rule.getStringValue());
Messenger.m(source, "w "+rule.name +" is set to: ","wb "+rule.getAsString());
return 1;
}
Messenger.m(player, "");
Messenger.m(player, "wb "+rule.getName(),"!/carpet "+rule.getName(),"^g refresh");
Messenger.m(player, "w "+rule.getToast());
Messenger.m(player, "wb "+rule.name,"!/carpet "+rule.name,"^g refresh");
Messenger.m(player, "w "+rule.description);
Arrays.stream(rule.getInfo()).forEach(s -> Messenger.m(player, "g "+s));
rule.extraInfo.forEach(s -> Messenger.m(player, "g "+s));
List<BaseText> tags = new ArrayList<>();
tags.add(Messenger.c("w Tags: "));
for (String t: rule.getTags())
for (String t: rule.categories)
{
tags.add(Messenger.c("c ["+t+"]", "^g list all "+t+" settings","!/carpet list "+t));
tags.add(Messenger.c("w , "));
@@ -93,15 +97,12 @@ public class CarpetCommand
tags.remove(tags.size()-1);
Messenger.m(player, tags.toArray(new Object[0]));
Messenger.m(player, "w Current value: ",String.format("%s %s (%s value)",rule.getBoolValue()?"lb":"nb", rule.getStringValue(),rule.isDefault()?"default":"modified"));
Messenger.m(player, "w Current value: ",String.format("%s %s (%s value)",rule.getBoolValue()?"lb":"nb", rule.getAsString(),rule.isDefault()?"default":"modified"));
List<BaseText> options = new ArrayList<>();
options.add(Messenger.c("w Options: ", "y [ "));
for (String o: rule.getOptions())
for (String o: rule.options)
{
options.add(Messenger.c(
String.format("%s%s %s",(o.equals(rule.getDefault()))?"u":"", (o.equals(rule.getStringValue()))?"bl":"y", o ),
"^g switch to "+o,
String.format("?/carpet %s %s",rule.getName(),o)));
options.add(makeSetRuleButton(rule, o, false));
options.add(Messenger.c("w "));
}
options.remove(options.size()-1);
@@ -111,72 +112,77 @@ public class CarpetCommand
return 1;
}
private static int setRule(ServerCommandSource source, CarpetSettingEntry rule, String newValue)
private static int setRule(ServerCommandSource source, ParsedRule<?> rule, String newValue)
{
CarpetSettings.set(source, rule.getName(), newValue);
if (rule.set(source, newValue) != null)
Messenger.m(source, "w "+rule.toString()+", ", "c [change permanently?]",
"^w Click to keep the settings in carpet.conf to save across restarts",
"?/carpet setDefault "+rule.getName()+" "+rule.getStringValue());
"?/carpet setDefault "+rule.name+" "+rule.getAsString());
return 1;
}
private static int setDefault(ServerCommandSource source, CarpetSettingEntry rule, String defaultValue)
private static int setDefault(ServerCommandSource source, ParsedRule<?> rule, String defaultValue)
{
CarpetSettings.setDefaultRule(source, rule.getName(), defaultValue);
Messenger.m(source ,"gi rule "+ rule.getName()+" will now default to "+ defaultValue);
if (CarpetServer.settingsManager.setDefaultRule(source, rule.name, defaultValue))
Messenger.m(source ,"gi rule "+ rule.name+" will now default to "+ defaultValue);
return 1;
}
private static int removeDefault(ServerCommandSource source, CarpetSettingEntry rule)
private static int removeDefault(ServerCommandSource source, ParsedRule<?> rule)
{
CarpetSettings.removeDefaultRule(source, rule.getName());
Messenger.m(source ,"gi rule "+ rule.getName()+" defaults to Vanilla");
if (CarpetServer.settingsManager.removeDefaultRule(source, rule.name))
Messenger.m(source ,"gi rule "+ rule.name+" defaults to Vanilla");
return 1;
}
private static BaseText displayInteractiveSetting(CarpetSettingEntry e)
private static BaseText displayInteractiveSetting(ParsedRule<?> rule)
{
List<Object> args = new ArrayList<>();
args.add("w - "+e.getName()+" ");
args.add("!/carpet "+e.getName());
args.add("^y "+e.getToast());
for (String option: e.getOptions())
args.add("w - "+rule.name+" ");
args.add("!/carpet "+rule.name);
args.add("^y "+rule.description);
for (String option: rule.options)
{
String style = e.isDefault()?"g":(option.equalsIgnoreCase(e.getDefault())?"y":"e");
if (option.equalsIgnoreCase(e.getDefault()))
style = style+"b";
else if (option.equalsIgnoreCase(e.getStringValue()))
style = style+"u";
args.add(style+" ["+option+"]");
if (!option.equalsIgnoreCase(e.getStringValue()))
{
args.add("!/carpet " + e.getName() + " " + option);
args.add("^w switch to " + option);
}
args.add(makeSetRuleButton(rule, option, true));
args.add("w ");
}
args.remove(args.size()-1);
return Messenger.c(args.toArray(new Object[0]));
}
private static int listSettings(ServerCommandSource source, String title, CarpetSettingEntry[] settings_list)
private static BaseText makeSetRuleButton(ParsedRule<?> rule, String option, boolean brackets)
{
String style = rule.isDefault()?"g":(option.equalsIgnoreCase(rule.defaultAsString)?"y":"e");
if (option.equalsIgnoreCase(rule.defaultAsString))
style = style+"b";
else if (option.equalsIgnoreCase(rule.getAsString()))
style = style+"u";
String baseText = style + (brackets ? " [" : " ") + option + (brackets ? "]" : "");
if (CarpetServer.settingsManager.locked)
return Messenger.c(baseText, "^g Settings are locked");
if (option.equalsIgnoreCase(rule.getAsString()))
return Messenger.c(baseText);
return Messenger.c(baseText, "^g Switch to " + option, "?/carpet " + rule.name + " " + option);
}
private static int listSettings(ServerCommandSource source, String title, Collection<ParsedRule<?>> settings_list)
{
try
{
PlayerEntity player = source.getPlayer();
Messenger.m(player,String.format("wb %s:",title));
Arrays.stream(settings_list).forEach(e -> Messenger.m(player,displayInteractiveSetting(e)));
settings_list.forEach(e -> Messenger.m(player,displayInteractiveSetting(e)));
}
catch (CommandSyntaxException e)
{
Messenger.m(source, "w s:"+title);
Arrays.stream(settings_list).forEach(r -> Messenger.m(source, "w - "+ r.toString()));
settings_list.forEach(r -> Messenger.m(source, "w - "+ r.toString()));
}
return 1;
}
private static int listAllSettings(ServerCommandSource source)
{
listSettings(source, "Current CarpetMod Settings", CarpetSettings.find_nondefault(source.getMinecraftServer()));
listSettings(source, "Current CarpetMod Settings", CarpetServer.settingsManager.getNonDefault());
Messenger.m(source, "Carpet Mod version: "+ CarpetSettings.carpetVersion);
try
@@ -184,7 +190,7 @@ public class CarpetCommand
PlayerEntity player = source.getPlayer();
List<Object> tags = new ArrayList<>();
tags.add("w Browse Categories:\n");
for (String t : CarpetSettings.default_tags)
for (String t : SettingsManager.getCategories())
{
tags.add("c [" + t+"]");
tags.add("^g list all " + t + " settings");
@@ -194,9 +200,7 @@ public class CarpetCommand
tags.remove(tags.size() - 1);
Messenger.m(player, tags.toArray(new Object[0]));
}
catch (CommandSyntaxException e)
{
}
catch (CommandSyntaxException ignored) { }
return 1;
}
}
@@ -1,6 +1,6 @@
package carpet.commands;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import carpet.helpers.HopperCounter;
import carpet.utils.Messenger;
import com.mojang.brigadier.CommandDispatcher;
@@ -17,7 +17,7 @@ public class CounterCommand
{
LiteralArgumentBuilder<ServerCommandSource> literalargumentbuilder = CommandManager.literal("counter").executes((context)
-> listAllCounters(context.getSource(), false)).requires((player) ->
CarpetSettings.getBool("hopperCounters"));
CarpetSettings.hopperCounters);
literalargumentbuilder.
then((CommandManager.literal("reset").executes( (p_198489_1_)->
@@ -1,6 +1,6 @@
package carpet.commands;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import carpet.utils.DistanceCalculator;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
@@ -15,7 +15,7 @@ public class DistanceCommand
public static void register(CommandDispatcher<ServerCommandSource> dispatcher)
{
LiteralArgumentBuilder<ServerCommandSource> command = literal("distance").
requires((player) -> CarpetSettings.getBool("commandDistance")).
requires((player) -> CarpetSettings.commandDistance).
then(literal("from").
executes( (c) -> DistanceCalculator.setStart(c.getSource(), c.getSource().getPosition())).
then(argument("from", Vec3ArgumentType.create()).
@@ -1,6 +1,6 @@
package carpet.commands;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import carpet.utils.Messenger;
import com.google.common.collect.Lists;
import com.mojang.brigadier.CommandDispatcher;
@@ -29,7 +29,7 @@ public class DrawCommand
public static void register(CommandDispatcher<ServerCommandSource> dispatcher)
{
LiteralArgumentBuilder<ServerCommandSource> command = literal("draw").
requires((player) -> CarpetSettings.getBool("commandDraw")).
requires((player) -> CarpetSettings.commandDraw).
then(literal("sphere").
then(argument("center",BlockPosArgumentType.create()).
then(argument("radius",IntegerArgumentType.integer(1)).
@@ -113,6 +113,7 @@ public class DrawCommand
}
}
CarpetSettings.impendingFillSkipUpdates = !CarpetSettings.fillUpdates;
for (int xmod = -1; xmod < 2; xmod+= 2)
{
for (int ymod = -1; ymod < 2; ymod += 2)
@@ -129,11 +130,7 @@ public class DrawCommand
((Inventory)tileentity).clear();
}
if (block.setBlockState(
world,
mbpos,
2 | (CarpetSettings.getBool("fillUpdates") ?0:1024)
))
if (block.setBlockState(world, mbpos,2))
{
list.add(mbpos.toImmutable());
++affected;
@@ -142,10 +139,11 @@ public class DrawCommand
}
}
}
CarpetSettings.impendingFillSkipUpdates = false;
}
}
}
if (CarpetSettings.getBool("fillUpdates"))
if (CarpetSettings.fillUpdates)
{
for (BlockPos blockpos1 : list)
@@ -1,6 +1,6 @@
package carpet.commands;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import carpet.utils.BlockInfo;
import carpet.utils.EntityInfo;
import carpet.utils.Messenger;
@@ -29,7 +29,7 @@ public class InfoCommand
public static void register(CommandDispatcher<ServerCommandSource> dispatcher)
{
LiteralArgumentBuilder<ServerCommandSource> command = literal("info").
requires((player) -> CarpetSettings.getBool("commandInfo")).
requires((player) -> CarpetSettings.commandInfo).
then(literal("block").
then(argument("block position", BlockPosArgumentType.create()).
executes( (c) -> infoBlock(
@@ -1,6 +1,6 @@
package carpet.commands;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import carpet.logging.Logger;
import carpet.logging.LoggerRegistry;
import carpet.utils.Messenger;
@@ -26,7 +26,7 @@ public class LogCommand
public static void register(CommandDispatcher<ServerCommandSource> dispatcher)
{
LiteralArgumentBuilder<ServerCommandSource> literalargumentbuilder = CommandManager.literal("log").
requires((player) -> CarpetSettings.getBool("commandLog")).
requires((player) -> CarpetSettings.commandLog).
executes((context) -> listLogs(context.getSource())).
then(CommandManager.literal("clear").
executes( (c) -> unsubFromAll(c.getSource(), c.getSource().getName())).
@@ -1,6 +1,6 @@
package carpet.commands;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import carpet.utils.Messenger;
import carpet.utils.PerimeterDiagnostics;
import com.mojang.brigadier.CommandDispatcher;
@@ -22,7 +22,7 @@ public class PerimeterInfoCommand
public static void register(CommandDispatcher<ServerCommandSource> dispatcher)
{
LiteralArgumentBuilder<ServerCommandSource> command = literal("perimeterinfo").
requires((player) -> CarpetSettings.getBool("commandPerimeterInfo")).
requires((player) -> CarpetSettings.commandPerimeterInfo).
executes( (c) -> perimeterDiagnose(
c.getSource(),
new BlockPos(c.getSource().getPosition()),
@@ -1,6 +1,6 @@
package carpet.commands;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import carpet.fakes.ServerPlayerEntityInterface;
import carpet.patches.EntityPlayerMPFake;
import carpet.utils.Messenger;
@@ -38,7 +38,7 @@ public class PlayerCommand
public static void register(CommandDispatcher<ServerCommandSource> dispatcher)
{
LiteralArgumentBuilder<ServerCommandSource> literalargumentbuilder = literal("player").
requires((player) -> CarpetSettings.getBool("commandPlayer")).
requires((player) -> CarpetSettings.commandPlayer).
then(argument("player", word()).
suggests( (c, b) -> suggestMatching(getPlayers(c.getSource()), b)).
then(literal("stop").
@@ -1,7 +1,7 @@
package carpet.commands;
import carpet.CarpetServer;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import carpet.script.CarpetEventServer;
import carpet.script.CarpetExpression;
import carpet.script.Expression;
@@ -26,8 +26,6 @@ import net.minecraft.util.Clearable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.MutableIntBoundingBox;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.math.Vec3i;
import java.util.ArrayList;
import java.util.Collection;
@@ -228,10 +226,10 @@ public class ScriptCommand
dispatcher.register(literal("script").
requires((player) -> CarpetSettings.getBool("commandScript")).
requires((player) -> CarpetSettings.commandScript).
then(b).then(u).then(o).then(l).then(s).then(c).then(h).then(i).then(e).then(t).then(a).then(f).then(q));
dispatcher.register(literal("script").
requires((player) -> CarpetSettings.getBool("commandScript")).
requires((player) -> CarpetSettings.commandScript).
then(literal("in").
then(argument("package", StringArgumentType.word()).
suggests( (cc, bb) -> suggestMatching(CarpetServer.scriptServer.modules.keySet(), bb)).
@@ -379,12 +377,13 @@ public class ScriptCommand
MutableIntBoundingBox area = new MutableIntBoundingBox(a, b);
CarpetExpression cexpr = new CarpetExpression(expr, source, origin);
int int_1 = area.getBlockCountX() * area.getBlockCountY() * area.getBlockCountZ();
if (int_1 > CarpetSettings.getInt("fillLimit"))
if (int_1 > CarpetSettings.fillLimit)
{
Messenger.m(source, "r too many blocks to evaluate: " + int_1);
return 1;
}
int successCount = 0;
CarpetSettings.impendingFillSkipUpdates = !CarpetSettings.fillUpdates;
try
{
for (int x = area.minX; x <= area.maxX; x++)
@@ -409,6 +408,10 @@ public class ScriptCommand
Messenger.m(source, "r Error while processing command: "+exc);
return 0;
}
finally
{
CarpetSettings.impendingFillSkipUpdates = false;
}
Messenger.m(source, "w Expression successful in " + successCount + " out of " + int_1 + " blocks");
return successCount;
@@ -423,7 +426,7 @@ public class ScriptCommand
MutableIntBoundingBox area = new MutableIntBoundingBox(a, b);
CarpetExpression cexpr = new CarpetExpression(expr, source, origin);
int int_1 = area.getBlockCountX() * area.getBlockCountY() * area.getBlockCountZ();
if (int_1 > CarpetSettings.getInt("fillLimit"))
if (int_1 > CarpetSettings.fillLimit)
{
Messenger.m(source, "r too many blocks to evaluate: "+ int_1);
return 1;
@@ -434,7 +437,6 @@ public class ScriptCommand
BlockPos.Mutable mbpos = new BlockPos.Mutable(origin);
ServerWorld world = source.getWorld();
for (int x = area.minX; x <= area.maxX; x++)
{
for (int y = area.minY; y <= area.maxY; y++)
@@ -490,6 +492,8 @@ public class ScriptCommand
volume = newVolume;
}
int affected = 0;
CarpetSettings.impendingFillSkipUpdates = !CarpetSettings.fillUpdates;
for (int x = 0; x <= maxx; x++)
{
for (int y = 0; y <= maxy; y++)
@@ -505,11 +509,7 @@ public class ScriptCommand
BlockEntity tileentity = world.getBlockEntity(mbpos);
Clearable.clear(tileentity);
if (block.setBlockState(
world,
mbpos,
2 | (CarpetSettings.getBool("fillUpdates") ?0:1024)
))
if (block.setBlockState(world, mbpos,2))
{
++affected;
}
@@ -518,7 +518,9 @@ public class ScriptCommand
}
}
}
if (CarpetSettings.getBool("fillUpdates") && block != null)
CarpetSettings.impendingFillSkipUpdates = false;
if (CarpetSettings.fillUpdates && block != null)
{
for (int x = 0; x <= maxx; x++)
{
@@ -1,6 +1,6 @@
package carpet.commands;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import carpet.helpers.HopperCounter;
import carpet.helpers.TickSpeed;
import carpet.utils.Messenger;
@@ -37,7 +37,7 @@ public class SpawnCommand
public static void register(CommandDispatcher<ServerCommandSource> dispatcher)
{
LiteralArgumentBuilder<ServerCommandSource> literalargumentbuilder = literal("spawn").
requires((player) -> CarpetSettings.getBool("commandSpawn"));
requires((player) -> CarpetSettings.commandSpawn);
literalargumentbuilder.
then(literal("list").
@@ -1,5 +1,6 @@
package carpet.commands;
import carpet.CarpetServer;
import carpet.utils.Messenger;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
@@ -15,6 +16,7 @@ public class TestCommand
public static void register(CommandDispatcher<ServerCommandSource> dispatcher)
{
dispatcher.register(literal("test").
then(literal("dump").executes((c) -> CarpetServer.settingsManager.printAllRulesToLog())).
then(argument("first",word()).
executes( (c)-> test(c, getString(c, "first")+" 1"))).
then(argument("second", word()).
@@ -23,7 +25,7 @@ public class TestCommand
private static int test(CommandContext<ServerCommandSource> c, String term)
{
Messenger.m(c.getSource(),"w term is: ",term.substring(0,1)+"b "+term);
Messenger.m(c.getSource(),term.substring(0,1)+" "+term+": how did you get here?");
return 1;
}
}
@@ -1,6 +1,6 @@
package carpet.commands;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import carpet.helpers.TickSpeed;
import carpet.utils.CarpetProfiler;
import carpet.utils.Messenger;
@@ -26,7 +26,7 @@ public class TickCommand
public static void register(CommandDispatcher<ServerCommandSource> dispatcher)
{
LiteralArgumentBuilder<ServerCommandSource> literalargumentbuilder = literal("tick").
requires((player) -> CarpetSettings.getBool("commandTick")).
requires((player) -> CarpetSettings.commandTick).
then(literal("rate").
executes((c) -> queryTps(c.getSource())).
then(argument("rate", floatArg(0.1F, 500.0F)).
@@ -1,6 +1,6 @@
package carpet.helpers;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import net.minecraft.block.AbstractRedstoneGateBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
@@ -44,7 +44,7 @@ public class BlockRotator
{
public static boolean flipBlockWithCactus(BlockState state, World world, PlayerEntity player, Hand hand, BlockHitResult hit)
{
if (!player.abilities.allowModifyWorld || !CarpetSettings.getBool("flippinCactus") || !player_holds_cactus_mainhand(player))
if (!player.abilities.allowModifyWorld || !CarpetSettings.flippinCactus || !player_holds_cactus_mainhand(player))
{
return false;
}
@@ -283,8 +283,7 @@ public class BlockRotator
}
public static boolean flippinEligibility(Entity entity)
{
if (CarpetSettings.getBool("flippinCactus")
&& (entity instanceof PlayerEntity))
if (CarpetSettings.flippinCactus && (entity instanceof PlayerEntity))
{
PlayerEntity player = (PlayerEntity)entity;
return (!player.getOffHandStack().isEmpty()
@@ -299,7 +298,7 @@ public class BlockRotator
@Override
protected ItemStack dispenseSilently(BlockPointer source, ItemStack stack)
{
if (CarpetSettings.getBool("rotatorBlock"))
if (CarpetSettings.rotatorBlock)
{
return BlockRotator.dispenserRotate(source, stack);
}
@@ -1,6 +1,6 @@
package carpet.helpers;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import carpet.mixins.PlayerActionC2SPacketMixin;
import net.minecraft.entity.Entity;
import net.minecraft.server.network.ServerPlayerEntity;
@@ -1,6 +1,6 @@
package carpet.helpers;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import carpet.fakes.StructureFeatureInterface;
import net.minecraft.block.Blocks;
import net.minecraft.util.math.BlockPos;
@@ -1,6 +1,6 @@
package carpet.logging;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.DyeColor;
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import net.minecraft.block.dispenser.BlockPlacementDispenserBehavior;
import net.minecraft.item.ItemStack;
import org.spongepowered.asm.mixin.Mixin;
@@ -13,7 +13,7 @@ public class BlockPlacementDispenserBehaviourMixin
@Redirect(method = "dispenseSilently", at = @At(value="INVOKE", target="Lnet/minecraft/item/ItemStack;decrement(I)V"))
private void cancleDoubleDecrement(ItemStack stack, int amount)
{
if (!CarpetSettings.b_stackableShulkerBoxes)
if (!CarpetSettings.stackableShulkerBoxes)
{
stack.decrement(amount);
}
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import net.minecraft.structure.BuriedTreasureGenerator;
import net.minecraft.world.Heightmap;
import net.minecraft.world.IWorld;
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.chunk.ChunkGenerator;
import net.minecraft.world.gen.feature.FeatureConfig;
+1 -1
View File
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.chunk.Chunk;
import org.spongepowered.asm.mixin.Mixin;
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import net.minecraft.block.Block;
import net.minecraft.server.command.CloneCommand;
import net.minecraft.server.world.ServerWorld;
@@ -17,7 +17,7 @@ public abstract class CloneCommandMixin
{
@ModifyConstant(method = "execute", constant = @Constant(intValue = 32768))
private static int fillLimit(int original) {
return CarpetSettings.getInt("fillLimit");
return CarpetSettings.fillLimit;
}
@Redirect(method = "execute", at = @At(
@@ -26,6 +26,6 @@ public abstract class CloneCommandMixin
))
private static void conditionalUpdating(ServerWorld serverWorld, BlockPos blockPos_1, Block block_1)
{
if (CarpetSettings.b_fillUpdates) serverWorld.updateNeighbors(blockPos_1, block_1);
if (CarpetSettings.fillUpdates) serverWorld.updateNeighbors(blockPos_1, block_1);
}
}
@@ -1,7 +1,7 @@
package carpet.mixins;
import carpet.CarpetServer;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import com.mojang.brigadier.CommandDispatcher;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;
@@ -30,7 +30,7 @@ public abstract class CommandManagerMixin
@Inject(method = "execute", at = @At("HEAD"))
private void onExecuteBegin(ServerCommandSource serverCommandSource_1, String string_1, CallbackInfoReturnable<Integer> cir)
{
if (!CarpetSettings.b_fillUpdates)
if (!CarpetSettings.fillUpdates)
CarpetSettings.impendingFillSkipUpdates = true;
}
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import net.minecraft.container.Container;
import net.minecraft.container.Slot;
import net.minecraft.container.SlotActionType;
@@ -29,7 +29,7 @@ public class ContainerMixin
CallbackInfoReturnable<ItemStack> cir
)
{
if (slotActionType_1 == SlotActionType.THROW && CarpetSettings.getBool("ctrlQCraftingFix") && playerEntity_1.inventory.getCursorStack().isEmpty() && int_1 >= 0)
if (slotActionType_1 == SlotActionType.THROW && CarpetSettings.ctrlQCraftingFix && playerEntity_1.inventory.getCursorStack().isEmpty() && int_1 >= 0)
{
ItemStack itemStack_1 = ItemStack.EMPTY;
Slot slot_4 = slotList.get(int_1);
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import carpet.fakes.CoralFeatureInterface;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
@@ -30,7 +30,7 @@ public abstract class CoralBlockMixin implements Fertilizable
{
public boolean isFertilizable(BlockView var1, BlockPos var2, BlockState var3, boolean var4)
{
return CarpetSettings.getBool("renewableCoral") && var3.get(CoralParentBlock.WATERLOGGED) && var1.getFluidState(var2.up()).matches(FluidTags.WATER);
return CarpetSettings.renewableCoral && var3.get(CoralParentBlock.WATERLOGGED) && var1.getFluidState(var2.up()).matches(FluidTags.WATER);
}
public boolean canGrow(World var1, Random var2, BlockPos var3, BlockState var4)
@@ -1,7 +1,5 @@
package carpet.mixins;
import carpet.CarpetSettings;
import com.mojang.bridge.game.GameVersion;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.hud.DebugHud;
import org.spongepowered.asm.mixin.Mixin;
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import carpet.fakes.EntityInterface;
import carpet.helpers.BlockRotator;
import net.minecraft.entity.Entity;
@@ -16,7 +16,7 @@ public abstract class DirectionMixin
private static float getYaw(Entity entity, float float_1)
{
float yaw;
if (!CarpetSettings.getBool("placementRotationFix"))
if (!CarpetSettings.placementRotationFix)
{
yaw = entity.getYaw(float_1);
}
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import com.google.common.collect.Lists;
import com.mojang.datafixers.Dynamic;
import net.minecraft.entity.EntityType;
@@ -27,7 +27,7 @@ public abstract class EndCityFeatureMixin extends StructureFeature<DefaultFeatur
@Override
public List<Biome.SpawnEntry> getMonsterSpawns()
{
if (CarpetSettings.b_shulkerSpawningInEndCities)
if (CarpetSettings.shulkerSpawningInEndCities)
return spawnList;
return Collections.emptyList();
}
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import carpet.fakes.ExperienceOrbInterface;
import carpet.helpers.XPcombine;
import net.minecraft.entity.ExperienceOrbEntity;
@@ -31,7 +31,7 @@ public abstract class ExperienceOrbEntityMixin implements ExperienceOrbInterface
))
void checkCombineAtTick(CallbackInfo ci)
{
if (CarpetSettings.getBool("combineXPOrbs"))
if (CarpetSettings.combineXPOrbs)
{
if (getCombineDelay() > 0)
{
@@ -48,7 +48,7 @@ public abstract class ExperienceOrbEntityMixin implements ExperienceOrbInterface
@Inject(method = "onPlayerCollision", at = @At("HEAD"))
void removeDelay(PlayerEntity playerEntity_1, CallbackInfo ci)
{
if (CarpetSettings.getBool("xpNoCooldown"))
if (CarpetSettings.xpNoCooldown)
playerEntity_1.experiencePickUpDelay = 0;
}
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.explosion.Explosion;
import org.spongepowered.asm.mixin.Final;
@@ -23,7 +23,7 @@ public abstract class ExplosionMixin
target = "Ljava/util/List;addAll(Ljava/util/Collection;)Z"))
private void clearList(CallbackInfo ci)
{
if (CarpetSettings.getBool("explosionNoBlockDamage"))
if (CarpetSettings.explosionNoBlockDamage)
{
this.affectedBlocks.clear();
}
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import net.minecraft.block.Block;
import net.minecraft.server.command.FillCommand;
import net.minecraft.server.world.ServerWorld;
@@ -15,8 +15,9 @@ import org.spongepowered.asm.mixin.injection.Redirect;
public abstract class FillCommandMixin
{
@ModifyConstant(method = "execute", constant = @Constant(intValue = 32768))
private static int fillLimit(int original) {
return CarpetSettings.getInt("fillLimit");
private static int fillLimit(int original)
{
return CarpetSettings.fillLimit;
}
@Redirect(method = "execute", at = @At(
@@ -25,6 +26,6 @@ public abstract class FillCommandMixin
))
private static void conditionalUpdating(ServerWorld serverWorld, BlockPos blockPos_1, Block block_1)
{
if (CarpetSettings.b_fillUpdates) serverWorld.updateNeighbors(blockPos_1, block_1);
if (CarpetSettings.fillUpdates) serverWorld.updateNeighbors(blockPos_1, block_1);
}
}
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import net.minecraft.entity.EntityCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
@@ -25,7 +25,7 @@ public abstract class FloatingIslandsChunkGeneratorMixin extends SurfaceChunkGen
@Override
public List<Biome.SpawnEntry> getEntitySpawnList(EntityCategory entityCategory_1, BlockPos blockPos_1)
{
if (CarpetSettings.b_shulkerSpawningInEndCities && EntityCategory.MONSTER == entityCategory_1)
if (CarpetSettings.shulkerSpawningInEndCities && EntityCategory.MONSTER == entityCategory_1)
{
if (Feature.END_CITY.isInsideStructure(this.world, blockPos_1))
{
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import net.minecraft.world.Heightmap;
import net.minecraft.world.IWorld;
import net.minecraft.world.gen.feature.FossilFeature;
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import net.minecraft.structure.processor.GravityStructureProcessor;
import net.minecraft.world.Heightmap;
import net.minecraft.world.ViewableWorld;
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import net.minecraft.entity.EntityData;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LightningEntity;
@@ -24,7 +24,7 @@ public abstract class GuardianEntityMixin extends HostileEntity
@Override
public void onStruckByLightning(LightningEntity lightning)
{
if (!this.world.isClient && !this.removed && CarpetSettings.getBool("renewableSponges"))
if (!this.world.isClient && !this.removed && CarpetSettings.renewableSponges)
{
ElderGuardianEntity elderGuardian = new ElderGuardianEntity(EntityType.ELDER_GUARDIAN ,this.world);
elderGuardian.setPositionAndAngles(this.x, this.y, this.z, this.yaw, this.pitch);
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import net.minecraft.block.HopperBlock;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.block.entity.HopperBlockEntity;
@@ -41,13 +41,16 @@ public abstract class HopperBlockEntityMixin extends LootableContainerBlockEntit
@Inject(method = "insert", at = @At("HEAD"), cancellable = true)
private void onInsert(CallbackInfoReturnable<Boolean> cir)
{
if (CarpetSettings.b_hopperCounters) {
if (CarpetSettings.hopperCounters) {
DyeColor wool_color = WoolTool.getWoolColorAtPosition(
getWorld(),
new BlockPos(getHopperX(), getHopperY(), getHopperZ()).offset(this.getCachedState().get(HopperBlock.FACING)));
if (wool_color != null) {
for (int i = 0; i < this.getInvSize(); ++i) {
if (!this.getInvStack(i).isEmpty()) {
if (wool_color != null)
{
for (int i = 0; i < this.getInvSize(); ++i)
{
if (!this.getInvStack(i).isEmpty())
{
ItemStack itemstack = this.getInvStack(i);//.copy();
HopperCounter.COUNTERS.get(wool_color).add(this.getWorld().getServer(), itemstack);
this.setInvStack(i, ItemStack.EMPTY);
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import net.minecraft.structure.IglooGenerator;
import net.minecraft.world.Heightmap;
import net.minecraft.world.IWorld;
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
@@ -26,7 +26,7 @@ public abstract class InfestedBlockMixin extends Block
private void onOnStacksDropped(BlockState blockState_1, World world_1, BlockPos blockPos_1,
ItemStack itemStack_1, CallbackInfo ci)
{
if (CarpetSettings.getBool("silverFishDropGravel"))
if (CarpetSettings.silverFishDropGravel)
{
dropStack(world_1, blockPos_1, new ItemStack(Blocks.GRAVEL));
}
@@ -10,13 +10,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(IntegratedServer.class)
public class IntegratedServerMixin
{
@Inject(method = "setupServer",
at = @At(
value = "INVOKE",
shift = At.Shift.AFTER,
target = "Lnet/minecraft/server/integrated/IntegratedServer;setKeyPair(Ljava/security/KeyPair;)V"
)
)
@Inject(method = "setupServer", at = @At("TAIL"))
private void onSetupServerIntegrated(CallbackInfoReturnable<Boolean> cir) {
CarpetServer.onServerLoaded((IntegratedServer) (Object) this);
}
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import carpet.helpers.InventoryHelper;
import carpet.utils.IItemEntity;
import net.minecraft.block.ShulkerBoxBlock;
@@ -41,7 +41,7 @@ public abstract class ItemEntityMixin extends Entity implements IItemEntity {
@Inject(method="<init>(Lnet/minecraft/world/World;DDDLnet/minecraft/item/ItemStack;)V", at = @At("RETURN"))
private void removeEmptyShulkerBoxTags(World worldIn, double x, double y, double z, ItemStack stack, CallbackInfo ci)
{
if (CarpetSettings.b_stackableShulkerBoxes
if (CarpetSettings.stackableShulkerBoxes
&& stack.getItem() instanceof BlockItem
&& ((BlockItem)stack.getItem()).getBlock() instanceof ShulkerBoxBlock)
{
@@ -59,7 +59,7 @@ public abstract class ItemEntityMixin extends Entity implements IItemEntity {
)
)
private int getItemStackMaxAmount(ItemStack stack) {
if (CarpetSettings.b_stackableShulkerBoxes && stack.getItem() instanceof BlockItem && ((BlockItem)stack.getItem()).getBlock() instanceof ShulkerBoxBlock)
if (CarpetSettings.stackableShulkerBoxes && stack.getItem() instanceof BlockItem && ((BlockItem)stack.getItem()).getBlock() instanceof ShulkerBoxBlock)
return SHULKERBOX_MAX_STACK_AMOUNT;
return stack.getMaxCount();
@@ -74,7 +74,7 @@ public abstract class ItemEntityMixin extends Entity implements IItemEntity {
{
ItemEntity self = (ItemEntity)(Object)this;
ItemStack selfStack = self.getStack();
if (!CarpetSettings.b_stackableShulkerBoxes || !(selfStack.getItem() instanceof BlockItem) || !(((BlockItem)selfStack.getItem()).getBlock() instanceof ShulkerBoxBlock)) {
if (!CarpetSettings.stackableShulkerBoxes || !(selfStack.getItem() instanceof BlockItem) || !(((BlockItem)selfStack.getItem()).getBlock() instanceof ShulkerBoxBlock)) {
return;
}
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import net.minecraft.world.gen.feature.KelpFeature;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@@ -16,7 +16,7 @@ public class KelpFeatureMixin
{
if (bound==10)
return random.nextInt(bound);
int limit = CarpetSettings.getInt("kelpGenerationGrowLimit");
int limit = CarpetSettings.kelpGenerationGrowthLimit;
if (limit == 0)
return random.nextInt(bound);
return 25-limit+random.nextInt(Math.min(23,limit+1));
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
@@ -12,7 +12,6 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.List;
@@ -50,8 +49,8 @@ public abstract class LivingEntity_maxCollisionsMixin extends Entity
}
int limit = list_1.size();
if (CarpetSettings.n_maxEntityCollisions > 0)
limit = Math.min(limit, CarpetSettings.n_maxEntityCollisions);
if (CarpetSettings.maxEntityCollisions > 0)
limit = Math.min(limit, CarpetSettings.maxEntityCollisions);
for(int_2 = 0; int_2 < limit; ++int_2) {
Entity entity_1 = (Entity)list_1.get(int_2);
@@ -1,7 +1,7 @@
package carpet.mixins;
import carpet.CarpetServer;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import net.minecraft.client.MinecraftClient;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
@@ -12,15 +12,7 @@ public class MinecraftDedicatedServerMixin
{
//to inject right before
// this.tickWorlds(booleanSupplier_1);
@Inject(
method = "setupServer",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/util/UserCache;setUseRemote(Z)V",
shift = At.Shift.AFTER,
ordinal = 0
)
)
@Inject(method = "setupServer", at = @At("TAIL"))
private void onSetupServer(CallbackInfoReturnable<Boolean> cir) {
//CM init - all stuff loaded from the server, just before worlds loading
CarpetServer.onServerLoaded((MinecraftDedicatedServer) (Object) this);
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import carpet.fakes.MinecraftServer_motdInterface;
import net.minecraft.server.MinecraftServer;
import org.spongepowered.asm.mixin.Mixin;
@@ -27,15 +27,15 @@ public abstract class MinecraftServer_motdMixin implements MinecraftServer_motdI
@Override
public String checkMOTD()
{
if ("_".equals(CarpetSettings.getString("customMOTD")))
if ("_".equals(CarpetSettings.customMOTD))
{
setMotd(motd);
return motd;
}
else
{
setMotd(CarpetSettings.getString("customMOTD"));
return CarpetSettings.getString("customMOTD");
setMotd(CarpetSettings.customMOTD);
return CarpetSettings.customMOTD;
}
}
}
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import net.minecraft.structure.OceanRuinGenerator;
import net.minecraft.world.Heightmap;
import net.minecraft.world.IWorld;
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import carpet.fakes.BlockEntityRenderDispatcherInterface;
import carpet.fakes.PistonBlockEntityInterface;
import net.minecraft.block.entity.BlockEntity;
@@ -22,7 +22,7 @@ public abstract class PistonBlockEntityRenderer_movableTEMixin extends BlockEnti
double double_3, float float_1, int int_1, CallbackInfo ci)
{
if (!((PistonBlockEntityInterface) pistonBlockEntity_1).isRenderModeSet())
((PistonBlockEntityInterface) pistonBlockEntity_1).setRenderCarriedBlockEntity(CarpetSettings.b_movableTileEntities && ((PistonBlockEntityInterface) pistonBlockEntity_1).getCarriedBlockEntity() != null);
((PistonBlockEntityInterface) pistonBlockEntity_1).setRenderCarriedBlockEntity(CarpetSettings.movableTileEntities && ((PistonBlockEntityInterface) pistonBlockEntity_1).getCarriedBlockEntity() != null);
}
@Inject(method = "method_3576", at = @At("RETURN"))
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import carpet.fakes.PistonBlockEntityInterface;
import carpet.fakes.WorldInterface;
import net.minecraft.block.Block;
@@ -77,7 +77,7 @@ public abstract class PistonBlockEntity_movableTEMixin extends BlockEntity imple
target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
private boolean movableTEsetBlockState0(World world, BlockPos blockPos_1, BlockState blockAState_2, int int_1)
{
if (!CarpetSettings.b_movableTileEntities)
if (!CarpetSettings.movableTileEntities)
return world.setBlockState(blockPos_1, blockAState_2, int_1);
else
return ((WorldInterface) (world)).setBlockStateWithBlockEntity(blockPos_1, blockAState_2, this.carriedBlockEntity, int_1);
@@ -87,7 +87,7 @@ public abstract class PistonBlockEntity_movableTEMixin extends BlockEntity imple
target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
private boolean movableTEsetBlockState1(World world, BlockPos blockPos_1, BlockState blockState_2, int int_1)
{
if (!CarpetSettings.b_movableTileEntities)
if (!CarpetSettings.movableTileEntities)
return world.setBlockState(blockPos_1, blockState_2, int_1);
else
{
@@ -103,7 +103,7 @@ public abstract class PistonBlockEntity_movableTEMixin extends BlockEntity imple
//Handle TNT Explosions or other ways the moving Block is broken
//Also /setblock will cause this to be called, and drop e.g. a moving chest's contents.
// This is MC-40380 (BlockEntities that aren't Inventories drop stuff when setblock is called )
if (CarpetSettings.b_movableTileEntities && this.carriedBlockEntity != null && !this.world.isClient && this.world.getBlockState(this.pos).getBlock() == Blocks.AIR)
if (CarpetSettings.movableTileEntities && this.carriedBlockEntity != null && !this.world.isClient && this.world.getBlockState(this.pos).getBlock() == Blocks.AIR)
{
BlockState blockState_2;
if (this.source)
@@ -118,7 +118,7 @@ public abstract class PistonBlockEntity_movableTEMixin extends BlockEntity imple
@Inject(method = "fromTag", at = @At(value = "TAIL"))
private void onFromTag(CompoundTag compoundTag_1, CallbackInfo ci)
{
if (CarpetSettings.b_movableTileEntities && compoundTag_1.containsKey("carriedTileEntityCM", 10))
if (CarpetSettings.movableTileEntities && compoundTag_1.containsKey("carriedTileEntityCM", 10))
{
if (this.pushedBlock.getBlock() instanceof BlockEntityProvider)
this.carriedBlockEntity = ((BlockEntityProvider) (this.pushedBlock.getBlock())).createBlockEntity(this.world);
@@ -130,7 +130,7 @@ public abstract class PistonBlockEntity_movableTEMixin extends BlockEntity imple
@Inject(method = "toTag", at = @At(value = "RETURN", shift = At.Shift.BEFORE))
private void onToTag(CompoundTag compoundTag_1, CallbackInfoReturnable<CompoundTag> cir)
{
if (CarpetSettings.b_movableTileEntities && this.carriedBlockEntity != null)
if (CarpetSettings.movableTileEntities && this.carriedBlockEntity != null)
{
//Leave name "carriedTileEntityCM" instead of "carriedBlockEntityCM" for upgrade compatibility with 1.13.2 movable TE
compoundTag_1.put("carriedTileEntityCM", this.carriedBlockEntity.toTag(new CompoundTag()));
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import carpet.fakes.PistonBlockEntityInterface;
import com.google.common.collect.Lists;
import net.minecraft.block.*;
@@ -35,7 +35,7 @@ public abstract class PistonBlock_movableTEMixin extends FacingBlock
{
Block block_1 = blockState_1.getBlock();
//Make CommandBlocks movable, either use instanceof CommandBlock or the 3 cmd block objects,
if (CarpetSettings.b_movableTileEntities && block_1 instanceof CommandBlock)
if (CarpetSettings.movableTileEntities && block_1 instanceof CommandBlock)
{
cir.setReturnValue(true);
}
@@ -58,7 +58,7 @@ public abstract class PistonBlock_movableTEMixin extends FacingBlock
}
else
{
return !(CarpetSettings.b_movableTileEntities && isPushableTileEntityBlock(block));
return !(CarpetSettings.movableTileEntities && isPushableTileEntityBlock(block));
}
}
@Inject(method = "move", at = @At(value = "INVOKE", shift = At.Shift.BEFORE,
@@ -69,7 +69,7 @@ public abstract class PistonBlock_movableTEMixin extends FacingBlock
Direction direction_2, Set set_1)
{
//Get the blockEntities and remove them from the world before any magic starts to happen
if (CarpetSettings.b_movableTileEntities)
if (CarpetSettings.movableTileEntities)
{
list1_BlockEntities.set(Lists.<BlockEntity>newArrayList());
for (int i = 0; i < list_1.size(); ++i)
@@ -99,7 +99,7 @@ public abstract class PistonBlock_movableTEMixin extends FacingBlock
{
BlockEntity blockEntityPiston = PistonExtensionBlock.createBlockEntityPiston((BlockState) list_2.get(int_3),
direction_1, boolean_1, false);
if (CarpetSettings.b_movableTileEntities)
if (CarpetSettings.movableTileEntities)
((PistonBlockEntityInterface) blockEntityPiston).setCarriedBlockEntity(list1_BlockEntities.get().get(int_3));
world_1.setBlockEntity(blockPos_4, blockEntityPiston);
}
@@ -1,9 +1,8 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import net.minecraft.block.piston.PistonHandler;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
@@ -13,6 +12,6 @@ public class PistonHandler_pushLimitMixin
@ModifyConstant(method = "tryMove", constant = @Constant(intValue = 12), expect = 3)
private int pushLimit(int original)
{
return CarpetSettings.n_pushLimit;
return CarpetSettings.pushLimit;
}
}
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import carpet.helpers.PortalHelper;
import net.minecraft.entity.player.PlayerEntity;
import org.spongepowered.asm.mixin.Mixin;
@@ -13,7 +13,7 @@ public abstract class PlayerEntityMixin
@ModifyConstant(method = "getMaxPortalTime",
constant = @Constant(intValue = 1))
private int addFillUpdatesInt(int original) {
if (CarpetSettings.getBool("portalCreativeDelay"))
if (CarpetSettings.portalCreativeDelay)
if (PortalHelper.player_holds_obsidian((PlayerEntity) (Object)this))
return 72000;
else
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.damage.DamageSource;
@@ -50,7 +50,7 @@ public abstract class PlayerEntity_parrotMixin extends LivingEntity
target = "Lnet/minecraft/entity/player/PlayerEntity;updateShoulderEntity(Lnet/minecraft/nbt/CompoundTag;)V"))
private void onTickMovement(CallbackInfo ci)
{
boolean parrots_will_drop = !CarpetSettings.getBool("persistentParrots") || this.abilities.invulnerable;
boolean parrots_will_drop = !CarpetSettings.persistentParrots || this.abilities.invulnerable;
if (!this.world.isClient && ((parrots_will_drop && this.fallDistance > 0.5F) || this.isInWater() || (parrots_will_drop && this.hasVehicle())) || this.abilities.flying)
{
this.dropShoulderEntities();
@@ -80,7 +80,7 @@ public abstract class PlayerEntity_parrotMixin extends LivingEntity
target = "Lnet/minecraft/entity/player/PlayerEntity;dropShoulderEntities()V"))
private void onDamage(DamageSource damageSource_1, float float_1, CallbackInfoReturnable<Boolean> cir)
{
if (CarpetSettings.getBool("persistentParrots") && !this.isSneaking())
if (CarpetSettings.persistentParrots && !this.isSneaking())
{
if (this.random.nextFloat() < ((float_1)/15.0) )
{
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import carpet.fakes.PortalForcerInterface;
import net.minecraft.block.BlockState;
import net.minecraft.block.PortalBlock;
@@ -22,7 +22,7 @@ public class PortalBlock_portalCachingMixin
))
private void onCreatePortal(IWorld iWorld_1, BlockPos blockPos_1, CallbackInfoReturnable<Boolean> cir)
{
if (!iWorld_1.isClient() && CarpetSettings.getBool("portalCaching"))
if (!iWorld_1.isClient() && CarpetSettings.portalCaching)
{
((PortalForcerInterface)((ServerWorld)iWorld_1).getPortalForcer()).invalidateCache();
}
@@ -34,7 +34,7 @@ public class PortalBlock_portalCachingMixin
))
private void getAirBlockState(BlockState blockState_1, Direction direction_1, BlockState blockState_2, IWorld iWorld_1, BlockPos blockPos_1, BlockPos blockPos_2, CallbackInfoReturnable<BlockState> cir)
{
if (!iWorld_1.isClient() && CarpetSettings.getBool("portalCaching"))
if (!iWorld_1.isClient() && CarpetSettings.portalCaching)
{
((PortalForcerInterface)((ServerWorld)iWorld_1).getPortalForcer()).invalidateCache();
}
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import carpet.fakes.PortalForcerInterface;
import net.minecraft.entity.Entity;
import net.minecraft.server.world.ChunkTicketType;
@@ -45,7 +45,7 @@ public class PortalForcer_portalCachingMixin implements PortalForcerInterface
private Object /* private TicketInfo */ getTicketInfo(Map map, Object /* ColumnPos */ key)
{
//Do the dance with ticketinfos. If vanilla has one, we gonna borrow, if vanilla is missing, we supply
if (!CarpetSettings.getBool("portalCaching"))
if (!CarpetSettings.portalCaching)
return map.get(key);
Object ticketInfo = map.get(key);
if (ticketInfo != null)
@@ -71,7 +71,7 @@ public class PortalForcer_portalCachingMixin implements PortalForcerInterface
))
private Object /* TicketInfo */ putNewTicket(Map map, Object /*ColumnPos */ key, Object /*TicketInfo */ value)
{
if (CarpetSettings.getBool("portalCaching"))
if (CarpetSettings.portalCaching)
storedTicketInfos.put((ColumnPos) key, value);
return map.put(key, value);
}
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import net.minecraft.block.PoweredRailBlock;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
@@ -13,6 +13,6 @@ public class PoweredRailBlock_powerLimitMixin
constant = @Constant(intValue = 8))
private int powerLimit(int original)
{
return CarpetSettings.railPowerLimitAdjusted;
return CarpetSettings.railPowerLimit-1;
}
}
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import carpet.helpers.BlockSaplingHelper;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
@@ -23,7 +23,7 @@ public abstract class SaplingBlockMixin
cancellable = true)
private void onGenerate(IWorld iWorld_1, BlockPos blockPos_1, BlockState blockState_1, Random random_1, CallbackInfo ci)
{
if(CarpetSettings.getBool("desertShrubs") && iWorld_1.getBiome(blockPos_1) == Biomes.DESERT && !BlockSaplingHelper.hasWater(iWorld_1, blockPos_1))
if(CarpetSettings.desertShrubs && iWorld_1.getBiome(blockPos_1) == Biomes.DESERT && !BlockSaplingHelper.hasWater(iWorld_1, blockPos_1))
{
iWorld_1.setBlockState(blockPos_1, Blocks.DEAD_BUSH.getDefaultState(), 3);
ci.cancel();
@@ -1,19 +1,17 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import carpet.helpers.TickSpeed;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.network.packet.PlayerInputC2SPacket;
import net.minecraft.server.network.packet.PlayerMoveC2SPacket;
import net.minecraft.server.network.packet.VehicleMoveC2SPacket;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
@Mixin(ServerPlayNetworkHandler.class)
public class ServerPlayNetworkHandlerMixin
@@ -51,7 +49,7 @@ public class ServerPlayNetworkHandlerMixin
target = "Lnet/minecraft/server/network/ServerPlayerEntity;isInTeleportationState()Z"))
private boolean relaxMoveRestrictions(ServerPlayerEntity serverPlayerEntity)
{
return serverPlayerEntity.isInTeleportationState() || CarpetSettings.getBool("antiCheatSpeed");
return serverPlayerEntity.isInTeleportationState() || CarpetSettings.antiCheatSpeed;
}
}
@@ -1,7 +1,6 @@
package carpet.mixins;
import carpet.CarpetServer;
import carpet.CarpetSettings;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.network.packet.ClientCommandC2SPacket;
@@ -1,7 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import net.minecraft.entity.player.PlayerEntity;
import carpet.settings.CarpetSettings;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.server.world.ServerWorld;
import org.spongepowered.asm.mixin.Final;
@@ -26,7 +25,7 @@ public class ServerWorld_onePlayerSleepingMixin
@Inject(method = "updatePlayersSleeping", cancellable = true, at = @At("HEAD"))
private void updateOnePlayerSleeping(CallbackInfo ci)
{
if(CarpetSettings.getBool("onePlayerSleeping"))
if(CarpetSettings.onePlayerSleeping)
{
allPlayersSleeping = false;
for (ServerPlayerEntity p : players)
@@ -46,7 +45,7 @@ public class ServerWorld_onePlayerSleepingMixin
))
private boolean noneMatchSleep(Stream<ServerPlayerEntity> stream, Predicate<ServerPlayerEntity> predicate)
{
if (CarpetSettings.getBool("onePlayerSleeping"))
if (CarpetSettings.onePlayerSleeping)
return stream.anyMatch((p) -> !p.isSpectator() && p.isSleepingLongEnough());
return stream.noneMatch(predicate);
}
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import net.minecraft.block.Block;
import net.minecraft.server.command.SetBlockCommand;
import net.minecraft.server.world.ServerWorld;
@@ -18,6 +18,6 @@ public class SetBlockCommandMixin
))
private static void conditionalUpdating(ServerWorld serverWorld, BlockPos blockPos_1, Block block_1)
{
if (CarpetSettings.b_fillUpdates) serverWorld.updateNeighbors(blockPos_1, block_1);
if (CarpetSettings.fillUpdates) serverWorld.updateNeighbors(blockPos_1, block_1);
}
}
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import net.minecraft.structure.ShipwreckGenerator;
import net.minecraft.world.Heightmap;
import net.minecraft.world.IWorld;
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import carpet.fakes.WorldInterface;
import carpet.utils.SpawnReporter;
import net.minecraft.block.Block;
@@ -35,7 +35,7 @@ public class SpawnHelperMixin
// various configurations, but solid and 'passable' blocks, like air, water grass, etc.
// checking if in the BB of the entity are only passable blocks is very cheap and covers most cases
// in case something more complex happens - we default to full block collision check
if (CarpetSettings.b_lagFreeSpawning)
if (CarpetSettings.lagFreeSpawning)
{
BlockPos.Mutable blockpos = new BlockPos.Mutable();
for (int y = (int)bb.minY, maxy = (int)Math.ceil(bb.maxY); y < maxy; y++)
@@ -61,7 +61,7 @@ public class SpawnHelperMixin
))
private static Entity create(EntityType<?> entityType, World world_1)
{
if (CarpetSettings.b_lagFreeSpawning)
if (CarpetSettings.lagFreeSpawning)
{
Map<EntityType, Entity> precookedMobs = ((WorldInterface)world_1).getPrecookedMobs();
if (precookedMobs.containsKey(entityType))
@@ -80,7 +80,7 @@ public class SpawnHelperMixin
))
private static boolean spawnEntity(World world, Entity entity_1)
{
if (CarpetSettings.b_lagFreeSpawning)
if (CarpetSettings.lagFreeSpawning)
// we used the mob - next time we will create a new one when needed
((WorldInterface) world).getPrecookedMobs().remove(entity_1.getType());
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import net.minecraft.block.entity.StructureBlockBlockEntity;
import net.minecraft.structure.Structure;
import net.minecraft.structure.StructurePlacementData;
@@ -19,7 +19,7 @@ public abstract class StructureBlockBlockEntity_fillUpdatesMixin
))
private void onStructurePlacen(Structure structure, IWorld iWorld_1, BlockPos blockPos_1, StructurePlacementData structurePlacementData_1)
{
if(!CarpetSettings.b_fillUpdates)
if(!CarpetSettings.fillUpdates)
CarpetSettings.impendingFillSkipUpdates = true;
try
{
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import carpet.fakes.StructureFeatureInterface;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.structure.StructureStart;
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import net.minecraft.structure.StructurePiece;
import net.minecraft.world.Heightmap;
import net.minecraft.world.ViewableWorld;
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import net.minecraft.block.Block;
import net.minecraft.structure.Structure;
import net.minecraft.util.math.BlockPos;
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LightningEntity;
import net.minecraft.entity.mob.SkeletonHorseEntity;
@@ -31,7 +31,7 @@ public class SummonCommandMixin
private static void addRiders(ServerCommandSource source, Identifier identifier_1, Vec3d vec3d_1, CompoundTag compoundTag_1, boolean arg4, CallbackInfoReturnable<Integer> cir, CompoundTag compoundTag_2, LightningEntity lightningEntity_1)
{
// [CM] SummonNaturalLightning - if statement around
if (CarpetSettings.getBool("summonNaturalLightning") && !source.getWorld().isClient)
if (CarpetSettings.summonNaturalLightning && !source.getWorld().isClient)
{
ServerWorld world = source.getWorld();
BlockPos at = new BlockPos(vec3d_1);
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import net.minecraft.block.TntBlock;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@@ -11,11 +11,11 @@ import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(TntBlock.class)
public abstract class TntBlockMixin
{
// Add carpet rule check for TNTDoNotUpdate to an if statement.
// Add carpet rule check for tntDoNotUpdate to an if statement.
@Redirect(method = "onBlockAdded", at = @At(value = "INVOKE",
target = "Lnet/minecraft/world/World;isReceivingRedstonePower(Lnet/minecraft/util/math/BlockPos;)Z"))
private boolean isTNTDoNotUpdate(World world, BlockPos blockPos)
{
return !CarpetSettings.getBool("TNTDoNotUpdate") && world.isReceivingRedstonePower(blockPos);
return !CarpetSettings.tntDoNotUpdate && world.isReceivingRedstonePower(blockPos);
}
}
@@ -1,11 +1,10 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.TntEntity;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
@@ -49,7 +48,7 @@ public abstract class TntEntityMixin extends Entity
private void initTNTLogger(World world_1, double double_1, double double_2, double double_3,
LivingEntity livingEntity_1, CallbackInfo ci)
{
if(CarpetSettings.getBool("tntPrimerMomentumRemoved"))
if(CarpetSettings.tntPrimerMomentumRemoved)
this.setVelocity(new Vec3d(0.0, 0.20000000298023224D, 0.0));
}
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import carpet.fakes.WorldChunkInterface;
import net.minecraft.block.Block;
import net.minecraft.block.BlockEntityProvider;
@@ -48,7 +48,7 @@ public abstract class WorldChunk_movableTEMixin implements WorldChunkInterface
private BlockEntity ifGetBlockEntity(WorldChunk worldChunk, BlockPos blockPos_1,
WorldChunk.CreationType worldChunk$CreationType_1)
{
if (!CarpetSettings.b_movableTileEntities)
if (!CarpetSettings.movableTileEntities)
{
return this.getBlockEntity(blockPos_1, WorldChunk.CreationType.CHECK);
}
@@ -1,6 +1,6 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
@@ -1,7 +1,7 @@
package carpet.script;
import carpet.CarpetServer;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import carpet.helpers.FeatureGenerator;
import carpet.fakes.MinecraftServerInterface;
import carpet.script.exception.CarpetExpressionException;
@@ -21,7 +21,6 @@ import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.EntityType;
@@ -707,7 +706,7 @@ public class CarpetExpression
}
if (sourceBlockState == targetBlockState)
return (c_, t_) -> Value.FALSE;
if (!CarpetSettings.b_fillUpdates) CarpetSettings.impendingFillSkipUpdates = true;
CarpetSettings.impendingFillSkipUpdates = !CarpetSettings.fillUpdates;
cc.s.getWorld().setBlockState(targetLocator.block.getPos(), sourceBlockState, 2);
CarpetSettings.impendingFillSkipUpdates = false;
Value retval = new BlockValue(sourceBlockState, world, targetLocator.block.getPos());
@@ -1,7 +1,7 @@
package carpet.script;
import carpet.CarpetServer;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import carpet.script.bundled.CameraPathModule;
import carpet.script.bundled.FileModule;
import carpet.script.bundled.ModuleInterface;
@@ -242,7 +242,7 @@ public class CarpetScriptServer
}
Messenger.m(source, "gi Package "+hostName+" loaded with /"+hostName+" command");
CarpetServer.minecraft_server.getCommandManager().getDispatcher().register(command);
CarpetSettings.notifyPlayersCommandsChanged();
CarpetServer.settingsManager.notifyPlayersCommandsChanged();
}
public void setChatErrorSnooper(ServerCommandSource source)
@@ -304,7 +304,7 @@ public class CarpetScriptServer
}
// stop all events associated with name
modules.remove(name);
CarpetSettings.notifyPlayersCommandsChanged();
CarpetServer.settingsManager.notifyPlayersCommandsChanged();
Messenger.m(source, "w Removed host "+name);
return true;
}
+1 -1
View File
@@ -1,7 +1,7 @@
package carpet.script;
import carpet.CarpetServer;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import carpet.script.exception.ExpressionException;
import carpet.script.exception.InvalidCallbackException;
import carpet.script.value.NumericValue;
@@ -0,0 +1,385 @@
package carpet.settings;
import carpet.CarpetServer;
import carpet.fakes.MinecraftServer_motdInterface;
import carpet.utils.Messenger;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.dedicated.DedicatedServer;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import static carpet.settings.RuleCategory.BUGFIX;
import static carpet.settings.RuleCategory.COMMAND;
import static carpet.settings.RuleCategory.CREATIVE;
import static carpet.settings.RuleCategory.EXPERIMENTAL;
import static carpet.settings.RuleCategory.FEATURE;
import static carpet.settings.RuleCategory.OPTIMIZATION;
import static carpet.settings.RuleCategory.SURVIVAL;
public class CarpetSettings
{
public static final String carpetVersion = "v19_06_04alpha";
public static final Logger LOG = LogManager.getLogger();
public static boolean skipGenerationChecks = false;
public static boolean impendingFillSkipUpdates = false;
@Rule(
desc = "Fixes server crashing supposedly on falling behind 60s in ONE tick, yeah bs.",
extra = "Fixed 1.12 watchdog crash in 1.13 pre-releases, reintroduced with 1.13, GG.",
category = BUGFIX,
validate = Validator.WIP.class
)
public static boolean watchdogCrashFix = false;
@Rule(
desc = "Nether portals correctly place entities going through",
extra = "Entities shouldn't suffocate in obsidian",
category = BUGFIX,
validate = Validator.WIP.class
)
public static boolean portalSuffocationFix = false;
@Rule(desc = "Gbhs sgnf sadsgras fhskdpri!", category = EXPERIMENTAL)
public static boolean superSecretSetting = false;
@Rule(
desc = "Portals won't let a creative player go through instantly",
extra = "Holding obsidian in either hand won't let you through at all",
category = CREATIVE
)
public static boolean portalCreativeDelay = false;
@Rule(desc = "Dropping entire stacks works also from on the crafting UI result slot", category = {BUGFIX, SURVIVAL})
public static boolean ctrlQCraftingFix = false;
@Rule(
desc = "Parrots don't get of your shoulders until you receive damage",
category = {SURVIVAL, FEATURE},
validate = Validator.WIP.class
)
public static boolean persistentParrots = false;
/*@Rule(
desc = "Mobs growing up won't glitch into walls or go through fences",
category = BUGFIX,
validate = Validator.WIP.class
)
public static boolean growingUpWallJump = false;
@Rule(
desc = "Won't let mobs glitch into blocks when reloaded.",
extra = "Can cause slight differences in mobs behaviour",
category = {BUGFIX, EXPERIMENTAL},
validate = Validator.WIP.class
)
public static boolean reloadSuffocationFix = false;
*/
@Rule( desc = "Players absorb XP instantly, without delay", category = CREATIVE )
public static boolean xpNoCooldown = false;
@Rule( desc = "XP orbs combine with other into bigger orbs", category = FEATURE )
public static boolean combineXPOrbs = false;
@Rule(
desc = "Empty shulker boxes can stack to 64 when dropped on the ground",
extra = "To move them around between inventories, use shift click to move entire stacks",
category = {SURVIVAL, FEATURE}
)
public static boolean stackableShulkerBoxes = false;
@Rule( desc = "Explosions won't destroy blocks", category = CREATIVE )
public static boolean explosionNoBlockDamage = false;
@Rule( desc = "Removes random TNT momentum when primed", category = CREATIVE )
public static boolean tntPrimerMomentumRemoved = false;
@Rule(
desc = "Lag optimizations for redstone dust",
extra = "by Theosib",
category = {EXPERIMENTAL, OPTIMIZATION},
validate = Validator.WIP.class
)
public static boolean fastRedstoneDust = false;
@Rule(desc = "Only husks spawn in desert temples", category = FEATURE, validate = Validator.WIP.class)
public static boolean huskSpawningInTemples = false;
@Rule( desc = "Shulkers will respawn in end cities", category = FEATURE )
public static boolean shulkerSpawningInEndCities = false;
@Rule(desc = "Entities pushed or moved into unloaded chunks no longer disappear", category = {EXPERIMENTAL, BUGFIX}, validate = Validator.WIP.class)
public static boolean unloadedEntityFix = false;
@Rule( desc = "TNT doesn't update when placed against a power source", category = CREATIVE )
public static boolean tntDoNotUpdate = false;
@Rule(
desc = "Prevents players from rubberbanding when moving too fast",
extra = "Puts more trust in clients positioning",
category = {CREATIVE, SURVIVAL},
validate = Validator.WIP.class
)
public static boolean antiCheatSpeed = false;
@Rule(desc = "Pistons, droppers and dispensers react if block above them is powered", category = CREATIVE, validate = Validator.WIP.class)
public static boolean quasiConnectivity = true;
@Rule(
desc = "Players can flip and rotate blocks when holding cactus",
extra = {
"Doesn't cause block updates when rotated/flipped",
"Applies to pistons, observers, droppers, repeaters, stairs, glazed terracotta etc..."
},
category = {CREATIVE, SURVIVAL, FEATURE}
)
public static boolean flippinCactus = false;
@Rule(
desc = "hoppers pointing to wool will count items passing through them",
extra = {
"Enables /counter command, and actions while placing red and green carpets on wool blocks",
"Use /counter <color?> reset to reset the counter, and /counter <color?> to query",
"In survival, place green carpet on same color wool to query, red to reset the counters",
"Counters are global and shared between players, 16 channels available",
"Items counted are destroyed, count up to one stack per tick per hopper"
},
category = {COMMAND, CREATIVE, FEATURE}
)
public static boolean hopperCounters = false;
@Rule( desc = "Guardians turn into Elder Guardian when struck by lightning", category = FEATURE )
public static boolean renewableSponges = false;
@Rule( desc = "Pistons can push tile entities, like hoppers, chests etc.", category = {EXPERIMENTAL, FEATURE} )
public static boolean movableTileEntities = false;
@Rule( desc = "Saplings turn into dead shrubs in hot climates and no water access", category = FEATURE )
public static boolean desertShrubs = false;
@Rule( desc = "Silverfish drop a gravel item when breaking out of a block", category = FEATURE )
public static boolean silverFishDropGravel = false;
@Rule( desc = "summoning a lightning bolt has all the side effects of natural lightning", category = CREATIVE )
public static boolean summonNaturalLightning = false;
@Rule(desc = "Enables /spawn command for spawn tracking", category = COMMAND)
public static boolean commandSpawn = true;
@Rule(desc = "Enables /tick command to control game clocks", category = COMMAND)
public static boolean commandTick = true;
@Rule(desc = "Enables /log command to monitor events in the game via chat and overlays", category = COMMAND)
public static boolean commandLog = true;
@Rule(
desc = "Enables /distance command to measure in game distance between points",
extra = "Also enables brown carpet placement action if 'carpets' rule is turned on as well",
category = COMMAND
)
public static boolean commandDistance = true;
@Rule(
desc = "Enables /info command for blocks",
extra = {
"Also enables gray carpet placement action",
"if 'carpets' rule is turned on as well"
},
category = COMMAND
)
public static boolean commandInfo = true;
@Rule(
desc = "Enables /c and /s commands to quickly switch between camera and survival modes",
extra = "/c and /s commands are available to all players regardless of their permission levels",
category = COMMAND
)
public static boolean commandCameramode = true;
@Rule(
desc = "Enables /perimeterinfo command",
extra = "... that scans the area around the block for potential spawnable spots",
category = COMMAND
)
public static boolean commandPerimeterInfo = true;
@Rule(desc = "Enables /draw commands", extra = "... allows for drawing simple shapes", category = COMMAND)
public static boolean commandDraw = true;
@Rule(desc = "Enables /script command", extra = "An in-game scripting API for Scarpet programming language", category = COMMAND)
public static boolean commandScript = true;
@Rule(desc = "Enables /player command to control/spawn players", category = COMMAND, validate = Validator.WIP.class)
public static boolean commandPlayer = true;
@Rule(desc = "Placing carpets may issue carpet commands for non-op players", category = SURVIVAL)
public static boolean carpets = false;
@Rule(
desc = "Pistons, Glass and Sponge can be broken faster with their appropriate tools",
category = SURVIVAL,
validate = Validator.WIP.class
)
public static boolean missingTools = false;
@Rule(desc = "Alternative, persistent caching strategy for nether portals", category = {SURVIVAL, CREATIVE})
public static boolean portalCaching = false;
@Rule(desc = "Permanent fires don't schedule random updates", category = OPTIMIZATION, validate = Validator.WIP.class)
public static boolean calmNetherFires = false;
@Rule(desc = "fill/clone/setblock and structure blocks cause block updates", category = CREATIVE)
public static boolean fillUpdates = true;
private static class PushLimitLimits extends Validator<Integer> {
@Override public Integer validate(ServerCommandSource source, ParsedRule<Integer> currentRule, Integer newValue, String string) {
return (newValue>0 && newValue <= 1024) ? newValue : null;
}
@Override
public String description() { return "You must choose a value from 1 to 1024";}
}
@Rule(
desc = "Customizable piston push limit",
options = {"10", "12", "14", "100"},
category = CREATIVE,
validate = PushLimitLimits.class
)
public static int pushLimit = 12;
@Rule(
desc = "Customizable powered rail power range",
options = {"9", "15", "30"},
category = CREATIVE,
validate = PushLimitLimits.class
)
public static int railPowerLimit = 9;
private static class FillLimitLimits extends Validator<Integer> {
@Override public Integer validate(ServerCommandSource source, ParsedRule<Integer> currentRule, Integer newValue, String string) {
return (newValue>0 && newValue < 20000000) ? newValue : null;
}
@Override
public String description() { return "You must choose a value from 1 to 20M";}
}
@Rule(
desc = "Customizable fill/clone volume limit",
options = {"32768", "250000", "1000000"},
category = CREATIVE,
validate = FillLimitLimits.class
)
public static int fillLimit = 32768;
@Rule(
desc = "Customizable maximal entity collision limits, 0 for no limits",
options = {"0", "1", "20"},
category = OPTIMIZATION,
validate = Validator.NONNEGATIVE_NUMBER.class
)
public static int maxEntityCollisions = 0;
@Rule(desc = "One player is required on the server to cause night to pass", category = SURVIVAL)
public static boolean onePlayerSleeping = false;
private static class SetMotd extends Validator<String> {
@Override public String validate(ServerCommandSource source, ParsedRule<String> currentRule, String newValue, String string) {
customMOTD = newValue; // accelerate a smidge
((MinecraftServer_motdInterface) CarpetServer.minecraft_server).checkMOTD();
return newValue;
}
}
@Rule(
desc = "Sets a different motd message on client trying to connect to the server",
extra = "use '_' to use the startup setting from server.properties",
options = "_",
category = CREATIVE,
validate = {SetMotd.class, Validator.WIP.class} // for some reason doesn't yet work
)
public static String customMOTD = "_";
@Rule(desc = "Cactus in dispensers rotates blocks.", extra = "Rotates block anti-clockwise if possible", category = FEATURE)
public static boolean rotatorBlock = false;
private static class ViewDistanceValidator extends Validator<Integer>
{
@Override public Integer validate(ServerCommandSource source, ParsedRule<Integer> currentRule, Integer newValue, String string)
{
if (newValue < 0 || newValue > 32)
{
Messenger.m(source, "r view distance has to be between 0 and 32");
return null;
}
MinecraftServer server = source.getMinecraftServer();
if (server.isDedicated())
{
int vd = (newValue >= 2)?newValue:((DedicatedServer) server).getProperties().viewDistance;
if (vd != CarpetServer.minecraft_server.getPlayerManager().getViewDistance())
CarpetServer.minecraft_server.getPlayerManager().setViewDistance(vd);
return newValue;
}
else
{
Messenger.m(source, "r view distance can only be changed on a server");
return 0;
}
}
@Override
public String description() { return "You must choose a value from 0 (use server settings) to 32";}
}
@Rule(
desc = "Changes the view distance of the server.",
extra = "Set to 0 to not override the value in server settings.",
options = {"0", "12", "16", "32"},
category = CREATIVE,
validate = ViewDistanceValidator.class
)
public static int viewDistance = 0;
private static class DisableSpawnChunksValidator extends Validator<Boolean> {
@Override public Boolean validate(ServerCommandSource source, ParsedRule<Boolean> currentRule, Boolean newValue, String string) {
if (!newValue)
Messenger.m(source, "w Spawn chunks re-enabled. Visit spawn to load them?");
return newValue;
}
}
@Rule(
desc = "Allows spawn chunks to unload",
category = CREATIVE,
validate = {Validator.WIP.class, DisableSpawnChunksValidator.class}
)
public static boolean disableSpawnChunks = false;
private static class KelpLimit extends Validator<Integer>
{
@Override public Integer validate(ServerCommandSource source, ParsedRule<Integer> currentRule, Integer newValue, String string) {
return (newValue>=0 && newValue <=25)?newValue:null;
}
@Override
public String description() { return "You must choose a value from 0 to 25. 25 and all natural kelp can grow 25 blocks, choose 0 to make all generated kelp not to grow";}
}
@Rule(
desc = "limits growth limit of newly naturally generated kelp to this amount of blocks",
options = {"0", "2", "25"},
category = FEATURE,
validate = KelpLimit.class
)
public static int kelpGenerationGrowthLimit = 25;
@Rule(desc = "Coral structures will grow with bonemeal from coral plants", category = FEATURE)
public static boolean renewableCoral = false;
@Rule(desc = "fixes block placement rotation issue when player rotates quickly while placing blocks", category = BUGFIX)
public static boolean placementRotationFix = false;
@Rule(
desc = "Fixes leads breaking/becoming invisible in unloaded chunks",
extra = "You may still get visibly broken leash links on the client side, but server side the link is still there.",
category = BUGFIX,
validate = Validator.WIP.class
)
public static boolean leadFix = false;
@Rule(desc = "Spawning requires much less CPU and Memory", category = OPTIMIZATION)
public static boolean lagFreeSpawning = false;
}
@@ -0,0 +1,195 @@
package carpet.settings;
import carpet.CarpetServer;
import carpet.utils.Messenger;
import com.google.common.collect.ImmutableList;
import net.minecraft.server.command.ServerCommandSource;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
public final class ParsedRule<T> implements Comparable<ParsedRule> {
public final Field field;
public final String name;
public final String description;
public final ImmutableList<String> extraInfo;
public final ImmutableList<String> categories;
public final ImmutableList<String> options;
public boolean isStrict;
public final Class<T> type;
public final List<Validator<T>> validators;
public final T defaultValue;
public final String defaultAsString;
ParsedRule(Field field, Rule rule)
{
this.field = field;
this.name = rule.name().isEmpty() ? field.getName() : rule.name();
this.type = (Class<T>) field.getType();
this.description = rule.desc();
this.isStrict = rule.strict();
this.extraInfo = ImmutableList.copyOf(rule.extra());
this.categories = ImmutableList.copyOf(rule.category());
this.validators = new ArrayList<>();
for (Class v : rule.validate())
this.validators.add((Validator<T>) callConstructor(v));
if (categories.contains(RuleCategory.COMMAND))
this.validators.add(callConstructor(Validator._COMMAND.class));
this.defaultValue = get();
this.defaultAsString = convertToString(this.defaultValue);
if (this.type == boolean.class)
{
this.isStrict = true; // it has no sense otherwise
this.options = ImmutableList.of("true", "false");
}
else if (this.type.isEnum())
{
this.isStrict = true; // it has no sense otherwise
this.options = Arrays.stream(this.type.getEnumConstants()).map(e -> ((Enum) e).name().toLowerCase(Locale.ROOT)).collect(ImmutableList.toImmutableList());
}
else
{
this.options = ImmutableList.copyOf(rule.options());
}
if (isStrict)
this.validators.add(callConstructor(Validator._STRICT.class));
}
private <T> T callConstructor(Class<T> cls)
{
try
{
Constructor<T> constr = cls.getDeclaredConstructor();
constr.setAccessible(true);
return constr.newInstance();
}
catch (ReflectiveOperationException e)
{
throw new RuntimeException(e);
}
}
public ParsedRule<T> set(ServerCommandSource source, String value)
{
if (CarpetServer.settingsManager != null && CarpetServer.settingsManager.locked)
return null;
if (type == String.class)
{
return set(source, (T) value, value);
}
else if (type == boolean.class)
{
return set(source, (T) (Object) Boolean.parseBoolean(value), value);
}
else if (type == int.class)
{
return set(source, (T) (Object) Integer.parseInt(value), value);
}
else if (type.isEnum())
{
String ucValue = value.toUpperCase(Locale.ROOT);
return set(source, (T) (Object) Enum.valueOf((Class<? extends Enum>) type, ucValue), value);
}
else
{
Messenger.m(source, "r Unknown type " + type.getSimpleName());
return null;
}
}
ParsedRule<T> set(ServerCommandSource source, T value, String stringValue)
{
try
{
for (Validator<T> validator : this.validators)
{
value = validator.validate(source, this, value, stringValue);
if (value == null)
{
Messenger.m(source, "r Wrong value for " + name + ": " + stringValue);
return null;
}
}
if (!value.equals(get()))
{
this.field.set(null, value);
SettingsManager.notifyRuleChanged(this, stringValue);
}
}
catch (IllegalAccessException e)
{
Messenger.m(source, "r Unable to access setting for "+name);
return null;
}
return this;
}
public T get()
{
try
{
return (T) this.field.get(null);
}
catch (IllegalAccessException e)
{
throw new IllegalStateException(e);
}
}
public String getAsString()
{
return convertToString(get());
}
public boolean getBoolValue()
{
if (type == boolean.class) return (Boolean) get();
if (type.isAssignableFrom(Number.class)) return ((Number) get()).doubleValue() > 0;
return false;
}
public boolean isDefault()
{
return defaultValue.equals(get());
}
public void resetToDefault(ServerCommandSource source)
{
set(source, defaultValue, defaultAsString);
}
private static String convertToString(Object value)
{
if (value instanceof Enum) return ((Enum) value).name().toLowerCase(Locale.ROOT);
return value.toString();
}
@Override
public boolean equals(Object obj)
{
return obj.getClass() == ParsedRule.class && ((ParsedRule) obj).name.equals(this.name);
}
@Override
public int hashCode()
{
return this.name.hashCode();
}
@Override
public int compareTo(ParsedRule o)
{
return this.name.compareTo(o.name);
}
@Override
public String toString()
{
return this.name + ": " + getAsString();
}
}
+59
View File
@@ -0,0 +1,59 @@
package carpet.settings;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Any field in this class annotated with this class is interpreted as a carpet rule.
* The field must be static and have a type of one of:
* - boolean
* - int
* - double
* - String
* - a subclass of Enum
* The default value of the rule will be the initial value of the field.
*/
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@interface Rule
{
/**
* The rule name, by default the same as the field name
*/
String name() default ""; // default same as field name
/**
* A description of the rule
*/
String desc();
/**
* Extra information about the rule
*/
String[] extra() default {};
/**
* A list of categories the rule is in
*/
String[] category();
/**
* Options to select in menu.
* Inferred for booleans and enums. Otherwise, must be present.
*/
String[] options() default {};
/**
* if a rule is not strict - can take any value, otherwise it needs to match
* any of the options
* For enums, its always strict, same for booleans - no need to set that for them.
*/
boolean strict() default false;
/**
* The class of the validator checked when the rule is changed.
*/
Class<? extends Validator>[] validate() default {};
}
@@ -0,0 +1,13 @@
package carpet.settings;
public class RuleCategory
{
public static final String BUGFIX = "bugfix";
public static final String SURVIVAL = "survival";
public static final String CREATIVE = "creative";
public static final String EXPERIMENTAL = "experimental";
public static final String OPTIMIZATION = "optimization";
public static final String FEATURE = "feature";
public static final String COMMAND = "command";
}
@@ -0,0 +1,290 @@
package carpet.settings;
import com.google.common.collect.ImmutableList;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintStream;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.function.BiConsumer;
import java.util.stream.Collectors;
public class SettingsManager
{
private static final Logger LOG = LogManager.getLogger();
private static Map<String, ParsedRule<?>> rules = new HashMap<>();
public boolean locked;
private MinecraftServer server;
private static List<BiConsumer<ParsedRule<?>, String>> observers = new ArrayList<>();
public SettingsManager(MinecraftServer server)
{
this.server = server;
loadConfigurationFromConf();
}
public static void parseSettingsClass(Class settingsClass)
{
for (Field f : settingsClass.getDeclaredFields())
{
Rule rule = f.getAnnotation(Rule.class);
if (rule == null) continue;
ParsedRule parsed = new ParsedRule(f, rule);
rules.put(parsed.name, parsed);
}
}
public static void addRuleObserver(BiConsumer<ParsedRule<?>, String> observer)
{
observers.add(observer);
}
static void notifyRuleChanged(ParsedRule<?> rule, String userTypedValue)
{
observers.forEach(observer -> observer.accept(rule, userTypedValue));
}
public static Iterable<String> getCategories()
{
Set<String> categories = new HashSet<>();
getRules().stream().map(r -> r.categories).forEach(categories::addAll);
return categories;
}
public ParsedRule getRule(String name)
{
return rules.get(name);
}
public static Collection<ParsedRule<?>> getRules()
{
CarpetSettings.LOG.error("grabbing rules");
List<ParsedRule<?>> r = rules.values().stream().sorted().collect(Collectors.toList());
CarpetSettings.LOG.error("Got: "+r.size()+" rules");
return r;
}
public Collection<ParsedRule<?>> findStartupOverrides()
{
Set<String> defaults = readSettingsFromConf().getLeft().keySet();
return rules.values().stream().filter(r -> defaults.contains(r.name)).
sorted().collect(Collectors.toList());
}
public Collection<ParsedRule<?>> getNonDefault()
{
return rules.values().stream().filter(r -> !r.isDefault()).sorted().collect(Collectors.toList());
}
private File getFile()
{
return server.getLevelStorage().resolveFile(server.getLevelName(), "carpet.conf");
}
public void disableBooleanFromCategory(String category)
{
for (ParsedRule<?> rule : rules.values())
{
if (rule.type != boolean.class || !rule.categories.contains(category))
continue;
((ParsedRule<Boolean>) rule).set(server.getCommandSource(), false, "false");
}
}
private void writeSettingsToConf(Map<String, String> values)
{
if (locked)
return;
try
{
FileWriter fw = new FileWriter(getFile());
for (String key: values.keySet())
{
fw.write(key+" "+values.get(key)+"\n");
}
fw.close();
}
catch (IOException e)
{
e.printStackTrace();
LOG.error("[CM]: failed write the carpet.conf");
}
///todo is it really needed? resendCommandTree();
}
public void notifyPlayersCommandsChanged()
{
if (server.getPlayerManager() == null)
{
return;
}
for (ServerPlayerEntity entityplayermp : server.getPlayerManager().getPlayerList())
{
server.getCommandManager().sendCommandTree(entityplayermp);
}
}
private void loadConfigurationFromConf()
{
for (ParsedRule<?> rule : rules.values()) rule.resetToDefault(server.getCommandSource());
Pair<Map<String, String>,Boolean> conf = readSettingsFromConf();
locked = false;
if (conf.getRight())
{
LOG.info("[CM]: Carpet Mod is locked by the administrator");
disableBooleanFromCategory(RuleCategory.COMMAND);
}
for (String key: conf.getLeft().keySet())
{
if (rules.get(key).set(server.getCommandSource(), conf.getLeft().get(key)) != null)
LOG.info("[CM]: loaded setting "+key+" as "+conf.getLeft().get(key)+" from carpet.conf");
}
locked = conf.getRight();
}
private Pair<Map<String, String>,Boolean> readSettingsFromConf()
{
try
{
BufferedReader reader = new BufferedReader(new FileReader(getFile()));
String line = "";
boolean confLocked = false;
Map<String,String> result = new HashMap<String, String>();
while ((line = reader.readLine()) != null)
{
line = line.replaceAll("\\r|\\n", "");
if ("locked".equalsIgnoreCase(line))
{
confLocked = true;
}
String[] fields = line.split("\\s+",2);
if (fields.length > 1)
{
if (!rules.containsKey(fields[0]))
{
LOG.error("[CM]: Setting " + fields[0] + " is not a valid - ignoring...");
continue;
}
ParsedRule rule = rules.get(fields[0]);
if (!(rule.options.contains(fields[1])) && rule.isStrict)
{
LOG.error("[CM]: The value of " + fields[1] + " for " + fields[0] + " is not valid - ignoring...");
continue;
}
result.put(fields[0],fields[1]);
}
}
reader.close();
return Pair.of(result, confLocked);
}
catch(FileNotFoundException e)
{
return Pair.of(new HashMap<>(), false);
}
catch (IOException e)
{
e.printStackTrace();
return Pair.of(new HashMap<>(), false);
}
}
// stores different defaults in the file
public boolean setDefaultRule(ServerCommandSource source, String settingName, String stringValue)
{
if (locked) return false;
if (rules.containsKey(settingName))
{
Pair<Map<String, String>,Boolean> conf = readSettingsFromConf();
conf.getLeft().put(settingName, stringValue);
writeSettingsToConf(conf.getLeft()); // this may feels weird, but if conf
// is locked, it will never reach this point.
rules.get(settingName).set(source,stringValue);
return true;
}
return false;
}
// removes overrides of the default values in the file
public boolean removeDefaultRule(ServerCommandSource source, String settingName)
{
if (locked) return false;
if (rules.containsKey(settingName))
{
Pair<Map<String, String>,Boolean> conf = readSettingsFromConf();
conf.getLeft().remove(settingName);
writeSettingsToConf(conf.getLeft());
rules.get(settingName).resetToDefault(source);
return true;
}
return false;
}
public Collection<ParsedRule<?>> getRulesMatching(String search) {
String lcSearch = search.toLowerCase(Locale.ROOT);
return rules.values().stream().filter(rule ->
{
if (rule.name.toLowerCase(Locale.ROOT).contains(lcSearch)) return true;
for (String c : rule.categories) if (c.toLowerCase(Locale.ROOT).equals(search)) return true;
return false;
}).collect(ImmutableList.toImmutableList());
}
public int printAllRulesToLog()
{
PrintStream ps = System.out;
ps.println("# Carpet Settings");
for (Map.Entry<String, ParsedRule<?>> e : new TreeMap<>(rules).entrySet())
{
ParsedRule<?> rule = e.getValue();
ps.println("## " + rule.name);
ps.println(rule.description+" ");
for (String extra : rule.extraInfo)
ps.println(extra + " ");
ps.println("* Type: `" + rule.type.getSimpleName() + "` ");
ps.println("* Default value: `" + rule.defaultAsString + "` ");
String optionString = rule.options.stream().map(s -> "`" + s + "`").collect(Collectors.joining(", "));
ps.println((rule.isStrict?"* Required":"* Suggested")+" options: " + optionString + " ");
ps.println("* Categories: " + rule.categories.stream().map(s -> "`" + s.toUpperCase(Locale.ROOT) + "`").collect(Collectors.joining(", ")) + " ");
boolean preamble = false;
for (Validator<?> validator : rule.validators)
{
if(validator.description() != null)
{
if (!preamble)
{
ps.println("* Additional notes: ");
preamble = true;
}
ps.println(" * "+validator.description()+" ");
}
}
ps.println(" ");
}
return 1;
}
}
@@ -0,0 +1,89 @@
package carpet.settings;
import carpet.CarpetServer;
import carpet.utils.Messenger;
import net.minecraft.server.command.ServerCommandSource;
import java.util.Locale;
public abstract class Validator<T>
{
/**
* Validate the new value of a rule
* @return true if valid, false if new rule invalid.
*/
public abstract T validate(ServerCommandSource source, ParsedRule<T> currentRule, T newValue, String string);
public String description() {return null;}
public static class POSITIVE_NUMBER<T extends Number> extends Validator<T>
{
@Override
public T validate(ServerCommandSource source, ParsedRule<T> currentRule, T newValue, String string)
{
return newValue.doubleValue() > 0 ? newValue : null;
}
@Override
public String description() { return "Must be a positive number"; }
}
public static class _COMMAND<T> extends Validator<T>
{
@Override
public T validate(ServerCommandSource source, ParsedRule<T> currentRule, T newValue, String string)
{
if (CarpetServer.settingsManager != null)
CarpetServer.settingsManager.notifyPlayersCommandsChanged();
return newValue;
}
@Override
public String description() { return "It has an accompanying command";}
}
public static class WIP<T> extends Validator<T>
{
@Override
public T validate(ServerCommandSource source, ParsedRule<T> currentRule, T newValue, String string)
{
if (source != null)
try
{
Messenger.m(source, "r Work in progress - limited or no functionality available for "+currentRule.name);
}
catch (NullPointerException ignored) { }
return newValue;
}
@Override
public String description() { return "Its not yet fully implemented - we are working on it";}
}
public static class _STRICT<T> extends Validator<T>
{
@Override
public T validate(ServerCommandSource source, ParsedRule<T> currentRule, T newValue, String string)
{
if (!currentRule.options.contains(string.toLowerCase(Locale.ROOT)))
{
if (source != null)
try
{
Messenger.m(source, "r Valid options: " + currentRule.options.toString());
}
catch (NullPointerException ignored)
{
}
return null;
}
return newValue;
}
}
public static class NONNEGATIVE_NUMBER <T extends Number> extends Validator<T>
{
@Override
public T validate(ServerCommandSource source, ParsedRule<T> currentRule, T newValue, String string)
{
return newValue.doubleValue() >= 0 ? newValue : null;
}
@Override
public String description() { return "Must be a positive number";}
}
}
@@ -1,6 +1,6 @@
package carpet.utils;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import net.minecraft.entity.Entity;
import net.minecraft.server.MinecraftServer;
import net.minecraft.block.entity.BlockEntity;
@@ -1,7 +1,6 @@
package carpet.utils;
import carpet.CarpetSettings;
import carpet.mixins.WeightedPickerEntryMixin;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2LongMap;
+10 -10
View File
@@ -1,6 +1,6 @@
package carpet.utils;
import carpet.CarpetSettings;
import carpet.settings.CarpetSettings;
import carpet.helpers.HopperCounter;
import net.minecraft.block.Material;
import net.minecraft.block.MaterialColor;
@@ -30,23 +30,23 @@ public class WoolTool
public static void carpetPlacedAction(DyeColor color, PlayerEntity placer, BlockPos pos, World worldIn)
{
if (!CarpetSettings.getBool("carpets"))
if (!CarpetSettings.carpets)
{
return;
}
switch (color)
{
case PINK:
if (CarpetSettings.getBool("commandSpawn"))
if (CarpetSettings.commandSpawn)
Messenger.send(placer, SpawnReporter.report(pos, worldIn));
break;
case BLACK:
if (CarpetSettings.getBool("commandSpawn"))
if (CarpetSettings.commandSpawn)
Messenger.send(placer, SpawnReporter.show_mobcaps(pos, worldIn));
break;
case BROWN:
if (CarpetSettings.getBool("commandDistance"))
if (CarpetSettings.commandDistance)
{
ServerCommandSource source = placer.getCommandSource();
if (!DistanceCalculator.hasStartingPoint(source) || placer.isSneaking()) {
@@ -58,16 +58,16 @@ public class WoolTool
}
break;
case GRAY:
if (CarpetSettings.getBool("commandInfo"))
if (CarpetSettings.commandInfo)
Messenger.send(placer, BlockInfo.blockInfo(pos.down(), worldIn));
break;
case YELLOW:
if (CarpetSettings.getBool("commandInfo"))
Messenger.m(placer, "r use data get entity command");
if (CarpetSettings.commandInfo)
Messenger.m(placer, "r This used to show entity info around the player. Use data get entity command, sorry");
//EntityInfo.issue_entity_info(placer);
break;
case GREEN:
if (CarpetSettings.getBool("hopperCounters"))
if (CarpetSettings.hopperCounters)
{
DyeColor under = getWoolColorAtPosition(worldIn, pos.down());
if (under == null) return;
@@ -77,7 +77,7 @@ public class WoolTool
}
break;
case RED:
if (CarpetSettings.getBool("hopperCounters"))
if (CarpetSettings.hopperCounters)
{
DyeColor under = getWoolColorAtPosition(worldIn, pos.down());
if (under == null) return;