1.21.6 dev
Co-authored-by: Bjarne Koll <git@lynxplay.dev> Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com> Co-authored-by: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Co-authored-by: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Co-authored-by: Noah van der Aa <ndvdaa@gmail.com> Co-authored-by: Owen1212055 <23108066+Owen1212055@users.noreply.github.com> Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com>
This commit is contained in:
committed by
Nassim Jahnke
parent
39203a65e0
commit
a24f9b204c
@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/level/GameRules.java
|
||||
+++ b/net/minecraft/world/level/GameRules.java
|
||||
@@ -34,6 +_,14 @@
|
||||
@@ -35,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();
|
||||
public static final Map<GameRules.Key<?>, GameRules.Type<?>> GAME_RULE_TYPES = Maps.newTreeMap(Comparator.comparing(entry -> entry.id));
|
||||
@@ -86,10 +_,10 @@
|
||||
@@ -87,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));
|
||||
}
|
||||
})
|
||||
@@ -113,8 +_,8 @@
|
||||
@@ -114,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));
|
||||
}
|
||||
})
|
||||
@@ -138,8 +_,8 @@
|
||||
@@ -139,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));
|
||||
}
|
||||
})
|
||||
@@ -210,11 +_,11 @@
|
||||
@@ -211,11 +_,11 @@
|
||||
public static final GameRules.Key<GameRules.IntegerValue> RULE_MINECART_MAX_SPEED = register(
|
||||
"minecartMaxSpeed",
|
||||
GameRules.Category.MISC,
|
||||
@ -65,7 +65,16 @@
|
||||
serverLevel.setDefaultSpawnPos(serverLevel.getSharedSpawnPos(), serverLevel.getSharedSpawnAngle());
|
||||
})
|
||||
);
|
||||
@@ -223,6 +_,7 @@
|
||||
@@ -223,7 +_,7 @@
|
||||
"tntExplodes", GameRules.Category.MISC, GameRules.BooleanValue.create(true)
|
||||
);
|
||||
public static final GameRules.Key<GameRules.BooleanValue> RULE_LOCATOR_BAR = register(
|
||||
- "locatorBar", GameRules.Category.PLAYER, GameRules.BooleanValue.create(true, (server, value) -> server.getAllLevels().forEach(level -> {
|
||||
+ "locatorBar", GameRules.Category.PLAYER, GameRules.BooleanValue.create(true, (server, value) -> java.util.Optional.of(server).ifPresent(level -> { // Paper - per world game rules
|
||||
ServerWaypointManager waypointManager = level.getWaypointManager();
|
||||
if (value.get()) {
|
||||
level.players().forEach(waypointManager::updatePlayer);
|
||||
@@ -234,6 +_,7 @@
|
||||
);
|
||||
private final Map<GameRules.Key<?>, GameRules.Value<?>> rules;
|
||||
private final FeatureFlagSet enabledFeatures;
|
||||
@ -73,7 +82,7 @@
|
||||
|
||||
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 @@
|
||||
@@ -281,10 +_,21 @@
|
||||
private GameRules(Map<GameRules.Key<?>, GameRules.Value<?>> rules, FeatureFlagSet enabledFeatures) {
|
||||
this.rules = rules;
|
||||
this.enabledFeatures = enabledFeatures;
|
||||
@ -96,7 +105,7 @@
|
||||
if (value == null) {
|
||||
throw new IllegalArgumentException("Tried to access invalid game rule");
|
||||
} else {
|
||||
@@ -314,13 +_,13 @@
|
||||
@@ -325,13 +_,13 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,16 +123,25 @@
|
||||
}
|
||||
|
||||
public boolean getBoolean(GameRules.Key<GameRules.BooleanValue> key) {
|
||||
@@ -334,7 +_,7 @@
|
||||
public static class BooleanValue extends GameRules.Value<GameRules.BooleanValue> {
|
||||
@@ -346,7 +_,7 @@
|
||||
private boolean value;
|
||||
|
||||
private static GameRules.Type<GameRules.BooleanValue> create(
|
||||
- boolean defaultValue, BiConsumer<MinecraftServer, GameRules.BooleanValue> changeListener, FeatureFlagSet requiredFeatures
|
||||
+ boolean defaultValue, BiConsumer<ServerLevel, GameRules.BooleanValue> changeListener, FeatureFlagSet requiredFeatures // Paper - per world gamerules
|
||||
) {
|
||||
return new GameRules.Type<>(
|
||||
BoolArgumentType::bool,
|
||||
@@ -358,7 +_,7 @@
|
||||
);
|
||||
}
|
||||
|
||||
- static GameRules.Type<GameRules.BooleanValue> create(boolean defaultValue, BiConsumer<MinecraftServer, GameRules.BooleanValue> changeListener) {
|
||||
+ static GameRules.Type<GameRules.BooleanValue> create(boolean defaultValue, BiConsumer<ServerLevel, GameRules.BooleanValue> changeListener) { // CraftBukkit - per-world
|
||||
+ static GameRules.Type<GameRules.BooleanValue> create(boolean defaultValue, BiConsumer<ServerLevel, GameRules.BooleanValue> changeListener) { // Paper - per world gamerules
|
||||
return new GameRules.Type<>(
|
||||
BoolArgumentType::bool,
|
||||
type -> new GameRules.BooleanValue(type, defaultValue),
|
||||
@@ -355,17 +_,21 @@
|
||||
@@ -379,17 +_,21 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -149,7 +167,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -394,9 +_,9 @@
|
||||
@@ -418,9 +_,9 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -161,7 +179,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -434,7 +_,7 @@
|
||||
@@ -458,7 +_,7 @@
|
||||
public static class IntegerValue extends GameRules.Value<GameRules.IntegerValue> {
|
||||
private int value;
|
||||
|
||||
@ -170,7 +188,7 @@
|
||||
return new GameRules.Type<>(
|
||||
IntegerArgumentType::integer,
|
||||
type -> new GameRules.IntegerValue(type, defaultValue),
|
||||
@@ -446,7 +_,7 @@
|
||||
@@ -470,7 +_,7 @@
|
||||
}
|
||||
|
||||
static GameRules.Type<GameRules.IntegerValue> create(
|
||||
@ -179,7 +197,7 @@
|
||||
) {
|
||||
return new GameRules.Type<>(
|
||||
() -> IntegerArgumentType.integer(min, max),
|
||||
@@ -468,17 +_,21 @@
|
||||
@@ -492,17 +_,21 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -205,7 +223,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -529,13 +_,17 @@
|
||||
@@ -553,13 +_,17 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -225,7 +243,7 @@
|
||||
final String id;
|
||||
private final GameRules.Category category;
|
||||
|
||||
@@ -575,7 +_,7 @@
|
||||
@@ -599,7 +_,7 @@
|
||||
public static class Type<T extends GameRules.Value<T>> {
|
||||
final Supplier<ArgumentType<?>> argument;
|
||||
private final Function<GameRules.Type<T>, T> constructor;
|
||||
@ -234,7 +252,7 @@
|
||||
private final GameRules.VisitorCaller<T> visitorCaller;
|
||||
final Class<T> valueClass;
|
||||
final FeatureFlagSet requiredFeatures;
|
||||
@@ -583,7 +_,7 @@
|
||||
@@ -607,7 +_,7 @@
|
||||
Type(
|
||||
Supplier<ArgumentType<?>> argument,
|
||||
Function<GameRules.Type<T>, T> constructor,
|
||||
@ -243,7 +261,7 @@
|
||||
GameRules.VisitorCaller<T> visitorCaller,
|
||||
Class<T> valueClass,
|
||||
FeatureFlagSet requiredFeatures
|
||||
@@ -611,6 +_,12 @@
|
||||
@@ -635,6 +_,12 @@
|
||||
public FeatureFlagSet requiredFeatures() {
|
||||
return this.requiredFeatures;
|
||||
}
|
||||
@ -256,7 +274,7 @@
|
||||
}
|
||||
|
||||
public abstract static class Value<T extends GameRules.Value<T>> {
|
||||
@@ -620,16 +_,16 @@
|
||||
@@ -644,16 +_,16 @@
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@ -280,7 +298,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -648,7 +_,7 @@
|
||||
@@ -672,7 +_,7 @@
|
||||
|
||||
protected abstract T copy();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user