From d611ad767de381ed3d384eb648877fa8571a47b5 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 --- .../Async-GameProfileCache-saving.patch | 0 ...r-redstone-torch-rapid-clock-removal.patch | 8 +- ...-API-Replenishable-Lootables-Feature.patch | 106 ++++++++++-------- .../Optional-TNT-doesn-t-move-in-water.patch | 4 +- ...tem-property-for-disabling-watchdoge.patch | 0 5 files changed, 68 insertions(+), 50 deletions(-) rename patches/{unapplied => }/server/Async-GameProfileCache-saving.patch (100%) rename patches/{unapplied => }/server/Faster-redstone-torch-rapid-clock-removal.patch (91%) rename patches/{unapplied => }/server/LootTable-API-Replenishable-Lootables-Feature.patch (92%) rename patches/{unapplied => }/server/Optional-TNT-doesn-t-move-in-water.patch (96%) rename patches/{unapplied => }/server/System-property-for-disabling-watchdoge.patch (100%) diff --git a/patches/unapplied/server/Async-GameProfileCache-saving.patch b/patches/server/Async-GameProfileCache-saving.patch similarity index 100% rename from patches/unapplied/server/Async-GameProfileCache-saving.patch rename to patches/server/Async-GameProfileCache-saving.patch diff --git a/patches/unapplied/server/Faster-redstone-torch-rapid-clock-removal.patch b/patches/server/Faster-redstone-torch-rapid-clock-removal.patch similarity index 91% rename from patches/unapplied/server/Faster-redstone-torch-rapid-clock-removal.patch rename to patches/server/Faster-redstone-torch-rapid-clock-removal.patch index b02286fd01..7d8fddde6e 100644 --- a/patches/unapplied/server/Faster-redstone-torch-rapid-clock-removal.patch +++ b/patches/server/Faster-redstone-torch-rapid-clock-removal.patch @@ -21,16 +21,16 @@ diff --git a/src/main/java/net/minecraft/world/level/block/RedstoneTorchBlock.ja index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/level/block/RedstoneTorchBlock.java +++ b/src/main/java/net/minecraft/world/level/block/RedstoneTorchBlock.java -@@ -0,0 +0,0 @@ import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit - public class RedstoneTorchBlock extends TorchBlock { +@@ -0,0 +0,0 @@ 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; -@@ -0,0 +0,0 @@ public class RedstoneTorchBlock extends TorchBlock { +@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..00000000000000000000000000000000 // CraftBukkit start org.bukkit.plugin.PluginManager manager = world.getCraftServer().getPluginManager(); -@@ -0,0 +0,0 @@ public class RedstoneTorchBlock extends TorchBlock { +@@ -0,0 +0,0 @@ public class RedstoneTorchBlock extends BaseTorchBlock { } private static boolean isToggledTooFrequently(Level world, BlockPos pos, boolean addNew) { diff --git a/patches/unapplied/server/LootTable-API-Replenishable-Lootables-Feature.patch b/patches/server/LootTable-API-Replenishable-Lootables-Feature.patch similarity index 92% rename from patches/unapplied/server/LootTable-API-Replenishable-Lootables-Feature.patch rename to patches/server/LootTable-API-Replenishable-Lootables-Feature.patch index 3d13de19e1..17760b56fa 100644 --- a/patches/unapplied/server/LootTable-API-Replenishable-Lootables-Feature.patch +++ b/patches/server/LootTable-API-Replenishable-Lootables-Feature.patch @@ -503,11 +503,72 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return tileEntityLootable.getLevel(); + } +} +diff --git a/src/main/java/net/minecraft/world/RandomizableContainer.java b/src/main/java/net/minecraft/world/RandomizableContainer.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/RandomizableContainer.java ++++ b/src/main/java/net/minecraft/world/RandomizableContainer.java +@@ -0,0 +0,0 @@ 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; +@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S } // Paper end @@ -665,49 +726,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 protected RandomizableContainerBlockEntity(BlockEntityType type, BlockPos pos, BlockState state) { super(type, pos, state); -@@ -0,0 +0,0 @@ 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 { -@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBrushableBlock.java diff --git a/patches/unapplied/server/Optional-TNT-doesn-t-move-in-water.patch b/patches/server/Optional-TNT-doesn-t-move-in-water.patch similarity index 96% rename from patches/unapplied/server/Optional-TNT-doesn-t-move-in-water.patch rename to patches/server/Optional-TNT-doesn-t-move-in-water.patch index f85a3e4813..e3ea9ba361 100644 --- a/patches/unapplied/server/Optional-TNT-doesn-t-move-in-water.patch +++ b/patches/server/Optional-TNT-doesn-t-move-in-water.patch @@ -50,8 +50,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 private void explode() { @@ -0,0 +0,0 @@ public class PrimedTnt extends Entity implements TraceableEntity { - public int getFuse() { - return (Integer) this.entityData.get(PrimedTnt.DATA_FUSE_ID); + 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/System-property-for-disabling-watchdoge.patch b/patches/server/System-property-for-disabling-watchdoge.patch similarity index 100% rename from patches/unapplied/server/System-property-for-disabling-watchdoge.patch rename to patches/server/System-property-for-disabling-watchdoge.patch