2014-04-24 21:07:39 +02:00
|
|
|
From 0467adc477c07485d63c96122b135c5b4ab5602b Mon Sep 17 00:00:00 2001
|
2013-09-09 06:40:16 +02:00
|
|
|
From: erocs <github@erocs.org>
|
|
|
|
Date: Sun, 8 Sep 2013 12:06:15 -0700
|
2014-04-19 01:22:44 +02:00
|
|
|
Subject: [PATCH] Hopper Customisations
|
2013-06-20 11:44:06 +02:00
|
|
|
|
2014-04-19 01:22:44 +02:00
|
|
|
Allows editing hopper cooldowns and amount transferred per tick.
|
2013-06-20 11:44:06 +02:00
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/TileEntityHopper.java b/src/main/java/net/minecraft/server/TileEntityHopper.java
|
2014-04-24 21:07:39 +02:00
|
|
|
index 48a882a..ba015aa 100644
|
2013-06-20 11:44:06 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/TileEntityHopper.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/TileEntityHopper.java
|
2014-03-23 01:06:43 +01:00
|
|
|
@@ -189,12 +189,18 @@ public class TileEntityHopper extends TileEntity implements IHopper {
|
|
|
|
}
|
2013-06-20 11:44:06 +02:00
|
|
|
|
|
|
|
if (flag) {
|
|
|
|
- this.c(8);
|
|
|
|
+ this.c(world.spigotConfig.hopperTransfer); // Spigot
|
|
|
|
this.update();
|
|
|
|
return true;
|
|
|
|
}
|
2013-09-09 06:40:16 +02:00
|
|
|
}
|
2014-03-23 01:06:43 +01:00
|
|
|
|
2013-09-09 06:40:16 +02:00
|
|
|
+ // Spigot start
|
2013-12-01 06:00:50 +01:00
|
|
|
+ if ( !this.j() )
|
2013-09-09 06:40:16 +02:00
|
|
|
+ {
|
|
|
|
+ this.c( world.spigotConfig.hopperCheck );
|
|
|
|
+ }
|
|
|
|
+ // Spigot end
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
return false;
|
2014-04-19 01:22:44 +02:00
|
|
|
@@ -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
|
2014-03-23 01:06:43 +01:00
|
|
|
@@ -260,7 +266,7 @@ public class TileEntityHopper extends TileEntity implements IHopper {
|
|
|
|
this.getWorld().getServer().getPluginManager().callEvent(event);
|
|
|
|
if (event.isCancelled()) {
|
2014-03-24 21:36:29 +01:00
|
|
|
this.setItem(j, itemstack);
|
2014-03-23 01:06:43 +01:00
|
|
|
- this.c(8); // Delay hopper checks
|
|
|
|
+ this.c(world.spigotConfig.hopperTransfer); // Spigot
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
ItemStack itemstack1 = addItem(iinventory, CraftItemStack.asNMSCopy(event.getItem()), i);
|
2014-04-24 21:07:39 +02:00
|
|
|
@@ -275,7 +281,7 @@ public class TileEntityHopper extends TileEntity implements IHopper {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
- this.setItem(j, itemstack);
|
|
|
|
+ this.setItem(j, itemstack1); // Spigot
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-19 01:22:44 +02:00
|
|
|
@@ -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
|
2014-03-23 01:06:43 +01:00
|
|
|
@@ -396,9 +402,9 @@ public class TileEntityHopper extends TileEntity implements IHopper {
|
2013-06-20 11:44:06 +02:00
|
|
|
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) {
|
2013-07-02 05:03:56 +02:00
|
|
|
- ((EntityMinecartHopper) ihopper).l(4); // Delay hopper minecart checks
|
2013-07-02 05:45:51 +02:00
|
|
|
+ ((EntityMinecartHopper) ihopper).l(ihopper.getWorld().spigotConfig.hopperTransfer / 2); // Spigot
|
2013-06-20 11:44:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2014-04-24 21:07:39 +02:00
|
|
|
@@ -416,7 +422,7 @@ public class TileEntityHopper extends TileEntity implements IHopper {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
- iinventory.setItem(i, itemstack1);
|
|
|
|
+ iinventory.setItem(i, itemstack2); // Spigot
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2014-03-23 01:06:43 +01:00
|
|
|
@@ -502,7 +508,7 @@ public class TileEntityHopper extends TileEntity implements IHopper {
|
2013-06-20 11:44:06 +02:00
|
|
|
|
|
|
|
if (flag) {
|
|
|
|
if (iinventory instanceof TileEntityHopper) {
|
|
|
|
- ((TileEntityHopper) iinventory).c(8);
|
|
|
|
+ ((TileEntityHopper) iinventory).c(((TileEntityHopper) iinventory).world.spigotConfig.hopperTransfer); // Spigot
|
2013-07-02 05:03:56 +02:00
|
|
|
iinventory.update();
|
2013-06-20 11:44:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
2014-04-19 01:22:44 +02:00
|
|
|
index 6421bf2..956c628 100644
|
2013-06-20 11:44:06 +02:00
|
|
|
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
|
|
|
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
2014-04-19 01:22:44 +02:00
|
|
|
@@ -164,4 +164,19 @@ public class SpigotWorldConfig
|
2014-02-17 13:19:44 +01:00
|
|
|
otherTrackingRange = getInt( "entity-tracking-range.other", otherTrackingRange );
|
|
|
|
log( "Entity Tracking Range: Pl " + playerTrackingRange + " / An " + animalTrackingRange + " / Mo " + monsterTrackingRange + " / Mi " + miscTrackingRange + " / Other " + otherTrackingRange );
|
2013-06-20 11:44:06 +02:00
|
|
|
}
|
|
|
|
+
|
2014-04-19 01:22:44 +02:00
|
|
|
+ public int hopperTransfer;
|
|
|
|
+ public int hopperCheck;
|
|
|
|
+ public int hopperAmount;
|
2013-06-20 11:44:06 +02:00
|
|
|
+ private void hoppers()
|
|
|
|
+ {
|
2013-09-09 06:40:16 +02:00
|
|
|
+ // Set the tick delay between hopper item movements
|
2014-04-19 01:22:44 +02:00
|
|
|
+ hopperTransfer = getInt( "ticks-per.hopper-transfer", 8 );
|
2013-09-09 06:40:16 +02:00
|
|
|
+ // 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 );
|
2014-04-19 01:22:44 +02:00
|
|
|
+ hopperAmount = getInt( "hopper-amount", 1 );
|
|
|
|
+ log( "Hopper Transfer: " + hopperTransfer + " Hopper Check: " + hopperCheck + " Hopper Amount: " + hopperAmount );
|
2013-06-20 11:44:06 +02:00
|
|
|
+ }
|
|
|
|
}
|
|
|
|
--
|
2014-04-19 01:15:23 +02:00
|
|
|
1.9.1
|
2013-06-20 11:44:06 +02:00
|
|
|
|