some patches

This commit is contained in:
Spottedleaf 2021-06-11 21:38:04 -07:00 committed by MiniDigger | Martin
parent 2dc0a31f5c
commit 2920f9b9e5
14 changed files with 197 additions and 211 deletions

View File

@ -8,6 +8,11 @@ bad behavior.
This also stops fire from spreading to illegal locations.
This shouldn't need to be included in post 1.14 versions, as blocks no longer tick without at least 1 radius
chunk loaded.
diff --git a/src/main/java/net/minecraft/world/level/block/FireBlock.java b/src/main/java/net/minecraft/world/level/block/FireBlock.java
index 700078c2fd536cc22351eadf51503efb9acd9df9..85170008de6e77cfb8e4f55ae440a8428d868af4 100644
--- a/src/main/java/net/minecraft/world/level/block/FireBlock.java

View File

@ -19,44 +19,44 @@ index 439dcc6effdc91830d2b7ede9063982998b37120..504efea7b6f50a0d17f4f353781953df
+ }
}
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java
index 53f284b720d97ba8ce8fac90bc26e7930dcec6b2..d70e7079ea2c84edbc2a8501f115194e2a4ef2e4 100644
index 8885220e4813b34627b42523834bbec995d8950d..4c9660176e783999301565790b8cf6f47b0d02a2 100644
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java
@@ -112,7 +112,7 @@ public class ClientboundSetPlayerTeamPacket implements Packet<ClientGamePacketLi
@@ -193,7 +193,7 @@ public class ClientboundSetPlayerTeamPacket implements Packet<ClientGamePacketLi
buf.writeComponent(this.displayName);
buf.writeByte(this.options);
buf.writeUtf(this.nametagVisibility);
- buf.writeUtf(this.collisionRule);
+ buf.writeUtf(!com.destroystokyo.paper.PaperConfig.enablePlayerCollisions ? "never" : this.collisionRule); // Paper
buf.writeEnum((Enum) this.color);
buf.writeEnum(this.color);
buf.writeComponent(this.playerPrefix);
buf.writeComponent(this.playerSuffix);
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index f7763a773bce4d8d947c8c859fe84d8a601034c5..d639ead95c36985fa0f5a9c51898c4237e373f0e 100644
index 591f7452005cbfb567b611b3ba71c16596f9edfa..f1868ef9111f25a1d4232587c0c5145c7cd50ef4 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -150,6 +150,7 @@ import net.minecraft.world.level.storage.loot.LootTables;
@@ -163,6 +163,7 @@ import net.minecraft.world.level.storage.loot.LootTables;
import net.minecraft.world.level.storage.loot.PredicateManager;
import net.minecraft.world.phys.Vec2;
import net.minecraft.world.phys.Vec3;
+import net.minecraft.world.scores.PlayerTeam;
import net.minecraft.world.scores.Scoreboard;
import net.minecraft.world.scores.ScoreboardSaveData;
+import net.minecraft.world.scores.PlayerTeam; // Paper
import org.apache.commons.lang3.Validate;
@@ -549,6 +550,20 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -602,6 +603,20 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
this.server.getPluginManager().callEvent(new org.bukkit.event.world.WorldLoadEvent(worldserver.getWorld()));
}
+ // Paper start - Handle collideRule team for player collision toggle
+ final Scoreboard scoreboard = this.getScoreboard();
+ final java.util.Collection<String> toRemove = scoreboard.getTeams().stream().filter(team -> team.getName().startsWith("collideRule_")).map(PlayerTeam::getName).collect(java.util.stream.Collectors.toList());
+ final ServerScoreboard scoreboard = this.getScoreboard();
+ final java.util.Collection<String> toRemove = scoreboard.getPlayerTeams().stream().filter(team -> team.getName().startsWith("collideRule_")).map(PlayerTeam::getName).collect(java.util.stream.Collectors.toList());
+ for (String teamName : toRemove) {
+ scoreboard.removeTeam(scoreboard.getTeam(teamName)); // Clean up after ourselves
+ scoreboard.removePlayerTeam(scoreboard.getPlayersTeam(teamName)); // Clean up after ourselves
+ }
+
+ if (!com.destroystokyo.paper.PaperConfig.enablePlayerCollisions) {
+ this.getPlayerList().collideRuleTeamName = org.apache.commons.lang3.StringUtils.left("collideRule_" + java.util.concurrent.ThreadLocalRandom.current().nextInt(), 16);
+ PlayerTeam collideTeam = scoreboard.createTeam(this.getPlayerList().collideRuleTeamName);
+ PlayerTeam collideTeam = scoreboard.addPlayerTeam(this.getPlayerList().collideRuleTeamName);
+ collideTeam.setSeeFriendlyInvisibles(false); // Because we want to mimic them not being on a team at all
+ }
+ // Paper end
@ -65,18 +65,18 @@ index f7763a773bce4d8d947c8c859fe84d8a601034c5..d639ead95c36985fa0f5a9c51898c423
this.server.getPluginManager().callEvent(new ServerLoadEvent(ServerLoadEvent.LoadType.STARTUP));
this.connection.acceptConnections();
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index aa440a6341a6d30aba8fd5f6bcd122bd5d8760cd..59fb19cfebe4f488fd02f02db31029d44b65e408 100644
index ce72102870075fffd8be6f32230ceae269ea4f9c..b9c4428bc9653e81ed046bda94e248218c1fa9c9 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -79,6 +79,7 @@ import net.minecraft.world.level.storage.PlayerDataStorage;
@@ -85,6 +85,7 @@ import net.minecraft.world.level.storage.PlayerDataStorage;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.scores.Objective;
import net.minecraft.world.scores.PlayerTeam;
+import net.minecraft.world.scores.Scoreboard;
+import net.minecraft.world.scores.Scoreboard; // Paper
import net.minecraft.world.scores.Team;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -141,6 +142,7 @@ public abstract class PlayerList {
@@ -146,6 +147,7 @@ public abstract class PlayerList {
// CraftBukkit start
private CraftServer cserver;
private final Map<String,ServerPlayer> playersByName = new java.util.HashMap<>();
@ -84,28 +84,28 @@ index aa440a6341a6d30aba8fd5f6bcd122bd5d8760cd..59fb19cfebe4f488fd02f02db31029d4
public PlayerList(MinecraftServer server, RegistryAccess.RegistryHolder registryManager, PlayerDataStorage saveHandler, int maxPlayers) {
this.cserver = server.server = new CraftServer((DedicatedServer) server, this);
@@ -372,6 +374,13 @@ public abstract class PlayerList {
}
@@ -377,6 +379,13 @@ public abstract class PlayerList {
player.initMenu();
player.initInventoryMenu();
// CraftBukkit - Moved from above, added world
+ // Paper start - Add to collideRule team if needed
+ final Scoreboard scoreboard = this.getServer().getLevel(Level.OVERWORLD).getScoreboard();
+ final PlayerTeam collideRuleTeam = scoreboard.getTeam(collideRuleTeamName);
+ final PlayerTeam collideRuleTeam = scoreboard.getPlayersTeam(this.collideRuleTeamName);
+ if (this.collideRuleTeamName != null && collideRuleTeam != null && player.getTeam() == null) {
+ scoreboard.addPlayerToTeam(player.getScoreboardName(), collideRuleTeam);
+ }
+ // Paper end
// CraftBukkit - Moved from above, added world
PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ([{}]{}, {}, {})", player.getName().getString(), s1, player.getId(), worldserver1.worldDataServer.getLevelName(), player.getX(), player.getY(), player.getZ());
PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ([{}]{}, {}, {})", player.getName().getString(), s1, player.getId(), worldserver1.serverLevelData.getLevelName(), player.getX(), player.getY(), player.getZ());
}
@@ -492,6 +501,16 @@ public abstract class PlayerList {
@@ -496,6 +505,16 @@ public abstract class PlayerList {
entityplayer.doTick(); // SPIGOT-924
// CraftBukkit end
+ // Paper start - Remove from collideRule team if needed
+ if (this.collideRuleTeamName != null) {
+ final Scoreboard scoreBoard = this.server.getLevel(Level.OVERWORLD).getScoreboard();
+ final PlayerTeam team = scoreBoard.getTeam(this.collideRuleTeamName);
+ final PlayerTeam team = scoreBoard.getPlayersTeam(this.collideRuleTeamName);
+ if (entityplayer.getTeam() == team && team != null) {
+ scoreBoard.removePlayerFromTeam(entityplayer.getScoreboardName(), team);
+ }
@ -115,15 +115,15 @@ index aa440a6341a6d30aba8fd5f6bcd122bd5d8760cd..59fb19cfebe4f488fd02f02db31029d4
this.save(entityplayer);
if (entityplayer.isPassenger()) {
Entity entity = entityplayer.getRootVehicle();
@@ -1140,6 +1159,13 @@ public abstract class PlayerList {
@@ -1118,6 +1137,13 @@ public abstract class PlayerList {
}
// CraftBukkit end
+ // Paper start - Remove collideRule team if it exists
+ if (this.collideRuleTeamName != null) {
+ final Scoreboard scoreboard = this.getServer().getLevel(Level.OVERWORLD).getScoreboard();
+ final PlayerTeam team = scoreboard.getTeam(this.collideRuleTeamName);
+ if (team != null) scoreboard.removeTeam(team);
+ final PlayerTeam team = scoreboard.getPlayersTeam(this.collideRuleTeamName);
+ if (team != null) scoreboard.removePlayerTeam(team);
+ }
+ // Paper end
}

View File

@ -6,18 +6,9 @@ Subject: [PATCH] Add handshake event to allow plugins to handle client
diff --git a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
index 55b6412bb978abb6f8eaff83a7dd40fbc1ed8b9a..e56ab94ce65e81bb0383a1626a1790c43bd6920e 100644
index 94d0111f35cb025024da10e2fb4ea0cb802d4ff2..c4ba069f5124ec151e05813beddf293fddc3b804 100644
--- a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java
@@ -29,7 +29,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL
// CraftBukkit end
private static final Component IGNORE_STATUS_REASON = new TextComponent("Ignoring status request");
private final MinecraftServer server;
- private final Connection connection;
+ private final Connection connection; final Connection getNetworkManager() { return this.connection; } // Paper - OBFHELPER
public ServerHandshakePacketListenerImpl(MinecraftServer server, Connection connection) {
this.server = server;
@@ -88,8 +88,35 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL
this.connection.disconnect(chatmessage);
} else {
@ -27,22 +18,22 @@ index 55b6412bb978abb6f8eaff83a7dd40fbc1ed8b9a..e56ab94ce65e81bb0383a1626a1790c4
+ boolean handledByEvent = false;
+ // Try and handle the handshake through the event
+ if (com.destroystokyo.paper.event.player.PlayerHandshakeEvent.getHandlerList().getRegisteredListeners().length != 0) { // Hello? Can you hear me?
+ java.net.SocketAddress socketAddress = this.getNetworkManager().address;
+ java.net.SocketAddress socketAddress = this.connection.address;
+ String hostnameOfRemote = socketAddress instanceof java.net.InetSocketAddress ? ((java.net.InetSocketAddress) socketAddress).getHostString() : InetAddress.getLoopbackAddress().getHostAddress();
+ com.destroystokyo.paper.event.player.PlayerHandshakeEvent event = new com.destroystokyo.paper.event.player.PlayerHandshakeEvent(packet.hostName, hostnameOfRemote, !proxyLogicEnabled);
+ if (event.callEvent()) {
+ // If we've failed somehow, let the client know so and go no further.
+ if (event.isFailed()) {
+ chatmessage = new TranslatableComponent(event.getFailMessage());
+ this.getNetworkManager().send(new ClientboundLoginDisconnectPacket(chatmessage));
+ this.getNetworkManager().disconnect(chatmessage);
+ TranslatableComponent chatmessage = new TranslatableComponent(event.getFailMessage());
+ this.connection.send(new ClientboundLoginDisconnectPacket(chatmessage));
+ this.connection.disconnect(chatmessage);
+ return;
+ }
+
+ if (event.getServerHostname() != null) packet.hostName = event.getServerHostname();
+ if (event.getSocketAddressHostname() != null) this.getNetworkManager().address = new java.net.InetSocketAddress(event.getSocketAddressHostname(), socketAddress instanceof java.net.InetSocketAddress ? ((java.net.InetSocketAddress) socketAddress).getPort() : 0);
+ this.getNetworkManager().spoofedUUID = event.getUniqueId();
+ this.getNetworkManager().spoofedProfile = gson.fromJson(event.getPropertiesJson(), com.mojang.authlib.properties.Property[].class);
+ if (event.getSocketAddressHostname() != null) this.connection.address = new java.net.InetSocketAddress(event.getSocketAddressHostname(), socketAddress instanceof java.net.InetSocketAddress ? ((java.net.InetSocketAddress) socketAddress).getPort() : 0);
+ this.connection.spoofedUUID = event.getUniqueId();
+ this.connection.spoofedProfile = gson.fromJson(event.getPropertiesJson(), com.mojang.authlib.properties.Property[].class);
+ handledByEvent = true; // Hooray, we did it!
+ }
+ }
@ -53,5 +44,5 @@ index 55b6412bb978abb6f8eaff83a7dd40fbc1ed8b9a..e56ab94ce65e81bb0383a1626a1790c4
- if (org.spigotmc.SpigotConfig.bungee) {
+ //if (org.spigotmc.SpigotConfig.bungee) { // Paper - comment out, we check above!
String[] split = packet.hostName.split("\00");
if ( ( split.length == 3 || split.length == 4 ) && ( HOST_PATTERN.matcher( split[1] ).matches() ) ) {
if ( ( split.length == 3 || split.length == 4 ) && ( ServerHandshakePacketListenerImpl.HOST_PATTERN.matcher( split[1] ).matches() ) ) {
packet.hostName = split[0];

View File

@ -6,54 +6,52 @@ Subject: [PATCH] Configurable RCON IP address
For servers with multiple IP's, ability to bind to a specific interface.
diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java
index d10f2e5a13a9e86c32ef5dd8c6732ad8b51ed6a0..545096d9ba403396b6aaa7bb6d912f2de08a967e 100644
index 3dc2187035fff8c0c338b35c07ca2164ed753b04..e3409d5f4ddcaa4edecfa4b3c638a12624b09f1b 100644
--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java
+++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServerProperties.java
@@ -64,6 +64,8 @@ public class DedicatedServerProperties extends Settings<DedicatedServerPropertie
public final Settings<DedicatedServerProperties>.MutableValue<Boolean> whiteList;
public final WorldGenSettings worldGenSettings;
@@ -67,6 +67,8 @@ public class DedicatedServerProperties extends Settings<DedicatedServerPropertie
@Nullable
public WorldGenSettings worldGenSettings;
+ public final String rconIp; // Paper - Add rcon ip
+
// CraftBukkit start
public DedicatedServerProperties(Properties properties, RegistryAccess iregistrycustom, OptionSet optionset) {
public DedicatedServerProperties(Properties properties, OptionSet optionset) {
super(properties, optionset);
@@ -115,6 +117,10 @@ public class DedicatedServerProperties extends Settings<DedicatedServerPropertie
this.textFilteringConfig = this.get("text-filtering-config", "");
this.playerIdleTimeout = this.getMutable("player-idle-timeout", 0);
this.whiteList = this.getMutable("white-list", false);
+ // Paper start - Configurable rcon ip
+ final String rconIp = this.getSettingIfExists("rcon.ip");
+ final String rconIp = this.getStringRaw("rcon.ip");
+ this.rconIp = rconIp == null ? this.serverIp : rconIp;
+ // Paper end
this.worldGenSettings = WorldGenSettings.create(iregistrycustom, properties);
}
// CraftBukkit start
diff --git a/src/main/java/net/minecraft/server/dedicated/Settings.java b/src/main/java/net/minecraft/server/dedicated/Settings.java
index f87bc37a0dc3e7e0ecbdca587683eae6e1b3187d..9d0e8bd74944b402385fe7f44717c32ebbef99f8 100644
index f914b12473a607622eb9c816c980ef1adbc9e863..2f30f6332f7c81a28f2930a8b7a7379fd31f8c02 100644
--- a/src/main/java/net/minecraft/server/dedicated/Settings.java
+++ b/src/main/java/net/minecraft/server/dedicated/Settings.java
@@ -129,8 +129,8 @@ public abstract class Settings<T extends Settings<T>> {
};
@@ -124,7 +124,7 @@ public abstract class Settings<T extends Settings<T>> {
}
- @Nullable
@Nullable
- private String getStringRaw(String key) {
+ @Nullable String getSettingIfExists(final String path) { return this.getStringRaw(path); } // Paper - OBFHELPER
+ @Nullable private String getStringRaw(String key) { // Paper - OBFHELPER
return (String) getOverride(key, this.properties.getProperty(key)); // CraftBukkit
+ public String getStringRaw(String key) { // Paper - private -> public
return (String) this.getOverride(key, this.properties.getProperty(key)); // CraftBukkit
}
diff --git a/src/main/java/net/minecraft/server/rcon/thread/RconThread.java b/src/main/java/net/minecraft/server/rcon/thread/RconThread.java
index f2a94e9d9b57ece16873972bc5292f7cf3928848..ef9f659ae5f53a8effa807ecb955ef47d53aacd2 100644
index 5e642ab9947f054c1741e13170a36f8fe300cdbe..a93e0eb67a78abb2eabd549cd5240095a24e5545 100644
--- a/src/main/java/net/minecraft/server/rcon/thread/RconThread.java
+++ b/src/main/java/net/minecraft/server/rcon/thread/RconThread.java
@@ -62,7 +62,7 @@ public class RconThread extends GenericThread {
@@ -60,7 +60,7 @@ public class RconThread extends GenericThread {
@Nullable
public static RconThread create(ServerInterface server) {
DedicatedServerProperties dedicatedserverproperties = server.getProperties();
- String s = server.getServerIp();
+ String s = dedicatedserverproperties.rconIp; // Paper - Configurable rcon ip
if (s.isEmpty()) {
s = "0.0.0.0";
DedicatedServerProperties dedicatedServerProperties = server.getProperties();
- String string = server.getServerIp();
+ String string = dedicatedServerProperties.rconIp; // Paper - Configurable rcon ip
if (string.isEmpty()) {
string = "0.0.0.0";
}

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Implement PlayerLocaleChangeEvent
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index ffad931c72e52855a3f139354f5e85c460e2a80b..bd3d9182dfb2c0ae1d8c3b9aa360f94c33252592 100644
index b68a58abf254289a806636ca28521be39c13a82f..0a59e3b405d5074ab326e6ddb265a714e4038e86 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -1692,7 +1692,7 @@ public class ServerPlayer extends Player implements ContainerListener {
@@ -1712,7 +1712,7 @@ public class ServerPlayer extends Player {
return s;
}
@ -17,30 +17,30 @@ index ffad931c72e52855a3f139354f5e85c460e2a80b..bd3d9182dfb2c0ae1d8c3b9aa360f94c
public java.util.Locale adventure$locale = java.util.Locale.US; // Paper
public void updateOptions(ServerboundClientInformationPacket packet) {
// CraftBukkit start
@@ -1700,9 +1700,10 @@ public class ServerPlayer extends Player implements ContainerListener {
PlayerChangedMainHandEvent event = new PlayerChangedMainHandEvent(getBukkitEntity(), getMainArm() == HumanoidArm.LEFT ? MainHand.LEFT : MainHand.RIGHT);
@@ -1720,9 +1720,10 @@ public class ServerPlayer extends Player {
PlayerChangedMainHandEvent event = new PlayerChangedMainHandEvent(this.getBukkitEntity(), getMainArm() == HumanoidArm.LEFT ? MainHand.LEFT : MainHand.RIGHT);
this.server.server.getPluginManager().callEvent(event);
}
- if (!this.locale.equals(packet.language)) {
+ if (this.locale == null || !this.locale.equals(packet.language)) { // Paper - check for null
PlayerLocaleChangeEvent event = new PlayerLocaleChangeEvent(getBukkitEntity(), packet.language);
PlayerLocaleChangeEvent event = new PlayerLocaleChangeEvent(this.getBukkitEntity(), packet.language);
this.server.server.getPluginManager().callEvent(event);
+ new com.destroystokyo.paper.event.player.PlayerLocaleChangeEvent(this.getBukkitEntity(), this.locale, packet.language).callEvent(); // Paper
}
this.locale = packet.language;
// Paper start
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index b264cbe5f91da9e31c5fd00ee285735a19aaad35..fc19b4cacd223b928fbdf922b828beaed630bf2e 100644
index b93a02dce55952321874528016ea48e5a35bd772..b9320aa8e3fc3216753f7d4e3d4b2bda9ec403ef 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -1875,8 +1875,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@@ -1878,8 +1878,10 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@Override
public String getLocale() {
- return getHandle().locale;
- return this.getHandle().locale;
-
+ // Paper start - Locale change event
+ final String locale = getHandle().locale;
+ final String locale = this.getHandle().locale;
+ return locale != null ? locale : "en_us";
+ // Paper end
}

View File

@ -6,10 +6,10 @@ Subject: [PATCH] EntityRegainHealthEvent isFastRegen API
Don't even get me started
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index a326e5b4ac055f2f8a95c6eaccd8d0a97762da1f..1131d86080b3100437aa18a00c6277fcea4b7ea8 100644
index 83eaa3c6581c1a3f588278124fed4c811e81e53c..041a61e037e7f6fddd94567f2954be600c737811 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -1127,10 +1127,16 @@ public abstract class LivingEntity extends Entity {
@@ -1230,10 +1230,16 @@ public abstract class LivingEntity extends Entity {
}
public void heal(float f, EntityRegainHealthEvent.RegainReason regainReason) {
@ -28,7 +28,7 @@ index a326e5b4ac055f2f8a95c6eaccd8d0a97762da1f..1131d86080b3100437aa18a00c6277fc
if (this.valid) {
this.level.getCraftServer().getPluginManager().callEvent(event);
diff --git a/src/main/java/net/minecraft/world/food/FoodData.java b/src/main/java/net/minecraft/world/food/FoodData.java
index 269392592f5271b1bb8c37661fbe685e76e32b74..d18b7d2c22312fc6ec3977ce38a1f04e0b5c8ad4 100644
index 4957366784799fb204ecec735655c3440734ca57..97133bd4af30d0ba92cbf884b83140f3399f92e2 100644
--- a/src/main/java/net/minecraft/world/food/FoodData.java
+++ b/src/main/java/net/minecraft/world/food/FoodData.java
@@ -84,7 +84,7 @@ public class FoodData {

View File

@ -24,23 +24,23 @@ index 1942f5224aaebb18adb591d6f70a419cfc1a7bdd..5baccb8d50c135ab20c38ffd0690f585
+ }
}
diff --git a/src/main/java/net/minecraft/world/level/block/FrostedIceBlock.java b/src/main/java/net/minecraft/world/level/block/FrostedIceBlock.java
index 0727cc36c99cb5ca5019c71f4540de76b78c7a80..ae2f5acd008d5d7163b56cb4a2d29354299959ca 100644
index 958d84d0046814a4a5715d9c8be09318f483aa22..54eb7ba0265bb155dd1c753661242fa9d299ff80 100644
--- a/src/main/java/net/minecraft/world/level/block/FrostedIceBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/FrostedIceBlock.java
@@ -30,6 +30,7 @@ public class FrostedIceBlock extends IceBlock {
@@ -32,6 +32,7 @@ public class FrostedIceBlock extends IceBlock {
@Override
public void tick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
+ if (!world.paperConfig.frostedIceEnabled) return; // Paper - add ability to disable frosted ice
if ((random.nextInt(3) == 0 || this.fewerNeigboursThan(world, pos, 4)) && world.getMaxLocalRawBrightness(pos) > 11 - (Integer) state.getValue(FrostedIceBlock.AGE) - state.getLightBlock((BlockGetter) world, pos) && this.slightlyMelt(state, (Level) world, pos)) {
BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos();
Direction[] aenumdirection = Direction.values();
@@ -42,12 +43,12 @@ public class FrostedIceBlock extends IceBlock {
BlockState iblockdata1 = world.getBlockState(blockposition_mutableblockposition);
if ((random.nextInt(3) == 0 || this.fewerNeigboursThan(world, pos, 4)) && world.getMaxLocalRawBrightness(pos) > 11 - state.getValue(AGE) - state.getLightBlock(world, pos) && this.slightlyMelt(state, world, pos)) {
BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos();
if (iblockdata1.is((Block) this) && !this.slightlyMelt(iblockdata1, (Level) world, blockposition_mutableblockposition)) {
- world.getBlockTicks().scheduleTick(blockposition_mutableblockposition, this, Mth.nextInt(random, 20, 40));
+ world.getBlockTicks().scheduleTick(blockposition_mutableblockposition, this, Mth.nextInt(random, world.paperConfig.frostedIceDelayMin, world.paperConfig.frostedIceDelayMax)); // Paper - use configurable min/max delay
@@ -39,12 +40,12 @@ public class FrostedIceBlock extends IceBlock {
mutableBlockPos.setWithOffset(pos, direction);
BlockState blockState = world.getBlockState(mutableBlockPos);
if (blockState.is(this) && !this.slightlyMelt(blockState, world, mutableBlockPos)) {
- world.getBlockTicks().scheduleTick(mutableBlockPos, this, Mth.nextInt(random, 20, 40));
+ world.getBlockTicks().scheduleTick(mutableBlockPos, this, Mth.nextInt(random, world.paperConfig.frostedIceDelayMin, world.paperConfig.frostedIceDelayMax)); // Paper - use configurable min/max delay
}
}

View File

@ -6,26 +6,26 @@ Subject: [PATCH] remove null possibility for getServer singleton
to stop IDE complaining about potential NPE
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index d639ead95c36985fa0f5a9c51898c4237e373f0e..4e468cb7ccf683b8fc9e04a48cfc25779775e25f 100644
index f1868ef9111f25a1d4232587c0c5145c7cd50ef4..ef231e11b90b24418a77b62f5fe766c9ac10c09b 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -178,6 +178,7 @@ import org.spigotmc.SlackActivityAccountant; // Spigot
@@ -189,6 +189,7 @@ import org.spigotmc.SlackActivityAccountant; // Spigot
public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTask> implements SnooperPopulator, CommandSource, AutoCloseable {
+ private static MinecraftServer SERVER; // Paper
public static final Logger LOGGER = LogManager.getLogger();
public static final File USERID_CACHE_FILE = new File("usercache.json");
public static final LevelSettings DEMO_SETTINGS = new LevelSettings("Demo World", GameType.SURVIVAL, false, Difficulty.NORMAL, false, new GameRules(), DataPackConfig.DEFAULT);
@@ -284,6 +285,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
private static final float AVERAGE_TICK_TIME_SMOOTHING = 0.8F;
private static final int TICK_STATS_SPAN = 100;
@@ -318,6 +319,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
public MinecraftServer(OptionSet options, DataPackConfig datapackconfiguration, Thread thread, RegistryAccess.RegistryHolder iregistrycustom_dimension, LevelStorageSource.LevelStorageAccess convertable_conversionsession, WorldData savedata, PackRepository resourcepackrepository, Proxy proxy, DataFixer datafixer, ServerResources datapackresources, MinecraftSessionService minecraftsessionservice, GameProfileRepository gameprofilerepository, GameProfileCache usercache, ChunkProgressListenerFactory worldloadlistenerfactory) {
public MinecraftServer(OptionSet options, DataPackConfig datapackconfiguration, Thread thread, RegistryAccess.RegistryHolder iregistrycustom_dimension, LevelStorageSource.LevelStorageAccess convertable_conversionsession, WorldData savedata, PackRepository resourcepackrepository, Proxy proxy, DataFixer datafixer, ServerResources datapackresources, @Nullable MinecraftSessionService minecraftsessionservice, @Nullable GameProfileRepository gameprofilerepository, @Nullable GameProfileCache usercache, ChunkProgressListenerFactory worldloadlistenerfactory) {
super("Server");
+ SERVER = this; // Paper - better singleton
this.continousProfiler = new ContinuousProfiler(Util.timeSource, this::getTickCount);
this.profiler = InactiveProfiler.INSTANCE;
this.status = new ServerStatus();
@@ -2161,7 +2163,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
this.metricsRecorder = InactiveMetricsRecorder.INSTANCE;
this.profiler = this.metricsRecorder.getProfiler();
this.onMetricsRecordingStopped = (methodprofilerresults) -> {
@@ -2232,7 +2234,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@Deprecated
public static MinecraftServer getServer() {

View File

@ -13,10 +13,10 @@ custom renderers are in use, defaulting to the much simpler Vanilla system.
Additionally, numerous issues to player position tracking on maps has been fixed.
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index bb99d9fe5e274318d8480a6de2c45b0a57351f77..0a613f94d1c796267636e1a343aeee65a49ffed5 100644
index b1c9a21574d6adba5d01caea0abac16a0e214a8f..8323ddb363f49d266dd95f11241a30a9a27250aa 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -1164,6 +1164,7 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl
@@ -1920,6 +1920,7 @@ public class ServerLevel extends net.minecraft.world.level.Level implements Worl
{
if ( iter.next().player == entity )
{
@ -25,81 +25,73 @@ index bb99d9fe5e274318d8480a6de2c45b0a57351f77..0a613f94d1c796267636e1a343aeee65
}
}
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
index 3b451e75a7f49ea6b543aee9f0a51c0be3c4dfba..c11d5aa115d10e3c12863cf9d42c60194d63b690 100644
index a76f1cab566a3c8c8d1b0204b5c2c8492312c9f0..e8768625e55f849cd31784cb46e67293bcd93abf 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
@@ -85,6 +85,7 @@ import net.minecraft.world.item.ElytraItem;
@@ -88,6 +88,7 @@ import net.minecraft.world.item.ElytraItem;
import net.minecraft.world.item.ItemCooldowns;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
+import net.minecraft.world.item.MapItem;
+import net.minecraft.world.item.MapItem; // Paper
import net.minecraft.world.item.ProjectileWeaponItem;
import net.minecraft.world.item.SwordItem;
import net.minecraft.world.item.crafting.Recipe;
@@ -104,6 +105,7 @@ import net.minecraft.world.level.block.entity.SignBlockEntity;
@@ -107,6 +108,7 @@ import net.minecraft.world.level.block.entity.SignBlockEntity;
import net.minecraft.world.level.block.entity.StructureBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.pattern.BlockInWorld;
+import net.minecraft.world.level.saveddata.maps.MapItemSavedData;
+import net.minecraft.world.level.saveddata.maps.MapItemSavedData; // Paper
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.scores.PlayerTeam;
@@ -686,6 +688,12 @@ public abstract class Player extends LivingEntity {
@@ -736,6 +738,12 @@ public abstract class Player extends LivingEntity {
return null;
}
// CraftBukkit end
+ // Paper start - remove player from map on drop
+ if (stack.getItem() == Items.FILLED_MAP) {
+ MapItemSavedData worldmap = MapItem.getOrCreateSavedData(stack, this.level);
+ worldmap.updateSeenPlayers(this, stack);
+ MapItemSavedData worldmap = MapItem.getSavedData(stack, this.level);
+ worldmap.tickCarriedBy(this, stack);
+ }
+ // Paper end
return entityitem;
}
diff --git a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
index d44505b3ee2a35422568e9bce0d868191e348fc0..7582c7cd4235d212a0cf66a4c59ce0cedaa360ad 100644
index 6859fafa42527d45366018f737c19e6c3777d152..15c6f9d1c43fbedac70526a84a010be83b4cae86 100644
--- a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
+++ b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
@@ -57,6 +57,7 @@ public class MapItemSavedData extends SavedData {
private final Map<String, MapBanner> bannerMarkers = Maps.newHashMap();
@@ -64,6 +64,7 @@ public class MapItemSavedData extends SavedData {
public final Map<String, MapDecoration> decorations = Maps.newLinkedHashMap();
private final Map<String, MapFrame> frameMarkers = Maps.newHashMap();
private int trackedDecorationCount;
+ private org.bukkit.craftbukkit.map.RenderData vanillaRender = new org.bukkit.craftbukkit.map.RenderData(); // Paper
// CraftBukkit start
public final CraftMapView mapView;
@@ -69,6 +70,7 @@ public class MapItemSavedData extends SavedData {
@@ -84,6 +85,7 @@ public class MapItemSavedData extends SavedData {
// CraftBukkit start
mapView = new CraftMapView(this);
server = (CraftServer) org.bukkit.Bukkit.getServer();
+ vanillaRender.buffer = colors; // Paper
this.mapView = new CraftMapView(this);
this.server = (CraftServer) org.bukkit.Bukkit.getServer();
+ this.vanillaRender.buffer = colors; // Paper
// CraftBukkit end
}
@@ -136,6 +138,7 @@ public class MapItemSavedData extends SavedData {
this.bannerMarkers.put(mapiconbanner.getId(), mapiconbanner);
this.addDecoration(mapiconbanner.getDecoration(), (LevelAccessor) null, mapiconbanner.getId(), (double) mapiconbanner.getPos().getX(), (double) mapiconbanner.getPos().getZ(), 180.0D, mapiconbanner.getName());
@@ -139,6 +141,7 @@ public class MapItemSavedData extends SavedData {
if (abyte.length == 16384) {
worldmap.colors = abyte;
}
+ this.vanillaRender.buffer = colors; // Paper
+ worldmap.vanillaRender.buffer = abyte; // Paper
ListTag nbttaglist1 = tag.getList("frames", 10);
ListTag nbttaglist = nbt.getList("banners", 10);
@@ -216,6 +219,7 @@ public class MapItemSavedData extends SavedData {
this.setDirty();
}
+ public void updateSeenPlayers(Player entityhuman, ItemStack itemstack) { this.tickCarriedBy(entityhuman, itemstack); } // Paper - OBFHELPER
public void tickCarriedBy(Player player, ItemStack stack) {
if (!this.carriedByPlayers.containsKey(player)) {
MapItemSavedData.HoldingPlayer worldmap_worldmaphumantracker = new MapItemSavedData.HoldingPlayer(player);
@@ -451,6 +455,21 @@ public class MapItemSavedData extends SavedData {
@@ -549,6 +552,21 @@ public class MapItemSavedData extends SavedData {
public class HoldingPlayer {
+ // Paper start
+ private void addSeenPlayers(java.util.Collection<MapDecoration> icons) {
+ org.bukkit.entity.Player player = (org.bukkit.entity.Player) player.getBukkitEntity();
+ org.bukkit.entity.Player player = (org.bukkit.entity.Player) this.player.getBukkitEntity();
+ MapItemSavedData.this.decorations.forEach((name, mapIcon) -> {
+ // If this cursor is for a player check visibility with vanish system
+ org.bukkit.entity.Player other = org.bukkit.Bukkit.getPlayerExact(name); // Spigot
@ -115,20 +107,26 @@ index d44505b3ee2a35422568e9bce0d868191e348fc0..7582c7cd4235d212a0cf66a4c59ce0ce
public final Player player;
private boolean dirtyData = true;
private int minDirtyX;
@@ -467,9 +486,12 @@ public class MapItemSavedData extends SavedData {
@@ -582,7 +600,9 @@ public class MapItemSavedData extends SavedData {
@Nullable
public Packet<?> nextUpdatePacket(ItemStack stack) {
// CraftBukkit start
Packet<?> nextUpdatePacket(int mapId) {
MapItemSavedData.MapPatch worldmap_b;
- org.bukkit.craftbukkit.map.RenderData render = MapItemSavedData.this.mapView.render((org.bukkit.craftbukkit.entity.CraftPlayer) this.player.getBukkitEntity()); // CraftBukkit
+ if (!this.dirtyData && this.tick % 5 != 0) { this.tick++; return null; } // Paper - this won't end up sending, so don't render it!
+ boolean vanillaMaps = shouldUseVanillaMap(); // Paper
+ org.bukkit.craftbukkit.map.RenderData render = !vanillaMaps ? MapItemSavedData.this.mapView.render((org.bukkit.craftbukkit.entity.CraftPlayer) this.player.getBukkitEntity()) : MapItemSavedData.this.vanillaRender; // CraftBukkit // Paper
if (this.dirtyData) {
this.dirtyData = false;
@@ -598,6 +618,8 @@ public class MapItemSavedData extends SavedData {
// CraftBukkit start
java.util.Collection<MapDecoration> icons = new java.util.ArrayList<MapDecoration>();
+ if (vanillaMaps) addSeenPlayers(icons); // Paper
for ( org.bukkit.map.MapCursor cursor : render.cursors) {
+
for (org.bukkit.map.MapCursor cursor : render.cursors) {
if (cursor.isVisible()) {
icons.add(new MapDecoration(MapDecoration.Type.byIcon(cursor.getRawType()), cursor.getX(), cursor.getY(), cursor.getDirection(), PaperAdventure.asVanilla(cursor.caption()))); // Paper - Adventure
diff --git a/src/main/java/org/bukkit/craftbukkit/map/RenderData.java b/src/main/java/org/bukkit/craftbukkit/map/RenderData.java
index 256a131781721c86dd6cdbc329335964570cbe8c..5768cd512ec166f1e8d1f4a28792015347297c3f 100644
--- a/src/main/java/org/bukkit/craftbukkit/map/RenderData.java

View File

@ -43,13 +43,12 @@ index 5baccb8d50c135ab20c38ffd0690f585514ce5af..eb04fdb172a50ec1f5b7fe78fa0e7655
}
diff --git a/src/main/java/com/destroystokyo/paper/loottable/PaperLootableBlockInventory.java b/src/main/java/com/destroystokyo/paper/loottable/PaperLootableBlockInventory.java
new file mode 100644
index 0000000000000000000000000000000000000000..fda64b8860cb696e209eedcfb200e7193d216732
index 0000000000000000000000000000000000000000..70ca5625ff5d13a8e9cd64953066a7e1547ff223
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/loottable/PaperLootableBlockInventory.java
@@ -0,0 +1,34 @@
@@ -0,0 +1,33 @@
+package com.destroystokyo.paper.loottable;
+
+import LootableInventory;
+import net.minecraft.core.BlockPos;
+import net.minecraft.world.level.Level;
+import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity;
@ -118,14 +117,13 @@ index 0000000000000000000000000000000000000000..292d5ef8a1c428893af729b298eecd32
+}
diff --git a/src/main/java/com/destroystokyo/paper/loottable/PaperLootableInventory.java b/src/main/java/com/destroystokyo/paper/loottable/PaperLootableInventory.java
new file mode 100644
index 0000000000000000000000000000000000000000..b3def19a50081cfa758b6e25707b2fc6fed8d3ca
index 0000000000000000000000000000000000000000..16b3527d7bc782c47e6f6c3ecd7165bd16b0ab0a
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/loottable/PaperLootableInventory.java
@@ -0,0 +1,71 @@
@@ -0,0 +1,70 @@
+package com.destroystokyo.paper.loottable;
+
+import org.bukkit.loot.Lootable;
+import LootableInventory;
+import java.util.UUID;
+import net.minecraft.world.level.Level;
+
@ -195,16 +193,15 @@ index 0000000000000000000000000000000000000000..b3def19a50081cfa758b6e25707b2fc6
+}
diff --git a/src/main/java/com/destroystokyo/paper/loottable/PaperLootableInventoryData.java b/src/main/java/com/destroystokyo/paper/loottable/PaperLootableInventoryData.java
new file mode 100644
index 0000000000000000000000000000000000000000..88542462d34ba24e8590294bd896d7e73932ef9c
index 0000000000000000000000000000000000000000..115a6fad53655f356866032054db36777a791b4e
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/loottable/PaperLootableInventoryData.java
@@ -0,0 +1,180 @@
@@ -0,0 +1,179 @@
+package com.destroystokyo.paper.loottable;
+
+import com.destroystokyo.paper.PaperWorldConfig;
+import org.bukkit.entity.Player;
+import org.bukkit.loot.LootTable;
+
+import javax.annotation.Nullable;
+import net.minecraft.nbt.CompoundTag;
+import net.minecraft.nbt.ListTag;
@ -381,13 +378,12 @@ index 0000000000000000000000000000000000000000..88542462d34ba24e8590294bd896d7e7
+}
diff --git a/src/main/java/com/destroystokyo/paper/loottable/PaperMinecartLootableInventory.java b/src/main/java/com/destroystokyo/paper/loottable/PaperMinecartLootableInventory.java
new file mode 100644
index 0000000000000000000000000000000000000000..d9b31c8a21fdffb33d1f75b1a16606f218145b39
index 0000000000000000000000000000000000000000..6d2e0493729b7b4e109ff103a6ac36c9901568c0
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/loottable/PaperMinecartLootableInventory.java
@@ -0,0 +1,63 @@
@@ -0,0 +1,62 @@
+package com.destroystokyo.paper.loottable;
+
+import LootableInventory;
+import net.minecraft.world.entity.Entity;
+import net.minecraft.world.entity.vehicle.AbstractMinecartContainer;
+import net.minecraft.world.level.Level;
@ -450,13 +446,12 @@ index 0000000000000000000000000000000000000000..d9b31c8a21fdffb33d1f75b1a16606f2
+}
diff --git a/src/main/java/com/destroystokyo/paper/loottable/PaperTileEntityLootableInventory.java b/src/main/java/com/destroystokyo/paper/loottable/PaperTileEntityLootableInventory.java
new file mode 100644
index 0000000000000000000000000000000000000000..6bc899ec4dc03b09cc978bc7a763a9755a3d2dc4
index 0000000000000000000000000000000000000000..3377b86c337d0234bbb9b0349e4034a7cd450a97
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/loottable/PaperTileEntityLootableInventory.java
@@ -0,0 +1,66 @@
@@ -0,0 +1,65 @@
+package com.destroystokyo.paper.loottable;
+
+import LootableInventory;
+import net.minecraft.server.MCUtil;
+import net.minecraft.world.level.Level;
+import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity;
@ -521,10 +516,10 @@ index 0000000000000000000000000000000000000000..6bc899ec4dc03b09cc978bc7a763a975
+ }
+}
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 61048140cf0adca03bfb57193ada0adaee73b1bb..171697e88f5a4d8c0be2a47b67b865bbdc4dfe8c 100644
index eceaeed527f34860e1c55b9f96863f140055faa7..416dd12638540312aa48b530e24ba3ad7ab6079c 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -157,6 +157,7 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s
@@ -168,6 +168,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
};
// Paper end
@ -533,10 +528,10 @@ index 61048140cf0adca03bfb57193ada0adaee73b1bb..171697e88f5a4d8c0be2a47b67b865bb
public CraftEntity getBukkitEntity() {
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
index f4758251e58fbb36526cea5c4825561d62c9665a..5b96b1e7428a43c8c5f4a96ea37d5189f0d84f56 100644
index e347f30d7c5be460788cc815da2f4f8742488713..f57864ce919ef4721cfb5913c636fe8903ce4cc1 100644
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
@@ -45,6 +45,7 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme
@@ -46,6 +46,7 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme
public long lootTableSeed;
// CraftBukkit start
@ -544,36 +539,36 @@ index f4758251e58fbb36526cea5c4825561d62c9665a..5b96b1e7428a43c8c5f4a96ea37d5189
public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
private int maxStack = MAX_STACK;
@@ -202,12 +203,13 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme
@@ -200,12 +201,13 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme
@Override
protected void addAdditionalSaveData(CompoundTag tag) {
super.addAdditionalSaveData(tag);
+ this.lootableData.saveNbt(tag); // Paper
protected void addAdditionalSaveData(CompoundTag nbt) {
super.addAdditionalSaveData(nbt);
+ this.lootableData.saveNbt(nbt); // Paper
if (this.lootTable != null) {
tag.putString("LootTable", this.lootTable.toString());
nbt.putString("LootTable", this.lootTable.toString());
if (this.lootTableSeed != 0L) {
tag.putLong("LootTableSeed", this.lootTableSeed);
nbt.putLong("LootTableSeed", this.lootTableSeed);
}
- } else {
+ } if (true) { // Paper - Always save the items, Table may stick around
ContainerHelper.saveAllItems(tag, this.itemStacks);
ContainerHelper.saveAllItems(nbt, this.itemStacks);
}
@@ -216,11 +218,12 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme
@@ -214,11 +216,12 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme
@Override
protected void readAdditionalSaveData(CompoundTag tag) {
super.readAdditionalSaveData(tag);
+ this.lootableData.loadNbt(tag); // Paper
this.itemStacks = NonNullList.a(this.getContainerSize(), ItemStack.EMPTY);
if (tag.contains("LootTable", 8)) {
this.lootTable = new ResourceLocation(tag.getString("LootTable"));
this.lootTableSeed = tag.getLong("LootTableSeed");
protected void readAdditionalSaveData(CompoundTag nbt) {
super.readAdditionalSaveData(nbt);
+ this.lootableData.loadNbt(nbt); // Paper
this.itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY);
if (nbt.contains("LootTable", 8)) {
this.lootTable = new ResourceLocation(nbt.getString("LootTable"));
this.lootTableSeed = nbt.getLong("LootTableSeed");
- } else {
+ } if (true) { // Paper - always load the items, table may still remain
ContainerHelper.loadAllItems(tag, this.itemStacks);
ContainerHelper.loadAllItems(nbt, this.itemStacks);
}
@@ -251,14 +254,15 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme
@@ -254,14 +257,15 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme
}
public void unpackLootTable(@Nullable Player player) {
@ -592,26 +587,26 @@ index f4758251e58fbb36526cea5c4825561d62c9665a..5b96b1e7428a43c8c5f4a96ea37d5189
if (player != null) {
diff --git a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
index 9d33bc31c8088bfba66be1aecbf20e7ee86e4f83..5ad419941ff1113ef29b9a4593f44d8f35ba8424 100644
index b79d9d26a8e60f9c0ecd69e9c2f9cfd087e21d23..f23fff80d07ac7d06715efe67cb49ebbe704967b 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
@@ -27,6 +27,7 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc
@@ -28,6 +28,7 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc
@Nullable
public ResourceLocation lootTable;
public long lootTableSeed;
+ public final com.destroystokyo.paper.loottable.PaperLootableInventoryData lootableData = new com.destroystokyo.paper.loottable.PaperLootableInventoryData(new com.destroystokyo.paper.loottable.PaperTileEntityLootableInventory(this)); // Paper
protected RandomizableContainerBlockEntity(BlockEntityType<?> type) {
super(type);
protected RandomizableContainerBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
super(type, pos, state);
@@ -42,16 +43,19 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc
}
protected boolean tryLoadLootTable(CompoundTag nbttagcompound) {
+ this.lootableData.loadNbt(nbttagcompound); // Paper
if (nbttagcompound.contains("LootTable", 8)) {
this.lootTable = new ResourceLocation(nbttagcompound.getString("LootTable"));
protected boolean tryLoadLootTable(CompoundTag nbt) {
+ this.lootableData.loadNbt(nbt); // Paper
if (nbt.contains("LootTable", 8)) {
this.lootTable = new ResourceLocation(nbt.getString("LootTable"));
+ try { org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(this.lootTable); } catch (IllegalArgumentException ex) { this.lootTable = null; } // Paper - validate
this.lootTableSeed = nbttagcompound.getLong("LootTableSeed");
this.lootTableSeed = nbt.getLong("LootTableSeed");
- return true;
+ return false; // Paper - always load the items, table may still remain
} else {
@ -619,13 +614,13 @@ index 9d33bc31c8088bfba66be1aecbf20e7ee86e4f83..5ad419941ff1113ef29b9a4593f44d8f
}
}
protected boolean trySaveLootTable(CompoundTag nbttagcompound) {
+ this.lootableData.saveNbt(nbttagcompound); // Paper
protected boolean trySaveLootTable(CompoundTag nbt) {
+ this.lootableData.saveNbt(nbt); // Paper
if (this.lootTable == null) {
return false;
} else {
@@ -60,19 +64,20 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc
nbttagcompound.putLong("LootTableSeed", this.lootTableSeed);
@@ -60,18 +64,19 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc
nbt.putLong("LootTableSeed", this.lootTableSeed);
}
- return true;
@ -636,36 +631,35 @@ index 9d33bc31c8088bfba66be1aecbf20e7ee86e4f83..5ad419941ff1113ef29b9a4593f44d8f
public void unpackLootTable(@Nullable Player player) {
- if (this.lootTable != null && this.level.getServer() != null) {
+ if (this.lootableData.shouldReplenish(player) && this.level.getServer() != null) { // Paper
LootTable loottable = this.level.getServer().getLootTables().get(this.lootTable);
LootTable lootTable = this.level.getServer().getLootTables().get(this.lootTable);
if (player instanceof ServerPlayer) {
CriteriaTriggers.GENERATE_LOOT.trigger((ServerPlayer) player, this.lootTable);
CriteriaTriggers.GENERATE_LOOT.trigger((ServerPlayer)player, this.lootTable);
}
- this.lootTable = null;
+ //this.lootTable = null; // Paper
+ this.lootableData.processRefill(player); // Paper
LootContext.Builder loottableinfo_builder = (new LootContext.Builder((ServerLevel) this.level)).withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf((Vec3i) this.worldPosition)).withOptionalRandomSeed(this.lootTableSeed);
LootContext.Builder builder = (new LootContext.Builder((ServerLevel)this.level)).withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(this.worldPosition)).withOptionalRandomSeed(this.lootTableSeed);
if (player != null) {
builder.withLuck(player.getLuck()).withParameter(LootContextParams.THIS_ENTITY, player);
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java
index 1e2e94b0cd2ede8fb7ae5902dcd0b639bd8dcf52..e89a93082fe07fdb14df8ffef5beca5bd52d7866 100644
index 90f44b49d2728c8a1110270fa8c52104355e45c4..d57b32090cebfc952ac0a71b8aada85f49275241 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java
@@ -64,7 +64,7 @@ public class CraftBlockEntityState<T extends BlockEntity> extends CraftBlockStat
@@ -61,7 +61,7 @@ public class CraftBlockEntityState<T extends BlockEntity> extends CraftBlockStat
}
// gets the wrapped TileEntity
- protected T getTileEntity() {
+ public T getTileEntity() { // Paper - protected -> public
return tileEntity;
return this.tileEntity;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java b/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java
index 20d9a192ff102e04687a8aa3eff1ba36a69b6c03..a821df3e13e2ddc479dc5f55540671f43563cdac 100644
index 5cb17e8289db0ab38fd36318e2957701d6dfb341..f48b830a9ae8160388cb0d0220a44b1ec9f0d214 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftChest.java
@@ -12,8 +12,9 @@ import org.bukkit.craftbukkit.CraftWorld;
@@ -13,8 +13,9 @@ import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.inventory.CraftInventory;
import org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest;
import org.bukkit.inventory.Inventory;
@ -677,7 +671,7 @@ index 20d9a192ff102e04687a8aa3eff1ba36a69b6c03..a821df3e13e2ddc479dc5f55540671f4
public CraftChest(final Block block) {
super(block, ChestBlockEntity.class);
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java b/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java
index 309650aad43d8b6ce4bb13f8c172028f3feab299..5babbcfcacb89e62f00f8184af2ceea227f9ff69 100644
index 28b9a42d43522cde9d0be4d98a8a5f8fdf6c3abd..055ffe404c37e1daab61b821b590f8c7038076eb 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java
@@ -10,7 +10,7 @@ import org.bukkit.craftbukkit.util.CraftNamespacedKey;
@ -690,7 +684,7 @@ index 309650aad43d8b6ce4bb13f8c172028f3feab299..5babbcfcacb89e62f00f8184af2ceea2
public CraftLootable(Block block, Class<T> tileEntityClass) {
super(block, tileEntityClass);
@@ -54,7 +54,7 @@ public abstract class CraftLootable<T extends RandomizableContainerBlockEntity>
setLootTable(getLootTable(), seed);
this.setLootTable(this.getLootTable(), seed);
}
- private void setLootTable(LootTable table, long seed) {
@ -699,7 +693,7 @@ index 309650aad43d8b6ce4bb13f8c172028f3feab299..5babbcfcacb89e62f00f8184af2ceea2
getSnapshot().setLootTable(key, seed);
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartChest.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartChest.java
index f0a30acb0199e396d6863a473db433cbe112d8a5..293b222565d8e0592f9f355a2ee8cdfbc868a08e 100644
index eb21b8457774d5ac765fa9008157cb29d9b72509..abf58bef2042a9efba5a78fd7f97339deceaa780 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartChest.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartChest.java
@@ -8,7 +8,7 @@ import org.bukkit.entity.minecart.StorageMinecart;
@ -712,20 +706,20 @@ index f0a30acb0199e396d6863a473db433cbe112d8a5..293b222565d8e0592f9f355a2ee8cdfb
public CraftMinecartChest(CraftServer server, MinecartChest entity) {
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java
index 12044062cb746bd5c77abacf8acddc67e08e78ce..ce14bc4791bd282d16af0ee91fc431acefa3b909 100644
index 097d8bd479a0800114964725da8bfd19415a2956..4893d8e67025d919a455b44bb41d914a39ab5aa9 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java
@@ -47,7 +47,7 @@ public abstract class CraftMinecartContainer extends CraftMinecart implements Lo
return getHandle().lootTableSeed;
return this.getHandle().lootTableSeed;
}
- private void setLootTable(LootTable table, long seed) {
+ public void setLootTable(LootTable table, long seed) { // Paper
+ @Override public void setLootTable(LootTable table, long seed) { // Paper
ResourceLocation newKey = (table == null) ? null : CraftNamespacedKey.toMinecraft(table.getKey());
getHandle().setLootTable(newKey, seed);
this.getHandle().setLootTable(newKey, seed);
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartHopper.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartHopper.java
index c1af739369715d8c628c466b269fdde99a2f6286..c8c5f60b6b32248696363d9b63bbbe43810743d3 100644
index 34b8f103625f087bb725bed595dd9c30f4a6f70c..ee9648739fb39c5842063d7442df6eb5c9336d7f 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartHopper.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartHopper.java
@@ -7,7 +7,7 @@ import org.bukkit.entity.EntityType;