1.21.5
Co-authored-by: Bjarne Koll <git@lynxplay.dev> Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com> Co-authored-by: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Co-authored-by: MiniDigger | Martin <admin@minidigger.dev> Co-authored-by: Nassim Jahnke <nassim@njahnke.dev> Co-authored-by: Noah van der Aa <ndvdaa@gmail.com> Co-authored-by: Owen1212055 <23108066+Owen1212055@users.noreply.github.com> Co-authored-by: Shane Freeder <theboyetronic@gmail.com> Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com> Co-authored-by: Tamion <70228790+notTamion@users.noreply.github.com> Co-authored-by: Warrior <50800980+Warriorrrr@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/level/GameRules.java
|
||||
+++ b/net/minecraft/world/level/GameRules.java
|
||||
@@ -32,6 +_,14 @@
|
||||
@@ -34,6 +_,14 @@
|
||||
import org.slf4j.Logger;
|
||||
|
||||
public class GameRules {
|
||||
@@ -15,7 +15,7 @@
|
||||
public static final int DEFAULT_RANDOM_TICK_SPEED = 3;
|
||||
static final Logger LOGGER = LogUtils.getLogger();
|
||||
private static final Map<GameRules.Key<?>, GameRules.Type<?>> GAME_RULE_TYPES = Maps.newTreeMap(Comparator.comparing(entry -> entry.id));
|
||||
@@ -81,10 +_,10 @@
|
||||
@@ -86,10 +_,10 @@
|
||||
"sendCommandFeedback", GameRules.Category.CHAT, GameRules.BooleanValue.create(true)
|
||||
);
|
||||
public static final GameRules.Key<GameRules.BooleanValue> RULE_REDUCEDDEBUGINFO = register(
|
||||
@@ -28,7 +28,7 @@
|
||||
serverPlayer.connection.send(new ClientboundEntityEventPacket(serverPlayer, b));
|
||||
}
|
||||
})
|
||||
@@ -108,8 +_,8 @@
|
||||
@@ -113,8 +_,8 @@
|
||||
"doWeatherCycle", GameRules.Category.UPDATES, GameRules.BooleanValue.create(true)
|
||||
);
|
||||
public static final GameRules.Key<GameRules.BooleanValue> RULE_LIMITED_CRAFTING = register(
|
||||
@@ -39,7 +39,7 @@
|
||||
serverPlayer.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.LIMITED_CRAFTING, value.get() ? 1.0F : 0.0F));
|
||||
}
|
||||
})
|
||||
@@ -133,8 +_,8 @@
|
||||
@@ -138,8 +_,8 @@
|
||||
"doInsomnia", GameRules.Category.SPAWNING, GameRules.BooleanValue.create(true)
|
||||
);
|
||||
public static final GameRules.Key<GameRules.BooleanValue> RULE_DO_IMMEDIATE_RESPAWN = register(
|
||||
@@ -50,7 +50,7 @@
|
||||
serverPlayer.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.IMMEDIATE_RESPAWN, value.get() ? 1.0F : 0.0F));
|
||||
}
|
||||
})
|
||||
@@ -205,16 +_,17 @@
|
||||
@@ -210,11 +_,11 @@
|
||||
public static final GameRules.Key<GameRules.IntegerValue> RULE_MINECART_MAX_SPEED = register(
|
||||
"minecartMaxSpeed",
|
||||
GameRules.Category.MISC,
|
||||
@@ -65,13 +65,15 @@
|
||||
serverLevel.setDefaultSpawnPos(serverLevel.getSharedSpawnPos(), serverLevel.getSharedSpawnAngle());
|
||||
})
|
||||
);
|
||||
@@ -223,6 +_,7 @@
|
||||
);
|
||||
private final Map<GameRules.Key<?>, GameRules.Value<?>> rules;
|
||||
private final FeatureFlagSet enabledFeatures;
|
||||
+ private final GameRules.Value<?>[] gameruleArray; // Paper - Perf: Use array for gamerule storage
|
||||
|
||||
private static <T extends GameRules.Value<T>> GameRules.Key<T> register(String name, GameRules.Category category, GameRules.Type<T> type) {
|
||||
GameRules.Key<T> key = new GameRules.Key<>(name, category);
|
||||
@@ -242,10 +_,21 @@
|
||||
public static <T extends GameRules.Value<T>> GameRules.Type<T> getType(GameRules.Key<T> key) {
|
||||
return (GameRules.Type<T>)GAME_RULE_TYPES.get(key);
|
||||
@@ -270,10 +_,21 @@
|
||||
private GameRules(Map<GameRules.Key<?>, GameRules.Value<?>> rules, FeatureFlagSet enabledFeatures) {
|
||||
this.rules = rules;
|
||||
this.enabledFeatures = enabledFeatures;
|
||||
@@ -94,7 +96,7 @@
|
||||
if (value == null) {
|
||||
throw new IllegalArgumentException("Tried to access invalid game rule");
|
||||
} else {
|
||||
@@ -286,13 +_,13 @@
|
||||
@@ -314,13 +_,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +114,7 @@
|
||||
}
|
||||
|
||||
public boolean getBoolean(GameRules.Key<GameRules.BooleanValue> key) {
|
||||
@@ -306,7 +_,7 @@
|
||||
@@ -334,7 +_,7 @@
|
||||
public static class BooleanValue extends GameRules.Value<GameRules.BooleanValue> {
|
||||
private boolean value;
|
||||
|
||||
@@ -121,7 +123,7 @@
|
||||
return new GameRules.Type<>(
|
||||
BoolArgumentType::bool,
|
||||
type -> new GameRules.BooleanValue(type, defaultValue),
|
||||
@@ -326,17 +_,21 @@
|
||||
@@ -355,17 +_,21 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -129,7 +131,7 @@
|
||||
- this.value = BoolArgumentType.getBool(context, paramName);
|
||||
+ // Paper start - Add WorldGameRuleChangeEvent
|
||||
+ protected void updateFromArgument(CommandContext<CommandSourceStack> context, String paramName, GameRules.Key<BooleanValue> gameRuleKey) {
|
||||
+ io.papermc.paper.event.world.WorldGameRuleChangeEvent event = new io.papermc.paper.event.world.WorldGameRuleChangeEvent(context.getSource().getBukkitWorld(), context.getSource().getBukkitSender(), (org.bukkit.GameRule<Boolean>) org.bukkit.GameRule.getByName(gameRuleKey.toString()), String.valueOf(BoolArgumentType.getBool(context, paramName)));
|
||||
+ io.papermc.paper.event.world.WorldGameRuleChangeEvent event = new io.papermc.paper.event.world.WorldGameRuleChangeEvent(context.getSource().getBukkitWorld(), context.getSource().getBukkitSender(), org.bukkit.GameRule.getByName(gameRuleKey.toString()), String.valueOf(BoolArgumentType.getBool(context, paramName)));
|
||||
+ if (!event.callEvent()) return;
|
||||
+ this.value = Boolean.parseBoolean(event.getValue());
|
||||
+ // Paper end - Add WorldGameRuleChangeEvent
|
||||
@@ -147,16 +149,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -345,7 +_,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- protected void deserialize(String value) {
|
||||
+ public void deserialize(String value) { // PAIL - protected->public
|
||||
this.value = Boolean.parseBoolean(value);
|
||||
}
|
||||
|
||||
@@ -365,9 +_,9 @@
|
||||
@@ -394,9 +_,9 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -168,7 +161,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -405,7 +_,7 @@
|
||||
@@ -434,7 +_,7 @@
|
||||
public static class IntegerValue extends GameRules.Value<GameRules.IntegerValue> {
|
||||
private int value;
|
||||
|
||||
@@ -177,7 +170,7 @@
|
||||
return new GameRules.Type<>(
|
||||
IntegerArgumentType::integer,
|
||||
type -> new GameRules.IntegerValue(type, defaultValue),
|
||||
@@ -416,7 +_,7 @@
|
||||
@@ -446,7 +_,7 @@
|
||||
}
|
||||
|
||||
static GameRules.Type<GameRules.IntegerValue> create(
|
||||
@@ -186,7 +179,7 @@
|
||||
) {
|
||||
return new GameRules.Type<>(
|
||||
() -> IntegerArgumentType.integer(min, max),
|
||||
@@ -437,17 +_,21 @@
|
||||
@@ -468,17 +_,21 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -194,7 +187,7 @@
|
||||
- this.value = IntegerArgumentType.getInteger(context, paramName);
|
||||
+ // Paper start - Add WorldGameRuleChangeEvent
|
||||
+ protected void updateFromArgument(CommandContext<CommandSourceStack> context, String paramName, GameRules.Key<IntegerValue> gameRuleKey) {
|
||||
+ io.papermc.paper.event.world.WorldGameRuleChangeEvent event = new io.papermc.paper.event.world.WorldGameRuleChangeEvent(context.getSource().getBukkitWorld(), context.getSource().getBukkitSender(), (org.bukkit.GameRule<Integer>) org.bukkit.GameRule.getByName(gameRuleKey.toString()), String.valueOf(IntegerArgumentType.getInteger(context, paramName)));
|
||||
+ io.papermc.paper.event.world.WorldGameRuleChangeEvent event = new io.papermc.paper.event.world.WorldGameRuleChangeEvent(context.getSource().getBukkitWorld(), context.getSource().getBukkitSender(), org.bukkit.GameRule.getByName(gameRuleKey.toString()), String.valueOf(IntegerArgumentType.getInteger(context, paramName)));
|
||||
+ if (!event.callEvent()) return;
|
||||
+ this.value = Integer.parseInt(event.getValue());
|
||||
+ // Paper end - Add WorldGameRuleChangeEvent
|
||||
@@ -212,16 +205,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -456,7 +_,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- protected void deserialize(String value) {
|
||||
+ public void deserialize(String value) { // PAIL - protected->public
|
||||
this.value = safeParse(value);
|
||||
}
|
||||
|
||||
@@ -498,13 +_,17 @@
|
||||
@@ -529,13 +_,17 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -241,24 +225,25 @@
|
||||
final String id;
|
||||
private final GameRules.Category category;
|
||||
|
||||
@@ -544,14 +_,14 @@
|
||||
@@ -575,7 +_,7 @@
|
||||
public static class Type<T extends GameRules.Value<T>> {
|
||||
final Supplier<ArgumentType<?>> argument;
|
||||
private final Function<GameRules.Type<T>, T> constructor;
|
||||
- final BiConsumer<MinecraftServer, T> callback;
|
||||
+ final BiConsumer<ServerLevel, T> callback; // CraftBukkit - per-world
|
||||
private final GameRules.VisitorCaller<T> visitorCaller;
|
||||
final Class<T> valueClass;
|
||||
final FeatureFlagSet requiredFeatures;
|
||||
|
||||
@@ -583,7 +_,7 @@
|
||||
Type(
|
||||
Supplier<ArgumentType<?>> argument,
|
||||
Function<GameRules.Type<T>, T> constructor,
|
||||
- BiConsumer<MinecraftServer, T> callback,
|
||||
+ BiConsumer<ServerLevel, T> callback, // CraftBukkit - per-world
|
||||
GameRules.VisitorCaller<T> visitorCaller,
|
||||
FeatureFlagSet requiredFeature
|
||||
) {
|
||||
@@ -586,20 +_,20 @@
|
||||
Class<T> valueClass,
|
||||
FeatureFlagSet requiredFeatures
|
||||
@@ -620,16 +_,16 @@
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@@ -282,12 +267,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
- protected abstract void deserialize(String value);
|
||||
+ public abstract void deserialize(String value); // PAIL - private->public
|
||||
|
||||
public abstract String serialize();
|
||||
|
||||
@@ -614,7 +_,7 @@
|
||||
@@ -648,7 +_,7 @@
|
||||
|
||||
protected abstract T copy();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user