settings ported to the annotation based system
This commit is contained in:
1 parent
79495eccd0
commit
734dc95dab
84 files changed
+292
-1231
No files matched your search
@@ -10,7 +10,6 @@ import carpet.commands.DistanceCommand;
|
||||
import carpet.commands.DrawCommand;
|
||||
import carpet.commands.InfoCommand;
|
||||
import carpet.commands.LogCommand;
|
||||
import carpet.commands.ParcetCommand;
|
||||
import carpet.commands.PerimeterInfoCommand;
|
||||
import carpet.commands.PlayerCommand;
|
||||
import carpet.commands.ScriptCommand;
|
||||
@@ -19,7 +18,7 @@ import carpet.commands.TickCommand;
|
||||
import carpet.helpers.TickSpeed;
|
||||
import carpet.logging.LoggerRegistry;
|
||||
import carpet.script.CarpetScriptServer;
|
||||
import carpet.settings.Settings;
|
||||
import carpet.settings.CarpetSettings;
|
||||
import carpet.settings.SettingsManager;
|
||||
import carpet.utils.HUDController;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
@@ -33,7 +32,7 @@ public class CarpetServer // static for now - easier to handle all around the co
|
||||
public static CarpetScriptServer scriptServer;
|
||||
public static SettingsManager settingsManager;
|
||||
static {
|
||||
SettingsManager.parseSettingsClass(Settings.class);
|
||||
SettingsManager.parseSettingsClass(CarpetSettings.class);
|
||||
//...
|
||||
}
|
||||
public static void init(MinecraftServer server) //aka constructor of this static singleton class
|
||||
@@ -42,11 +41,7 @@ public class CarpetServer // static for now - easier to handle all around the co
|
||||
}
|
||||
public static void onServerLoaded(MinecraftServer server)
|
||||
{
|
||||
//new
|
||||
settingsManager = new SettingsManager(server);
|
||||
|
||||
//old
|
||||
CarpetSettings.apply_settings_from_conf(server);
|
||||
scriptServer = new CarpetScriptServer();
|
||||
}
|
||||
// Separate from onServerLoaded, because a server can be loaded multiple times in singleplayer
|
||||
@@ -65,7 +60,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);
|
||||
@@ -77,7 +71,7 @@ public class CarpetServer // static for now - easier to handle all around the co
|
||||
PerimeterInfoCommand.register(dispatcher);
|
||||
DrawCommand.register(dispatcher);
|
||||
ScriptCommand.register(dispatcher);
|
||||
ParcetCommand.register(dispatcher);
|
||||
CarpetCommand.register(dispatcher);
|
||||
|
||||
//TestCommand.register(dispatcher);
|
||||
}
|
||||
|
||||
@@ -1,731 +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.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.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)
|
||||
{
|
||||
Pair<Map<String, String>,Boolean> conf = read_conf(server);
|
||||
locked = false;
|
||||
if (conf.getRight())
|
||||
{
|
||||
LOG.info("[CM]: Carpet Mod is locked by the administrator");
|
||||
disable_commands_by_default();
|
||||
}
|
||||
for (String key: conf.getLeft().keySet())
|
||||
{
|
||||
set(server.getCommandSource(), key, conf.getLeft().get(key));
|
||||
LOG.info("[CM]: loaded setting "+key+" as "+conf.getLeft().get(key)+" from carpet.conf");
|
||||
}
|
||||
locked = conf.getRight();
|
||||
}
|
||||
private static void disable_commands_by_default()
|
||||
{
|
||||
for (CarpetSettingEntry entry: settings_store.values())
|
||||
{
|
||||
if (entry.getName().startsWith("command"))
|
||||
{
|
||||
entry.defaultFalse();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Pair<Map<String, String>,Boolean> 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 = "";
|
||||
boolean confLocked = false;
|
||||
Map<String,String> result = new HashMap<String, String>();
|
||||
while ((line = b.readLine()) != null)
|
||||
{
|
||||
line = line.replaceAll("\\r|\\n", "");
|
||||
if ("locked".equalsIgnoreCase(line))
|
||||
{
|
||||
confLocked = 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 Pair.of(result, confLocked);
|
||||
}
|
||||
catch(FileNotFoundException e)
|
||||
{
|
||||
return Pair.of(new HashMap<>(), false);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return Pair.of(new HashMap<>(), false);
|
||||
}
|
||||
|
||||
}
|
||||
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))
|
||||
{
|
||||
Pair<Map<String, String>,Boolean> conf = read_conf(source.getMinecraftServer());
|
||||
conf.getLeft().put(setting_name, string_value);
|
||||
write_conf(source.getMinecraftServer(), conf.getLeft()); // this may feels weird, but if conf
|
||||
// is locked, it will never reach this point.
|
||||
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))
|
||||
{
|
||||
Pair<Map<String, String>,Boolean> conf = read_conf(source.getMinecraftServer());
|
||||
conf.getLeft().remove(setting_name);
|
||||
write_conf(source.getMinecraftServer(), conf.getLeft());
|
||||
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).getLeft();
|
||||
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).getLeft();
|
||||
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");
|
||||
|
||||
@@ -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,204 +0,0 @@
|
||||
package carpet.commands;
|
||||
|
||||
import carpet.CarpetServer;
|
||||
import carpet.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.entity.player.PlayerEntity;
|
||||
import net.minecraft.text.BaseText;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static net.minecraft.server.command.CommandManager.argument;
|
||||
import static net.minecraft.server.command.CommandManager.literal;
|
||||
import static net.minecraft.server.command.CommandSource.suggestMatching;
|
||||
|
||||
public class ParcetCommand
|
||||
{
|
||||
public static void register(CommandDispatcher<ServerCommandSource> dispatcher)
|
||||
{
|
||||
LiteralArgumentBuilder<ServerCommandSource> literalargumentbuilder = literal("parcet").requires((player) ->
|
||||
player.hasPermissionLevel(2) && !CarpetServer.settingsManager.locked);
|
||||
|
||||
literalargumentbuilder.executes((context)->listAllSettings(context.getSource())).
|
||||
then(literal("list").
|
||||
executes( (c) -> listSettings(c.getSource(),
|
||||
"All CarpetMod Settings",
|
||||
SettingsManager.getRules())).
|
||||
then(literal("defaults").
|
||||
executes( (c)-> listSettings(c.getSource(),
|
||||
"Current CarpetMod Startup Settings from carpet.conf",
|
||||
CarpetServer.settingsManager.findStartupOverrides()))).
|
||||
then(argument("tag",StringArgumentType.word()).
|
||||
suggests( (c, b)->suggestMatching(SettingsManager.getCategories(), b)).
|
||||
executes( (c) -> listSettings(c.getSource(),
|
||||
String.format("CarpetMod Settings matching \"%s\"", StringArgumentType.getString(c, "tag")),
|
||||
CarpetServer.settingsManager.getRulesMatching(StringArgumentType.getString(c, "tag"))))));
|
||||
|
||||
for (ParsedRule<?> rule: SettingsManager.getRules())
|
||||
{
|
||||
literalargumentbuilder.then(literal(rule.name).executes( (context) ->
|
||||
displayRuleMenu(context.getSource(),rule)));
|
||||
literalargumentbuilder.then(literal("removeDefault").
|
||||
requires(s -> !CarpetServer.settingsManager.locked).
|
||||
then(literal(rule.name).executes((context) ->
|
||||
removeDefault(context.getSource(), rule))));
|
||||
literalargumentbuilder.then(literal(rule.name).
|
||||
requires(s -> !CarpetServer.settingsManager.locked).
|
||||
then(argument("value", StringArgumentType.word()).
|
||||
suggests((c, b)-> suggestMatching(rule.options,b)).
|
||||
executes((context) ->
|
||||
setRule(context.getSource(), rule, StringArgumentType.getString(context, "value")))));
|
||||
literalargumentbuilder.then(literal("setDefault").
|
||||
requires(s -> !CarpetServer.settingsManager.locked).
|
||||
then(literal(rule.name).
|
||||
then(argument("value", StringArgumentType.word()).
|
||||
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, ParsedRule<?> rule)
|
||||
{
|
||||
PlayerEntity player;
|
||||
try
|
||||
{
|
||||
player = source.getPlayer();
|
||||
}
|
||||
catch (CommandSyntaxException e)
|
||||
{
|
||||
Messenger.m(source, "w "+rule.name +" is set to: ","wb "+rule.getAsString());
|
||||
return 1;
|
||||
}
|
||||
|
||||
Messenger.m(player, "");
|
||||
Messenger.m(player, "wb "+rule.name,"!/carpet "+rule.name,"^g refresh");
|
||||
Messenger.m(player, "w "+rule.description);
|
||||
|
||||
rule.extraInfo.forEach(s -> Messenger.m(player, "g "+s));
|
||||
|
||||
List<BaseText> tags = new ArrayList<>();
|
||||
tags.add(Messenger.c("w Tags: "));
|
||||
for (String t: SettingsManager.getCategories())
|
||||
{
|
||||
tags.add(Messenger.c("c ["+t+"]", "^g list all "+t+" settings","!/carpet list "+t));
|
||||
tags.add(Messenger.c("w , "));
|
||||
}
|
||||
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.getAsString(),rule.isDefault()?"default":"modified"));
|
||||
List<BaseText> options = new ArrayList<>();
|
||||
options.add(Messenger.c("w Options: ", "y [ "));
|
||||
for (String o: rule.options)
|
||||
{
|
||||
options.add(makeSetRuleButton(rule, o, false));
|
||||
options.add(Messenger.c("w "));
|
||||
}
|
||||
options.remove(options.size()-1);
|
||||
options.add(Messenger.c("y ]"));
|
||||
Messenger.m(player, options.toArray(new Object[0]));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
private static int setRule(ServerCommandSource source, ParsedRule<?> rule, String 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.name+" "+rule.getAsString());
|
||||
return 1;
|
||||
}
|
||||
private static int setDefault(ServerCommandSource source, ParsedRule<?> rule, String defaultValue)
|
||||
{
|
||||
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, ParsedRule<?> rule)
|
||||
{
|
||||
CarpetServer.settingsManager.removeDefaultRule(source, rule.name);
|
||||
Messenger.m(source ,"gi rule "+ rule.name+" defaults to Vanilla");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
private static BaseText displayInteractiveSetting(ParsedRule<?> rule)
|
||||
{
|
||||
List<Object> args = new ArrayList<>();
|
||||
args.add("w - "+rule.name+" ");
|
||||
args.add("!/carpet "+rule.name);
|
||||
args.add("^y "+rule.description);
|
||||
for (String option: rule.options)
|
||||
{
|
||||
args.add(makeSetRuleButton(rule, option, true));
|
||||
args.add("w ");
|
||||
}
|
||||
args.remove(args.size()-1);
|
||||
return Messenger.c(args.toArray(new Object[0]));
|
||||
}
|
||||
|
||||
private static BaseText makeSetRuleButton(ParsedRule<?> rule, String option, boolean brackets) {
|
||||
String color = "";
|
||||
if (option.equals(rule.defaultAsString) && !brackets) color += "u";
|
||||
color += option.equals(rule.getAsString()) ? "bl" : "y";
|
||||
String baseText = color + (brackets ? " [" : " ") + option + (brackets ? "]" : "");
|
||||
if (CarpetServer.settingsManager.locked) {
|
||||
return Messenger.c(baseText, "^g Settings are locked");
|
||||
}
|
||||
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));
|
||||
settings_list.forEach(e -> Messenger.m(player,displayInteractiveSetting(e)));
|
||||
|
||||
}
|
||||
catch (CommandSyntaxException e)
|
||||
{
|
||||
Messenger.m(source, "w s:"+title);
|
||||
settings_list.forEach(r -> Messenger.m(source, "w - "+ r.toString()));
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
private static int listAllSettings(ServerCommandSource source)
|
||||
{
|
||||
listSettings(source, "Current CarpetMod Settings", CarpetServer.settingsManager.getNonDefault());
|
||||
|
||||
Messenger.m(source, "Carpet Mod version: "+ CarpetSettings.carpetVersion);
|
||||
try
|
||||
{
|
||||
PlayerEntity player = source.getPlayer();
|
||||
List<Object> tags = new ArrayList<>();
|
||||
tags.add("w Browse Categories:\n");
|
||||
for (String t : SettingsManager.getCategories())
|
||||
{
|
||||
tags.add("c [" + t+"]");
|
||||
tags.add("^g list all " + t + " settings");
|
||||
tags.add("!/carpet list " + t);
|
||||
tags.add("w ");
|
||||
}
|
||||
tags.remove(tags.size() - 1);
|
||||
Messenger.m(player, tags.toArray(new Object[0]));
|
||||
}
|
||||
catch (CommandSyntaxException e)
|
||||
{
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -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").
|
||||
|
||||
@@ -23,7 +23,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,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,7 +41,7 @@ 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)));
|
||||
|
||||
@@ -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;
|
||||
@@ -16,6 +16,6 @@ public abstract class TntBlockMixin
|
||||
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,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;
|
||||
|
||||
+14
-7
@@ -6,6 +6,8 @@ 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.COMMANDS;
|
||||
@@ -15,8 +17,13 @@ import static carpet.settings.RuleCategory.FEATURE;
|
||||
import static carpet.settings.RuleCategory.OPTIMIZATIONS;
|
||||
import static carpet.settings.RuleCategory.SURVIVAL;
|
||||
|
||||
public class Settings
|
||||
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.",
|
||||
@@ -225,7 +232,7 @@ public class Settings
|
||||
@Rule(desc = "fill/clone/setblock and structure blocks cause block updates", category = CREATIVE)
|
||||
public static boolean fillUpdates = true;
|
||||
|
||||
private class PushLimitLimits extends Validator<Integer> {
|
||||
private static class PushLimitLimits extends Validator<Integer> {
|
||||
@Override Integer validate(ServerCommandSource source, ParsedRule<Integer> currentRule, Integer newValue, String string) {
|
||||
return (newValue>0 && newValue < 1024) ? newValue : null;
|
||||
}
|
||||
@@ -246,7 +253,7 @@ public class Settings
|
||||
)
|
||||
public static int railPowerLimit = 9;
|
||||
|
||||
private class FillLimitLimits extends Validator<Integer> {
|
||||
private static class FillLimitLimits extends Validator<Integer> {
|
||||
@Override Integer validate(ServerCommandSource source, ParsedRule<Integer> currentRule, Integer newValue, String string) {
|
||||
return (newValue>0 && newValue < 20000000) ? newValue : null;
|
||||
}
|
||||
@@ -270,7 +277,7 @@ public class Settings
|
||||
@Rule(desc = "One player is required on the server to cause night to pass", category = SURVIVAL)
|
||||
public static boolean onePlayerSleeping = false;
|
||||
|
||||
private class SetMotd extends Validator<String> {
|
||||
private static class SetMotd extends Validator<String> {
|
||||
@Override String validate(ServerCommandSource source, ParsedRule<String> currentRule, String newValue, String string) {
|
||||
customMOTD = newValue; // accelerate a smidge
|
||||
((MinecraftServer_motdInterface) CarpetServer.minecraft_server).checkMOTD();
|
||||
@@ -289,7 +296,7 @@ public class Settings
|
||||
@Rule(desc = "Cactus in dispensers rotates blocks.", extra = "Rotates block anti-clockwise if possible", category = FEATURE)
|
||||
public static boolean rotatorBlock = false;
|
||||
|
||||
private class ViewDistanceValidator extends Validator<Integer>
|
||||
private static class ViewDistanceValidator extends Validator<Integer>
|
||||
{
|
||||
@Override Integer validate(ServerCommandSource source, ParsedRule<Integer> currentRule, Integer newValue, String string)
|
||||
{
|
||||
@@ -323,7 +330,7 @@ public class Settings
|
||||
)
|
||||
public static int viewDistance = 0;
|
||||
|
||||
private class DisableSpawnChunksValidator extends Validator<Boolean> {
|
||||
private static class DisableSpawnChunksValidator extends Validator<Boolean> {
|
||||
@Override 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?");
|
||||
@@ -337,7 +344,7 @@ public class Settings
|
||||
)
|
||||
public static boolean disableSpawnChunks = false;
|
||||
|
||||
private class KelpLimit extends Validator<Integer> {
|
||||
private static class KelpLimit extends Validator<Integer> {
|
||||
@Override Integer validate(ServerCommandSource source, ParsedRule<Integer> currentRule, Integer newValue, String string) {
|
||||
return (newValue>=0 && newValue <=25)?newValue:null;
|
||||
}
|
||||
@@ -71,8 +71,9 @@ public final class ParsedRule<T> implements Comparable<ParsedRule> {
|
||||
}
|
||||
|
||||
|
||||
public ParsedRule<T> set(ServerCommandSource source, String value) {
|
||||
if (CarpetServer.settingsManager.locked)
|
||||
public ParsedRule<T> set(ServerCommandSource source, String value)
|
||||
{
|
||||
if (CarpetServer.settingsManager != null && CarpetServer.settingsManager.locked)
|
||||
return null;
|
||||
if (type == String.class)
|
||||
{
|
||||
@@ -98,8 +99,10 @@ public final class ParsedRule<T> implements Comparable<ParsedRule> {
|
||||
}
|
||||
}
|
||||
|
||||
ParsedRule<T> set(ServerCommandSource source, T value, String stringValue) {
|
||||
try {
|
||||
ParsedRule<T> set(ServerCommandSource source, T value, String stringValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
for (Validator<T> validator : this.validators)
|
||||
{
|
||||
value = validator.validate(source, this, value, stringValue);
|
||||
@@ -120,55 +123,68 @@ public final class ParsedRule<T> implements Comparable<ParsedRule> {
|
||||
return this;
|
||||
}
|
||||
|
||||
public T get() {
|
||||
try {
|
||||
public T get()
|
||||
{
|
||||
try
|
||||
{
|
||||
return (T) this.field.get(null);
|
||||
} catch (IllegalAccessException e) {
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public String getAsString() {
|
||||
public String getAsString()
|
||||
{
|
||||
return convertToString(get());
|
||||
}
|
||||
|
||||
public boolean getBoolValue() {
|
||||
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() {
|
||||
public boolean isDefault()
|
||||
{
|
||||
return defaultValue.equals(get());
|
||||
}
|
||||
|
||||
public void resetToDefault(ServerCommandSource source) {
|
||||
public void resetToDefault(ServerCommandSource source)
|
||||
{
|
||||
set(source, defaultValue, defaultAsString);
|
||||
}
|
||||
|
||||
|
||||
private static String convertToString(Object value) {
|
||||
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) {
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
return obj.getClass() == ParsedRule.class && ((ParsedRule) obj).name.equals(this.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
public int hashCode()
|
||||
{
|
||||
return this.name.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(ParsedRule o) {
|
||||
public int compareTo(ParsedRule o)
|
||||
{
|
||||
return this.name.compareTo(o.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
public String toString()
|
||||
{
|
||||
return this.name + ": " + getAsString();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package carpet.settings;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
@@ -35,7 +34,6 @@ public class SettingsManager {
|
||||
Rule rule = f.getAnnotation(Rule.class);
|
||||
if (rule == null) continue;
|
||||
ParsedRule parsed = new ParsedRule(f, rule);
|
||||
CarpetSettings.LOG.error("REGISTERED RULE: "+parsed.name);
|
||||
rules.put(parsed.name, parsed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user