From fad3fa9bde1c224903550b603fbc7f88e8e1087a Mon Sep 17 00:00:00 2001 From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> Date: Tue, 5 Dec 2023 14:20:44 -0700 Subject: [PATCH] Update loot table and other patches --- ...-API-Replenishable-Lootables-Feature.patch | 120 ++++++++++-------- ...em-property-for-disabling-watchdoge.patch} | 0 .../0098-Async-GameProfileCache-saving.patch} | 18 +-- ...-Optional-TNT-doesn-t-move-in-water.patch} | 10 +- ...-redstone-torch-rapid-clock-removal.patch} | 14 +- 5 files changed, 90 insertions(+), 72 deletions(-) rename patches/{unapplied => }/server/0096-LootTable-API-Replenishable-Lootables-Feature.patch (90%) rename patches/{unapplied/server/0098-System-property-for-disabling-watchdoge.patch => server/0097-System-property-for-disabling-watchdoge.patch} (100%) rename patches/{unapplied/server/0099-Async-GameProfileCache-saving.patch => server/0098-Async-GameProfileCache-saving.patch} (84%) rename patches/{unapplied/server/0100-Optional-TNT-doesn-t-move-in-water.patch => server/0099-Optional-TNT-doesn-t-move-in-water.patch} (89%) rename patches/{unapplied/server/0101-Faster-redstone-torch-rapid-clock-removal.patch => server/0100-Faster-redstone-torch-rapid-clock-removal.patch} (84%) diff --git a/patches/unapplied/server/0096-LootTable-API-Replenishable-Lootables-Feature.patch b/patches/server/0096-LootTable-API-Replenishable-Lootables-Feature.patch similarity index 90% rename from patches/unapplied/server/0096-LootTable-API-Replenishable-Lootables-Feature.patch rename to patches/server/0096-LootTable-API-Replenishable-Lootables-Feature.patch index 157c320c38..d20ffaea12 100644 --- a/patches/unapplied/server/0096-LootTable-API-Replenishable-Lootables-Feature.patch +++ b/patches/server/0096-LootTable-API-Replenishable-Lootables-Feature.patch @@ -503,11 +503,72 @@ index 0000000000000000000000000000000000000000..9cfa5d36a6991067a3866e0d437749fa + return tileEntityLootable.getLevel(); + } +} +diff --git a/src/main/java/net/minecraft/world/RandomizableContainer.java b/src/main/java/net/minecraft/world/RandomizableContainer.java +index 22eba5982dd258e2f58a7a70fd25900364cc9448..0c80f97e74ee04e7eab24e35c752ded5586bed07 100644 +--- a/src/main/java/net/minecraft/world/RandomizableContainer.java ++++ b/src/main/java/net/minecraft/world/RandomizableContainer.java +@@ -49,17 +49,29 @@ public interface RandomizableContainer extends Container { + + } + ++ // Paper start ++ private static net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity blockEntity(final RandomizableContainer container) { ++ return (net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity) container; ++ } + default boolean tryLoadLootTable(CompoundTag nbt) { ++ final net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity entity = blockEntity(this); ++ entity.lootableData.loadNbt(nbt); + if (nbt.contains("LootTable", 8)) { + this.setLootTable(new ResourceLocation(nbt.getString("LootTable"))); ++ try { org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(entity.lootTable); } catch (IllegalArgumentException ex) { entity.lootTable = null; } // Paper - validate + this.setLootTableSeed(nbt.getLong("LootTableSeed")); +- return true; ++ return false; // Paper - always load the items, table may still remain ++ // Paper end + } else { + return false; + } + } + + default boolean trySaveLootTable(CompoundTag nbt) { ++ // Paper start ++ final net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity entity = blockEntity(this); ++ entity.lootableData.saveNbt(nbt); ++ // Paper end + ResourceLocation resourceLocation = this.getLootTable(); + if (resourceLocation == null) { + return false; +@@ -70,21 +82,22 @@ public interface RandomizableContainer extends Container { + nbt.putLong("LootTableSeed", l); + } + +- return true; ++ return false; // Paper - always save the items, table may still remain + } + } + + default void unpackLootTable(@Nullable Player player) { ++ final net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity entity = blockEntity(this); // Paper + Level level = this.getLevel(); + BlockPos blockPos = this.getBlockPos(); + ResourceLocation resourceLocation = this.getLootTable(); +- if (resourceLocation != null && level != null && level.getServer() != null) { ++ if (entity.lootableData.shouldReplenish(player) && level != null) { // Paper + LootTable lootTable = level.getServer().getLootData().getLootTable(resourceLocation); + if (player instanceof ServerPlayer) { + CriteriaTriggers.GENERATE_LOOT.trigger((ServerPlayer)player, resourceLocation); + } + +- this.setLootTable((ResourceLocation)null); ++ entity.lootableData.processRefill(player); // Paper + LootParams.Builder builder = (new LootParams.Builder((ServerLevel)level)).withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(blockPos)); + if (player != null) { + builder.withLuck(player.getLuck()).withParameter(LootContextParams.THIS_ENTITY, player); diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 6b577914e6b7603f3cef4c4698d5f81b7ebff19c..c85833a54c79b9a6eb18bc22dae67a92dbbad724 100644 +index cc762d3eb68d2f8bf9529ecf07adfc343953c7a2..1b7b3114cd6ced0587a0e7e4a4c94584c72ed17f 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -235,6 +235,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -236,6 +236,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S } // Paper end @@ -516,7 +577,7 @@ index 6b577914e6b7603f3cef4c4698d5f81b7ebff19c..c85833a54c79b9a6eb18bc22dae67a92 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 442736878291fbdc62572b2c83f384413408326f..00187fbbeddfc17e1b6887f8bf0f50da23938470 100644 +index 364cfa220b5c7c5351f1eb909066bef933da2c08..6d23c39e4eadf23616080d6d08672e13b5d3c37d 100644 --- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java +++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java @@ -32,6 +32,20 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme @@ -556,10 +617,10 @@ index 442736878291fbdc62572b2c83f384413408326f..00187fbbeddfc17e1b6887f8bf0f50da } diff --git a/src/main/java/net/minecraft/world/entity/vehicle/ChestBoat.java b/src/main/java/net/minecraft/world/entity/vehicle/ChestBoat.java -index 11d9d4861aee68cd97d36ee2ff7597b7a6c81294..d70c1206df96b03c031399049a65e6a765d80347 100644 +index 7bfdffc9b3c637bd6ac8ac3eb10961abdc5b1a7a..bc3fe45d12ffc2069a03d1587b7623d31130565a 100644 --- a/src/main/java/net/minecraft/world/entity/vehicle/ChestBoat.java +++ b/src/main/java/net/minecraft/world/entity/vehicle/ChestBoat.java -@@ -65,12 +65,14 @@ public class ChestBoat extends Boat implements HasCustomInventoryScreen, Contain +@@ -66,12 +66,14 @@ public class ChestBoat extends Boat implements HasCustomInventoryScreen, Contain @Override protected void addAdditionalSaveData(CompoundTag nbt) { super.addAdditionalSaveData(nbt); @@ -574,7 +635,7 @@ index 11d9d4861aee68cd97d36ee2ff7597b7a6c81294..d70c1206df96b03c031399049a65e6a7 this.readChestVehicleSaveData(nbt); } -@@ -245,6 +247,20 @@ public class ChestBoat extends Boat implements HasCustomInventoryScreen, Contain +@@ -246,6 +248,20 @@ public class ChestBoat extends Boat implements HasCustomInventoryScreen, Contain this.level().gameEvent(GameEvent.CONTAINER_CLOSE, this.position(), GameEvent.Context.of((Entity) player)); } @@ -654,10 +715,10 @@ index e0fbacd574e0c83c2e1d164ded8e9ccf4af30480..7529751afa2932fd16bc4591189b0358 + // Paper end } 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 111494c30a2b7d8464237a92cf5c98f7f4cca19d..e11618247ad889fa8fadbb2c7addd0de94caf249 100644 +index aa4181e59f88be04a3605352fa5ceb3e04149dd3..a7c9301cfb3e15ebea9b3ca23ce97a936f0e351c 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 -@@ -29,6 +29,7 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc +@@ -17,6 +17,7 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc @Nullable public ResourceLocation lootTable; public long lootTableSeed; @@ -665,49 +726,6 @@ index 111494c30a2b7d8464237a92cf5c98f7f4cca19d..e11618247ad889fa8fadbb2c7addd0de protected RandomizableContainerBlockEntity(BlockEntityType type, BlockPos pos, BlockState state) { super(type, pos, state); -@@ -43,16 +44,19 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc - } - - 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 = nbt.getLong("LootTableSeed"); -- return true; -+ return false; // Paper - always load the items, table may still remain - } else { - return false; - } - } - - protected boolean trySaveLootTable(CompoundTag nbt) { -+ this.lootableData.saveNbt(nbt); // Paper - if (this.lootTable == null) { - return false; - } else { -@@ -61,18 +65,18 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc - nbt.putLong("LootTableSeed", this.lootTableSeed); - } - -- return true; -+ return false; // Paper - always save the items, table may still remain - } - } - - 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().getLootData().getLootTable(this.lootTable); - if (player instanceof ServerPlayer) { - CriteriaTriggers.GENERATE_LOOT.trigger((ServerPlayer)player, this.lootTable); - } - -- this.lootTable = null; -+ this.lootableData.processRefill(player); // Paper - LootParams.Builder builder = (new LootParams.Builder((ServerLevel)this.level)).withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(this.worldPosition)); - if (player != null) { - builder.withLuck(player.getLuck()).withParameter(LootContextParams.THIS_ENTITY, player); diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBrushableBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBrushableBlock.java index 86076a9d2a3b1044c96518cbaeee66d60a8a22c6..c268513bc5719d80e1c3d73de53b85ec7f852fa9 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBrushableBlock.java diff --git a/patches/unapplied/server/0098-System-property-for-disabling-watchdoge.patch b/patches/server/0097-System-property-for-disabling-watchdoge.patch similarity index 100% rename from patches/unapplied/server/0098-System-property-for-disabling-watchdoge.patch rename to patches/server/0097-System-property-for-disabling-watchdoge.patch diff --git a/patches/unapplied/server/0099-Async-GameProfileCache-saving.patch b/patches/server/0098-Async-GameProfileCache-saving.patch similarity index 84% rename from patches/unapplied/server/0099-Async-GameProfileCache-saving.patch rename to patches/server/0098-Async-GameProfileCache-saving.patch index 31a4d3647d..cb985372a0 100644 --- a/patches/unapplied/server/0099-Async-GameProfileCache-saving.patch +++ b/patches/server/0098-Async-GameProfileCache-saving.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Async GameProfileCache saving diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 937de8ff1f8c25861ae09af197d75577088b70fe..2bb21a86f49ec996b7beeb65dd0ec8e2e5634053 100644 +index ee751fb9580064682e650cf1c959a0e159a89bf2..e1849b879334bc9d17e6efeff061e1db6ab4ec7b 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -914,7 +914,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop> consumer, Set trackedPlayers) { this.trackedPlayers = trackedPlayers; diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -index 89fd5d6b373d2705dccc2f22663048f4c2aaa60f..57f9bf73ee14bc8811d0192543caf2b02e890ee0 100644 +index 5c3b86e2301079e775971aa4da6a8f2dc6a40d1f..d9ed22e9853eebdf6c517b41787a27a1a56a0871 100644 --- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java +++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -@@ -98,6 +98,27 @@ public class PrimedTnt extends Entity implements TraceableEntity { +@@ -106,6 +106,27 @@ public class PrimedTnt extends Entity implements TraceableEntity { } } @@ -49,9 +49,9 @@ index 89fd5d6b373d2705dccc2f22663048f4c2aaa60f..57f9bf73ee14bc8811d0192543caf2b0 } private void explode() { -@@ -147,4 +168,11 @@ public class PrimedTnt extends Entity implements TraceableEntity { - public int getFuse() { - return (Integer) this.entityData.get(PrimedTnt.DATA_FUSE_ID); +@@ -179,4 +200,11 @@ public class PrimedTnt extends Entity implements TraceableEntity { + public BlockState getBlockState() { + return (BlockState) this.entityData.get(PrimedTnt.DATA_BLOCK_STATE_ID); } + + // Paper start - Optional prevent TNT from moving in water diff --git a/patches/unapplied/server/0101-Faster-redstone-torch-rapid-clock-removal.patch b/patches/server/0100-Faster-redstone-torch-rapid-clock-removal.patch similarity index 84% rename from patches/unapplied/server/0101-Faster-redstone-torch-rapid-clock-removal.patch rename to patches/server/0100-Faster-redstone-torch-rapid-clock-removal.patch index 7fc6ae0995..24bb6dff26 100644 --- a/patches/unapplied/server/0101-Faster-redstone-torch-rapid-clock-removal.patch +++ b/patches/server/0100-Faster-redstone-torch-rapid-clock-removal.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Faster redstone torch rapid clock removal Only resize the the redstone torch list once, since resizing arrays / lists is costly diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index d9a03a3d262fee9f93b1ccf3a08ec0b77efa1c33..555e7efacd6cc37c6cf959e2931069be5c85fe8f 100644 +index 9bb380e7c8973b4728b5d4aad663af9e477dda0c..48d3da58820c1d9259bc023ddd74e9632b3f62d1 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -173,6 +173,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -176,6 +176,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { private org.spigotmc.TickLimiter tileLimiter; private int tileTickPosition; public final Map explosionDensityCache = new HashMap<>(); // Paper - Optimize explosions @@ -18,19 +18,19 @@ index d9a03a3d262fee9f93b1ccf3a08ec0b77efa1c33..555e7efacd6cc37c6cf959e2931069be public CraftWorld getWorld() { return this.world; diff --git a/src/main/java/net/minecraft/world/level/block/RedstoneTorchBlock.java b/src/main/java/net/minecraft/world/level/block/RedstoneTorchBlock.java -index a6e61112f5a30a0001071cd931ea658384338eef..c91535f6c0bbc870fad7e04b9d341783cfcbbd63 100644 +index 68da47c3ec59518a4bbeb03c196ef0e7c6b5d049..6c49962e8f9e2a5fca50b33f3e3fff76fa36f907 100644 --- a/src/main/java/net/minecraft/world/level/block/RedstoneTorchBlock.java +++ b/src/main/java/net/minecraft/world/level/block/RedstoneTorchBlock.java -@@ -22,7 +22,7 @@ import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit - public class RedstoneTorchBlock extends TorchBlock { +@@ -24,7 +24,7 @@ public class RedstoneTorchBlock extends BaseTorchBlock { + public static final MapCodec CODEC = simpleCodec(RedstoneTorchBlock::new); public static final BooleanProperty LIT = BlockStateProperties.LIT; - private static final Map> RECENT_TOGGLES = new WeakHashMap(); + // Paper - Move the mapped list to World public static final int RECENT_TOGGLE_TIMER = 60; public static final int MAX_RECENT_TOGGLES = 8; public static final int RESTART_DELAY = 160; -@@ -73,11 +73,15 @@ public class RedstoneTorchBlock extends TorchBlock { +@@ -80,11 +80,15 @@ public class RedstoneTorchBlock extends BaseTorchBlock { @Override public void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { boolean flag = this.hasNeighborSignal(world, pos, state); @@ -50,7 +50,7 @@ index a6e61112f5a30a0001071cd931ea658384338eef..c91535f6c0bbc870fad7e04b9d341783 // CraftBukkit start org.bukkit.plugin.PluginManager manager = world.getCraftServer().getPluginManager(); -@@ -153,9 +157,12 @@ public class RedstoneTorchBlock extends TorchBlock { +@@ -160,9 +164,12 @@ public class RedstoneTorchBlock extends BaseTorchBlock { } private static boolean isToggledTooFrequently(Level world, BlockPos pos, boolean addNew) {