2016-02-29 21:33:06 +00:00
|
|
|
From 68ce95ca445ea5500f1ef9e7ab0cfdf910b51e2d Mon Sep 17 00:00:00 2001
|
2014-07-21 20:46:54 +00:00
|
|
|
From: erocs <github@erocs.org>
|
|
|
|
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
|
2016-02-29 21:33:06 +00:00
|
|
|
index 7b00f6a..c01acb9 100644
|
2014-07-21 20:46:54 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/TileEntityHopper.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/TileEntityHopper.java
|
2016-02-29 21:33:06 +00:00
|
|
|
@@ -174,12 +174,11 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
2014-07-21 20:46:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (flag) {
|
2016-02-29 21:33:06 +00:00
|
|
|
- this.setCooldown(8);
|
|
|
|
+ this.setCooldown(world.spigotConfig.hopperTransfer); // Spigot
|
2014-07-21 20:46:54 +00:00
|
|
|
this.update();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2015-03-08 12:42:50 +00:00
|
|
|
-
|
2014-07-21 20:46:54 +00:00
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
return false;
|
2016-02-29 21:33:06 +00:00
|
|
|
@@ -233,7 +232,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
2014-11-28 01:17:45 +00:00
|
|
|
// ItemStack itemstack1 = addItem(iinventory, this.splitStack(i, 1), enumdirection);
|
2015-02-28 11:36:22 +00:00
|
|
|
|
2014-07-21 20:46:54 +00:00
|
|
|
// CraftBukkit start - Call event when pushing items into other inventories
|
2014-11-28 01:17:45 +00:00
|
|
|
- CraftItemStack oitemstack = CraftItemStack.asCraftMirror(this.splitStack(i, 1));
|
|
|
|
+ CraftItemStack oitemstack = CraftItemStack.asCraftMirror(this.splitStack(i, world.spigotConfig.hopperAmount)); // Spigot
|
2014-07-21 20:46:54 +00:00
|
|
|
|
|
|
|
Inventory destinationInventory;
|
|
|
|
// Have to special case large chests as they work oddly
|
2016-02-29 21:33:06 +00:00
|
|
|
@@ -247,9 +246,10 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
2014-07-21 20:46:54 +00:00
|
|
|
this.getWorld().getServer().getPluginManager().callEvent(event);
|
|
|
|
if (event.isCancelled()) {
|
2014-11-28 01:17:45 +00:00
|
|
|
this.setItem(i, itemstack);
|
2016-02-29 21:33:06 +00:00
|
|
|
- this.setCooldown(8); // Delay hopper checks
|
|
|
|
+ this.setCooldown(world.spigotConfig.hopperTransfer); // Spigot
|
2014-07-21 20:46:54 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
+ int origCount = event.getItem().getAmount(); // Spigot
|
2014-11-28 01:17:45 +00:00
|
|
|
ItemStack itemstack1 = addItem(iinventory, CraftItemStack.asNMSCopy(event.getItem()), enumdirection);
|
|
|
|
|
2014-07-21 20:46:54 +00:00
|
|
|
if (itemstack1 == null || itemstack1.count == 0) {
|
2016-02-29 21:33:06 +00:00
|
|
|
@@ -261,7 +261,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
2014-07-21 20:46:54 +00:00
|
|
|
// CraftBukkit end
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
-
|
|
|
|
+ itemstack.count -= origCount - itemstack1.count; // Spigot
|
2014-11-28 01:17:45 +00:00
|
|
|
this.setItem(i, itemstack);
|
2014-07-21 20:46:54 +00:00
|
|
|
}
|
|
|
|
}
|
2016-02-29 21:33:06 +00:00
|
|
|
@@ -371,7 +371,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
2014-07-21 20:46:54 +00:00
|
|
|
ItemStack itemstack1 = itemstack.cloneItemStack();
|
2014-11-28 01:17:45 +00:00
|
|
|
// ItemStack itemstack2 = addItem(ihopper, iinventory.splitStack(i, 1), (EnumDirection) null);
|
2014-07-21 20:46:54 +00:00
|
|
|
// 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
|
2016-02-29 21:33:06 +00:00
|
|
|
@@ -388,13 +388,13 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
2014-07-21 20:46:54 +00:00
|
|
|
iinventory.setItem(i, itemstack1);
|
|
|
|
|
|
|
|
if (ihopper instanceof TileEntityHopper) {
|
2016-02-29 21:33:06 +00:00
|
|
|
- ((TileEntityHopper) ihopper).setCooldown(8); // Delay hopper checks
|
|
|
|
+ ((TileEntityHopper) ihopper).setCooldown(ihopper.getWorld().spigotConfig.hopperTransfer); // Spigot
|
2014-07-21 20:46:54 +00:00
|
|
|
} else if (ihopper instanceof EntityMinecartHopper) {
|
2016-02-29 21:33:06 +00:00
|
|
|
- ((EntityMinecartHopper) ihopper).setCooldown(4); // Delay hopper minecart checks
|
|
|
|
+ ((EntityMinecartHopper) ihopper).setCooldown(ihopper.getWorld().spigotConfig.hopperTransfer / 2); // Spigot
|
2014-07-21 20:46:54 +00:00
|
|
|
}
|
2015-02-28 11:36:22 +00:00
|
|
|
-
|
2014-07-21 20:46:54 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
+ int origCount = event.getItem().getAmount(); // Spigot
|
2014-11-28 01:17:45 +00:00
|
|
|
ItemStack itemstack2 = addItem(ihopper, CraftItemStack.asNMSCopy(event.getItem()), null);
|
2014-07-21 20:46:54 +00:00
|
|
|
|
|
|
|
if (itemstack2 == null || itemstack2.count == 0) {
|
2016-02-29 21:33:06 +00:00
|
|
|
@@ -406,6 +406,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
2014-11-28 01:17:45 +00:00
|
|
|
// CraftBukkit end
|
2014-07-21 20:46:54 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
+ itemstack1.count -= origCount - itemstack2.count; // Spigot
|
|
|
|
|
|
|
|
iinventory.setItem(i, itemstack1);
|
|
|
|
}
|
2016-02-29 21:33:06 +00:00
|
|
|
@@ -495,7 +496,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
2014-11-28 01:17:45 +00:00
|
|
|
TileEntityHopper tileentityhopper = (TileEntityHopper) iinventory;
|
2014-07-21 20:46:54 +00:00
|
|
|
|
2016-02-29 21:33:06 +00:00
|
|
|
if (tileentityhopper.p()) {
|
|
|
|
- tileentityhopper.setCooldown(8);
|
|
|
|
+ tileentityhopper.setCooldown(tileentityhopper.world.spigotConfig.hopperTransfer); // Spigot
|
2014-11-28 01:17:45 +00:00
|
|
|
}
|
2014-07-21 20:46:54 +00:00
|
|
|
|
2014-11-28 01:17:45 +00:00
|
|
|
iinventory.update();
|
2014-07-21 20:46:54 +00:00
|
|
|
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
2016-02-29 21:33:06 +00:00
|
|
|
index 1369657..4de0a98 100644
|
2014-07-21 20:46:54 +00:00
|
|
|
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
|
|
|
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
2016-02-29 21:33:06 +00:00
|
|
|
@@ -162,4 +162,19 @@ public class SpigotWorldConfig
|
2014-07-21 20:46:54 +00:00
|
|
|
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 );
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
--
|
2016-02-29 21:33:06 +00:00
|
|
|
2.5.0
|
2014-07-21 20:46:54 +00:00
|
|
|
|