diff options
Diffstat (limited to 'CraftBukkit-Patches/0028-Hopper-Customisations.patch')
-rw-r--r-- | CraftBukkit-Patches/0028-Hopper-Customisations.patch | 133 |
1 files changed, 133 insertions, 0 deletions
diff --git a/CraftBukkit-Patches/0028-Hopper-Customisations.patch b/CraftBukkit-Patches/0028-Hopper-Customisations.patch new file mode 100644 index 0000000000..562bebe5cf --- /dev/null +++ b/CraftBukkit-Patches/0028-Hopper-Customisations.patch @@ -0,0 +1,133 @@ +From a1de0d063833482e59a1ae4750bf5542558b66bd Mon Sep 17 00:00:00 2001 +From: erocs <[email protected]> +Date: Sun, 8 Sep 2013 12:06:15 -0700 +Subject: [PATCH] Hopper Customisations + +Allows editing hopper cooldowns and amount transferred per tick. + +diff --git a/src/main/java/net/minecraft/server/TileEntityHopper.java b/src/main/java/net/minecraft/server/TileEntityHopper.java +index ebdf08e..d77708b 100644 +--- a/src/main/java/net/minecraft/server/TileEntityHopper.java ++++ b/src/main/java/net/minecraft/server/TileEntityHopper.java +@@ -189,12 +189,18 @@ public class TileEntityHopper extends TileEntity implements IHopper { + } + + if (flag) { +- this.c(8); ++ this.c(world.spigotConfig.hopperTransfer); // Spigot + this.update(); + return true; + } + } + ++ // Spigot start ++ if ( !this.j() ) ++ { ++ this.c( world.spigotConfig.hopperCheck ); ++ } ++ // Spigot end + return false; + } else { + return false; +@@ -246,7 +252,7 @@ public class TileEntityHopper extends TileEntity implements IHopper { + if (this.getItem(j) != null) { + ItemStack itemstack = this.getItem(j).cloneItemStack(); + // CraftBukkit start - Call event when pushing items into other inventories +- CraftItemStack oitemstack = CraftItemStack.asCraftMirror(this.splitStack(j, 1)); ++ CraftItemStack oitemstack = CraftItemStack.asCraftMirror(this.splitStack(j, world.spigotConfig.hopperAmount)); // Spigot + + Inventory destinationInventory; + // Have to special case large chests as they work oddly +@@ -260,11 +266,11 @@ public class TileEntityHopper extends TileEntity implements IHopper { + this.getWorld().getServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + this.setItem(j, itemstack); +- this.c(8); // Delay hopper checks ++ this.c(world.spigotConfig.hopperTransfer); // Spigot + return false; + } ++ int origCount = event.getItem().getAmount(); // Spigot + ItemStack itemstack1 = addItem(iinventory, CraftItemStack.asNMSCopy(event.getItem()), i); +- + if (itemstack1 == null || itemstack1.count == 0) { + if (event.getItem().equals(oitemstack)) { + iinventory.update(); +@@ -274,7 +280,7 @@ public class TileEntityHopper extends TileEntity implements IHopper { + // CraftBukkit end + return true; + } +- ++ itemstack.count -= origCount - itemstack1.count; // Spigot + this.setItem(j, itemstack); + } + } +@@ -379,7 +385,7 @@ public class TileEntityHopper extends TileEntity implements IHopper { + if (itemstack != null && canTakeItemFromInventory(iinventory, itemstack, i, j)) { + ItemStack itemstack1 = itemstack.cloneItemStack(); + // CraftBukkit start - Call event on collection of items from inventories into the hopper +- CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.splitStack(i, 1)); ++ CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.splitStack(i, ihopper.getWorld().spigotConfig.hopperAmount)); // Spigot + + Inventory sourceInventory; + // Have to special case large chests as they work oddly +@@ -396,13 +402,14 @@ public class TileEntityHopper extends TileEntity implements IHopper { + iinventory.setItem(i, itemstack1); + + if (ihopper instanceof TileEntityHopper) { +- ((TileEntityHopper) ihopper).c(8); // Delay hopper checks ++ ((TileEntityHopper) ihopper).c(ihopper.getWorld().spigotConfig.hopperTransfer); // Spigot + } else if (ihopper instanceof EntityMinecartHopper) { +- ((EntityMinecartHopper) ihopper).l(4); // Delay hopper minecart checks ++ ((EntityMinecartHopper) ihopper).l(ihopper.getWorld().spigotConfig.hopperTransfer / 2); // Spigot + } + + return false; + } ++ int origCount = event.getItem().getAmount(); // Spigot + ItemStack itemstack2 = addItem(ihopper, CraftItemStack.asNMSCopy(event.getItem()), -1); + + if (itemstack2 == null || itemstack2.count == 0) { +@@ -415,6 +422,7 @@ public class TileEntityHopper extends TileEntity implements IHopper { + + return true; + } ++ itemstack1.count -= origCount - itemstack2.count; // Spigot + + iinventory.setItem(i, itemstack1); + } +@@ -502,7 +510,7 @@ public class TileEntityHopper extends TileEntity implements IHopper { + + if (flag) { + if (iinventory instanceof TileEntityHopper) { +- ((TileEntityHopper) iinventory).c(8); ++ ((TileEntityHopper) iinventory).c(((TileEntityHopper) iinventory).world.spigotConfig.hopperTransfer); // Spigot + iinventory.update(); + } + +diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java +index 6421bf2..956c628 100644 +--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java ++++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java +@@ -164,4 +164,19 @@ public class SpigotWorldConfig + otherTrackingRange = getInt( "entity-tracking-range.other", otherTrackingRange ); + log( "Entity Tracking Range: Pl " + playerTrackingRange + " / An " + animalTrackingRange + " / Mo " + monsterTrackingRange + " / Mi " + miscTrackingRange + " / Other " + otherTrackingRange ); + } ++ ++ public int hopperTransfer; ++ public int hopperCheck; ++ public int hopperAmount; ++ private void hoppers() ++ { ++ // Set the tick delay between hopper item movements ++ hopperTransfer = getInt( "ticks-per.hopper-transfer", 8 ); ++ // Set the tick delay between checking for items after the associated ++ // container is empty. Default to the hopperTransfer value to prevent ++ // hopper sorting machines from becoming out of sync. ++ hopperCheck = getInt( "ticks-per.hopper-check", hopperTransfer ); ++ hopperAmount = getInt( "hopper-amount", 1 ); ++ log( "Hopper Transfer: " + hopperTransfer + " Hopper Check: " + hopperCheck + " Hopper Amount: " + hopperAmount ); ++ } + } +-- +1.9.1 + |