diff options
Diffstat (limited to 'patches/server/1009-Optimize-Hoppers.patch')
-rw-r--r-- | patches/server/1009-Optimize-Hoppers.patch | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/patches/server/1009-Optimize-Hoppers.patch b/patches/server/1009-Optimize-Hoppers.patch index 500c718a87..7ac3c6b823 100644 --- a/patches/server/1009-Optimize-Hoppers.patch +++ b/patches/server/1009-Optimize-Hoppers.patch @@ -105,7 +105,7 @@ index cd3b952a228c09077c2e74183a34ddb32811280b..c0563260277f9f4bd9ff08993b2efb4b } diff --git a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java -index 92086ca118d55ec49cefa5bf18977f8706e3e4b4..8310d132006043e93c612890514c4c7f3eb1c74d 100644 +index 0d6132abd49d66fbf84c046e09144cb33651be15..53f9d28bf3c6aafd4fdd6c12e0285500fe7350ce 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java @@ -156,6 +156,43 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen @@ -370,7 +370,7 @@ index 92086ca118d55ec49cefa5bf18977f8706e3e4b4..8310d132006043e93c612890514c4c7f private static boolean ejectItems(Level world, BlockPos pos, HopperBlockEntity blockEntity) { Container iinventory = HopperBlockEntity.getAttachedContainer(world, pos, blockEntity); -@@ -209,47 +443,50 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -209,48 +443,51 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen if (HopperBlockEntity.isFullContainer(iinventory, enumdirection)) { return false; } else { @@ -380,6 +380,7 @@ index 92086ca118d55ec49cefa5bf18977f8706e3e4b4..8310d132006043e93c612890514c4c7f - if (!itemstack.isEmpty()) { - int j = itemstack.getCount(); - // CraftBukkit start - Call event when pushing items into other inventories +- ItemStack original = itemstack.copy(); - CraftItemStack oitemstack = CraftItemStack.asCraftMirror(blockEntity.removeItem(i, world.spigotConfig.hopperAmount)); // Spigot - - Inventory destinationInventory; @@ -395,7 +396,7 @@ index 92086ca118d55ec49cefa5bf18977f8706e3e4b4..8310d132006043e93c612890514c4c7f - InventoryMoveItemEvent event = new InventoryMoveItemEvent(blockEntity.getOwner().getInventory(), oitemstack, destinationInventory, true); - world.getCraftServer().getPluginManager().callEvent(event); - if (event.isCancelled()) { -- blockEntity.setItem(i, itemstack); +- blockEntity.setItem(i, original); - blockEntity.setCooldown(world.spigotConfig.hopperTransfer); // Delay hopper checks // Spigot - return false; - } @@ -423,6 +424,7 @@ index 92086ca118d55ec49cefa5bf18977f8706e3e4b4..8310d132006043e93c612890514c4c7f + // if (!itemstack.isEmpty()) { + // int j = itemstack.getCount(); + // // CraftBukkit start - Call event when pushing items into other inventories ++ // ItemStack original = itemstack.copy(); + // CraftItemStack oitemstack = CraftItemStack.asCraftMirror(blockEntity.removeItem(i, world.spigotConfig.hopperAmount)); // Spigot + + // Inventory destinationInventory; @@ -438,7 +440,7 @@ index 92086ca118d55ec49cefa5bf18977f8706e3e4b4..8310d132006043e93c612890514c4c7f + // InventoryMoveItemEvent event = new InventoryMoveItemEvent(tileentityhopper.getOwner().getInventory(), oitemstack, destinationInventory, true); + // world.getCraftServer().getPluginManager().callEvent(event); + // if (event.isCancelled()) { -+ // blockEntity.setItem(i, itemstack); ++ // blockEntity.setItem(i, original); + // blockEntity.setCooldown(world.spigotConfig.hopperTransfer); // Delay hopper checks // Spigot + // return false; + // } @@ -462,7 +464,7 @@ index 92086ca118d55ec49cefa5bf18977f8706e3e4b4..8310d132006043e93c612890514c4c7f } } } -@@ -300,7 +537,6 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -301,7 +538,6 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen return false; } } @@ -470,7 +472,7 @@ index 92086ca118d55ec49cefa5bf18977f8706e3e4b4..8310d132006043e93c612890514c4c7f return true; } -@@ -311,6 +547,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -312,6 +548,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen if (iinventory != null) { Direction enumdirection = Direction.DOWN; @@ -478,12 +480,13 @@ index 92086ca118d55ec49cefa5bf18977f8706e3e4b4..8310d132006043e93c612890514c4c7f int[] aint = HopperBlockEntity.getSlots(iinventory, enumdirection); int i = aint.length; -@@ -346,44 +583,47 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -347,45 +584,48 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen ItemStack itemstack = iinventory.getItem(i); if (!itemstack.isEmpty() && HopperBlockEntity.canTakeItemFromContainer(ihopper, iinventory, itemstack, i, enumdirection)) { - int j = itemstack.getCount(); - // CraftBukkit start - Call event on collection of items from inventories into the hopper +- ItemStack original = itemstack.copy(); - CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.removeItem(i, world.spigotConfig.hopperAmount)); // Spigot - - Inventory sourceInventory; @@ -500,7 +503,7 @@ index 92086ca118d55ec49cefa5bf18977f8706e3e4b4..8310d132006043e93c612890514c4c7f - - Bukkit.getServer().getPluginManager().callEvent(event); - if (event.isCancelled()) { -- iinventory.setItem(i, itemstack); +- iinventory.setItem(i, original); - - if (ihopper instanceof HopperBlockEntity) { - ((HopperBlockEntity) ihopper).setCooldown(world.spigotConfig.hopperTransfer); // Spigot @@ -524,6 +527,7 @@ index 92086ca118d55ec49cefa5bf18977f8706e3e4b4..8310d132006043e93c612890514c4c7f + return hopperPull(world, ihopper, iinventory, itemstack, i); + // int j = itemstack.getCount(); + // // CraftBukkit start - Call event on collection of items from inventories into the hopper ++ // ItemStack original = itemstack.copy(); + // CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.removeItem(i, world.spigotConfig.hopperAmount)); // Spigot + + // Inventory sourceInventory; @@ -540,7 +544,7 @@ index 92086ca118d55ec49cefa5bf18977f8706e3e4b4..8310d132006043e93c612890514c4c7f + + // Bukkit.getServer().getPluginManager().callEvent(event); + // if (event.isCancelled()) { -+ // iinventory.setItem(i, itemstack); ++ // iinventory.setItem(i, original); + + // if (ihopper instanceof HopperBlockEntity) { + // ((HopperBlockEntity) ihopper).setCooldown(world.spigotConfig.hopperTransfer); // Spigot @@ -564,7 +568,7 @@ index 92086ca118d55ec49cefa5bf18977f8706e3e4b4..8310d132006043e93c612890514c4c7f } return false; -@@ -392,12 +632,14 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -394,12 +634,14 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen public static boolean addItem(Container inventory, ItemEntity itemEntity) { boolean flag = false; // CraftBukkit start @@ -580,7 +584,7 @@ index 92086ca118d55ec49cefa5bf18977f8706e3e4b4..8310d132006043e93c612890514c4c7f ItemStack itemstack = itemEntity.getItem().copy(); ItemStack itemstack1 = HopperBlockEntity.addItem((Container) null, inventory, itemstack, (Direction) null); -@@ -491,7 +733,9 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -493,7 +735,9 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen stack = stack.split(to.getMaxStackSize()); } // Spigot end @@ -590,7 +594,7 @@ index 92086ca118d55ec49cefa5bf18977f8706e3e4b4..8310d132006043e93c612890514c4c7f stack = leftover; // Paper - Make hoppers respect inventory max stack size flag = true; } else if (HopperBlockEntity.canMergeItems(itemstack1, stack)) { -@@ -571,14 +815,20 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -573,14 +817,20 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen @Nullable public static Container getContainerAt(Level world, BlockPos pos) { @@ -613,7 +617,7 @@ index 92086ca118d55ec49cefa5bf18977f8706e3e4b4..8310d132006043e93c612890514c4c7f iinventory = HopperBlockEntity.getEntityContainer(world, x, y, z); } -@@ -613,13 +863,13 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -615,13 +865,13 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen @Nullable private static Container getEntityContainer(Level world, double x, double y, double z) { |