From 4e13355af1d6c0dbb0c1b0b2a9f887f962b96d47 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Tue, 7 Jun 2022 14:48:09 -0700 Subject: [PATCH] some server compile fixes --- patches/api/0039-LootTable-API.patch | 11 + ...-API-Replenishable-Lootables-Feature.patch | 213 ++++++++++++------ 2 files changed, 149 insertions(+), 75 deletions(-) diff --git a/patches/api/0039-LootTable-API.patch b/patches/api/0039-LootTable-API.patch index ed6e56042..8be71089d 100644 --- a/patches/api/0039-LootTable-API.patch +++ b/patches/api/0039-LootTable-API.patch @@ -323,6 +323,17 @@ index 387b2892886e1ccb2bd928e5111fb9bd41d777ab..5dc5318b0a451937228a8a059dfec1cd /** * Get the {@link DyeColor} corresponding to this ShulkerBox +diff --git a/src/main/java/org/bukkit/entity/ChestBoat.java b/src/main/java/org/bukkit/entity/ChestBoat.java +index 5b5c3be107fdaa6c55ceb1bca2c223ebc6ab7f43..4ebe1033c55dbd58d0794809435c935236fabcc2 100644 +--- a/src/main/java/org/bukkit/entity/ChestBoat.java ++++ b/src/main/java/org/bukkit/entity/ChestBoat.java +@@ -6,5 +6,5 @@ import org.bukkit.loot.Lootable; + /** + * A {@link Boat} with a chest. + */ +-public interface ChestBoat extends Boat, InventoryHolder, Lootable { ++public interface ChestBoat extends Boat, InventoryHolder, com.destroystokyo.paper.loottable.LootableEntityInventory { // Paper + } diff --git a/src/main/java/org/bukkit/entity/minecart/HopperMinecart.java b/src/main/java/org/bukkit/entity/minecart/HopperMinecart.java index 937b99f8734d71b2ad33af142afbc251b81d9745..db69687a7ad4b18d17ab1677cae5d8dd4dcd3678 100644 --- a/src/main/java/org/bukkit/entity/minecart/HopperMinecart.java diff --git a/patches/server/0091-LootTable-API-Replenishable-Lootables-Feature.patch b/patches/server/0091-LootTable-API-Replenishable-Lootables-Feature.patch index d41e3c535..8e6adff62 100644 --- a/patches/server/0091-LootTable-API-Replenishable-Lootables-Feature.patch +++ b/patches/server/0091-LootTable-API-Replenishable-Lootables-Feature.patch @@ -41,6 +41,75 @@ index 2c7cdf91288eb9a88d1d453accc87a8d77e6daac..a491af30f70f41e5f7b198ae4d40acfb + } + } } +diff --git a/src/main/java/com/destroystokyo/paper/loottable/PaperContainerEntityLootableInventory.java b/src/main/java/com/destroystokyo/paper/loottable/PaperContainerEntityLootableInventory.java +new file mode 100644 +index 0000000000000000000000000000000000000000..88e32ed64f90bfd277dac84ba4bd84f0d943f5f8 +--- /dev/null ++++ b/src/main/java/com/destroystokyo/paper/loottable/PaperContainerEntityLootableInventory.java +@@ -0,0 +1,63 @@ ++package com.destroystokyo.paper.loottable; ++ ++import net.minecraft.world.entity.Entity; ++import net.minecraft.world.entity.vehicle.AbstractMinecartContainer; ++import net.minecraft.world.entity.vehicle.ContainerEntity; ++import net.minecraft.world.level.Level; ++import org.bukkit.Bukkit; ++import org.bukkit.craftbukkit.util.CraftNamespacedKey; ++ ++public class PaperContainerEntityLootableInventory implements PaperLootableEntityInventory { ++ ++ private final ContainerEntity entity; ++ ++ public PaperContainerEntityLootableInventory(ContainerEntity entity) { ++ this.entity = entity; ++ } ++ ++ @Override ++ public org.bukkit.loot.LootTable getLootTable() { ++ return entity.getLootTable() != null ? Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(entity.getLootTable())) : null; ++ } ++ ++ @Override ++ public void setLootTable(org.bukkit.loot.LootTable table, long seed) { ++ setLootTable(table); ++ setSeed(seed); ++ } ++ ++ @Override ++ public void setSeed(long seed) { ++ entity.setLootTableSeed(seed); ++ } ++ ++ @Override ++ public long getSeed() { ++ return entity.getLootTableSeed(); ++ } ++ ++ @Override ++ public void setLootTable(org.bukkit.loot.LootTable table) { ++ entity.setLootTable((table == null) ? null : CraftNamespacedKey.toMinecraft(table.getKey())); ++ } ++ ++ @Override ++ public PaperLootableInventoryData getLootableData() { ++ return entity.getLootableData(); ++ } ++ ++ @Override ++ public Entity getHandle() { ++ return entity.getEntity(); ++ } ++ ++ @Override ++ public LootableInventory getAPILootableInventory() { ++ return (LootableInventory) entity.getEntity().getBukkitEntity(); ++ } ++ ++ @Override ++ public Level getNMSWorld() { ++ return entity.getLevel(); ++ } ++} 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..70ca5625ff5d13a8e9cd64953066a7e1547ff223 @@ -375,74 +444,6 @@ index 0000000000000000000000000000000000000000..20cfe7b9b7127ddeb97aa91d759fc17b + return lootedPlayers != null ? lootedPlayers.get(player) : null; + } +} -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..6d2e0493729b7b4e109ff103a6ac36c9901568c0 ---- /dev/null -+++ b/src/main/java/com/destroystokyo/paper/loottable/PaperMinecartLootableInventory.java -@@ -0,0 +1,62 @@ -+package com.destroystokyo.paper.loottable; -+ -+import net.minecraft.world.entity.Entity; -+import net.minecraft.world.entity.vehicle.AbstractMinecartContainer; -+import net.minecraft.world.level.Level; -+import org.bukkit.Bukkit; -+import org.bukkit.craftbukkit.util.CraftNamespacedKey; -+ -+public class PaperMinecartLootableInventory implements PaperLootableEntityInventory { -+ -+ private AbstractMinecartContainer entity; -+ -+ public PaperMinecartLootableInventory(AbstractMinecartContainer entity) { -+ this.entity = entity; -+ } -+ -+ @Override -+ public org.bukkit.loot.LootTable getLootTable() { -+ return entity.lootTable != null ? Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(entity.lootTable)) : null; -+ } -+ -+ @Override -+ public void setLootTable(org.bukkit.loot.LootTable table, long seed) { -+ setLootTable(table); -+ setSeed(seed); -+ } -+ -+ @Override -+ public void setSeed(long seed) { -+ entity.lootTableSeed = seed; -+ } -+ -+ @Override -+ public long getSeed() { -+ return entity.lootTableSeed; -+ } -+ -+ @Override -+ public void setLootTable(org.bukkit.loot.LootTable table) { -+ entity.lootTable = (table == null) ? null : CraftNamespacedKey.toMinecraft(table.getKey()); -+ } -+ -+ @Override -+ public PaperLootableInventoryData getLootableData() { -+ return entity.lootableData; -+ } -+ -+ @Override -+ public Entity getHandle() { -+ return entity; -+ } -+ -+ @Override -+ public LootableInventory getAPILootableInventory() { -+ return (LootableInventory) entity.getBukkitEntity(); -+ } -+ -+ @Override -+ public Level getNMSWorld() { -+ return entity.level; -+ } -+} 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..3377b86c337d0234bbb9b0349e4034a7cd450a97 @@ -527,18 +528,31 @@ index 3b998ca5230dc03a7faf2b0d1d1731b442337346..1c74d8f3b432afb9bcc71d87d86cb977 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 9347faecdaa3ef8c375fe8b0a89fc3385b6823bd..9e29080bd041062447f3ba3240811e86022edc56 100644 +index 9347faecdaa3ef8c375fe8b0a89fc3385b6823bd..b8fb7b5a347298ada16bc8b818edf1863e3f6040 100644 --- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java +++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java -@@ -33,6 +33,7 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme +@@ -32,6 +32,20 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme + public ResourceLocation lootTable; public long lootTableSeed; ++ // Paper start ++ { ++ this.lootableData = new com.destroystokyo.paper.loottable.PaperLootableInventoryData(new com.destroystokyo.paper.loottable.PaperContainerEntityLootableInventory(this)); ++ } ++ @Override ++ public Entity getEntity() { ++ return this; ++ } ++ ++ @Override ++ public com.destroystokyo.paper.loottable.PaperLootableInventoryData getLootableData() { ++ return this.lootableData; ++ } ++ // Paper end // CraftBukkit start -+ { this.lootableData = new com.destroystokyo.paper.loottable.PaperLootableInventoryData(new com.destroystokyo.paper.loottable.PaperMinecartLootableInventory(this)); } // Paper public List transaction = new java.util.ArrayList(); private int maxStack = MAX_STACK; - -@@ -134,12 +135,14 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme +@@ -134,12 +148,14 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme @Override protected void addAdditionalSaveData(CompoundTag nbt) { super.addAdditionalSaveData(nbt); @@ -554,7 +568,7 @@ index 9347faecdaa3ef8c375fe8b0a89fc3385b6823bd..9e29080bd041062447f3ba3240811e86 } 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 abb35b675fc075c1004a85cd8f0c6f65d290a809..64097c718e906d2afb469202a0c9b82435e2926c 100644 +index abb35b675fc075c1004a85cd8f0c6f65d290a809..ba14657c6911bfd54da6ee9e248b3a050455d68a 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 @@ -572,8 +586,29 @@ index abb35b675fc075c1004a85cd8f0c6f65d290a809..64097c718e906d2afb469202a0c9b824 this.readChestVehicleSaveData(nbt); } +@@ -223,6 +225,20 @@ public class ChestBoat extends Boat implements HasCustomInventoryScreen, Contain + this.itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); + } + ++ // Paper start ++ { ++ this.lootableData = new com.destroystokyo.paper.loottable.PaperLootableInventoryData(new com.destroystokyo.paper.loottable.PaperContainerEntityLootableInventory(this)); ++ } ++ @Override ++ public Entity getEntity() { ++ return this; ++ } ++ ++ @Override ++ public com.destroystokyo.paper.loottable.PaperLootableInventoryData getLootableData() { ++ return this.lootableData; ++ } ++ // Paper end + // CraftBukkit start + public List transaction = new java.util.ArrayList(); + private int maxStack = MAX_STACK; diff --git a/src/main/java/net/minecraft/world/entity/vehicle/ContainerEntity.java b/src/main/java/net/minecraft/world/entity/vehicle/ContainerEntity.java -index e2a9782e0ae60eb5557dce0831084c5722687df6..8b740ae757721e02761939f8b50199e09f5c9136 100644 +index e2a9782e0ae60eb5557dce0831084c5722687df6..9c15af9b622716ba8b21b8b1138ad1cd85430f96 100644 --- a/src/main/java/net/minecraft/world/entity/vehicle/ContainerEntity.java +++ b/src/main/java/net/minecraft/world/entity/vehicle/ContainerEntity.java @@ -61,7 +61,7 @@ public interface ContainerEntity extends Container, MenuProvider { @@ -594,6 +629,20 @@ index e2a9782e0ae60eb5557dce0831084c5722687df6..8b740ae757721e02761939f8b50199e0 ContainerHelper.loadAllItems(nbt, this.getItemStacks()); } +@@ -184,4 +184,13 @@ public interface ContainerEntity extends Container, MenuProvider { + default boolean isChestVehicleStillValid(Player player) { + return !this.isRemoved() && this.position().closerThan(player.position(), 8.0D); + } ++ // Paper start ++ default Entity getEntity() { ++ throw new UnsupportedOperationException(); ++ } ++ ++ default com.destroystokyo.paper.loottable.PaperLootableInventoryData getLootableData() { ++ throw new UnsupportedOperationException(); ++ } ++ // 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 216fc20326d71121098430dc1b9f7477265a91b7..e3bee2df77d87630e96621470e940d9d9e152e7f 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java @@ -678,6 +727,20 @@ index 982adacb361b0590799dc68f9b7c13c7195627fd..e49eece9bff3a53469673d03a7bbf8f9 public CraftLootable(World world, T tileEntity) { super(world, tileEntity); +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftChestBoat.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftChestBoat.java +index ae07db69b11b993b50782c94aa5c45b97d949612..4b6631edfbfb8fb0421678a7ef8c930a3726a970 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftChestBoat.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftChestBoat.java +@@ -11,8 +11,7 @@ import org.bukkit.entity.EntityType; + import org.bukkit.inventory.Inventory; + import org.bukkit.loot.LootTable; + +-public class CraftChestBoat extends CraftBoat implements org.bukkit.entity.ChestBoat { +- ++public class CraftChestBoat extends CraftBoat implements org.bukkit.entity.ChestBoat, com.destroystokyo.paper.loottable.PaperLootableEntityInventory { // Paper + private final Inventory inventory; + + public CraftChestBoat(CraftServer server, ChestBoat entity) { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartChest.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartChest.java index eb21b8457774d5ac765fa9008157cb29d9b72509..abf58bef2042a9efba5a78fd7f97339deceaa780 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartChest.java