mirror of
https://hub.spigotmc.org/stash/scm/spigot/spigot.git
synced 2025-08-05 16:48:51 +00:00
136 lines
6.9 KiB
Diff
136 lines
6.9 KiB
Diff
From b33f8ab466abe47e79a3601c35bf5ac9f55d8baa Mon Sep 17 00:00:00 2001
|
|
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
|
|
index 4339d74c3..d0d271475 100644
|
|
--- a/src/main/java/net/minecraft/server/TileEntityHopper.java
|
|
+++ b/src/main/java/net/minecraft/server/TileEntityHopper.java
|
|
@@ -115,9 +115,14 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
|
this.j = this.world.getTime();
|
|
if (!this.E()) {
|
|
this.setCooldown(0);
|
|
- this.a(() -> {
|
|
+ // Spigot start
|
|
+ boolean result = this.a(() -> {
|
|
return Boolean.valueOf(a((IHopper) this));
|
|
});
|
|
+ if (!result && this.world.spigotConfig.hopperCheck > 1) {
|
|
+ this.setCooldown(this.world.spigotConfig.hopperCheck);
|
|
+ }
|
|
+ // Spigot end
|
|
}
|
|
|
|
}
|
|
@@ -137,7 +142,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
|
}
|
|
|
|
if (flag) {
|
|
- this.setCooldown(8);
|
|
+ this.setCooldown(world.spigotConfig.hopperTransfer); // Spigot
|
|
this.update();
|
|
return true;
|
|
}
|
|
@@ -202,7 +207,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
|
// ItemStack itemstack1 = addItem(this, iinventory, this.splitStack(i, 1), enumdirection);
|
|
|
|
// CraftBukkit start - Call event when pushing items into other inventories
|
|
- CraftItemStack oitemstack = CraftItemStack.asCraftMirror(this.splitStack(i, 1));
|
|
+ CraftItemStack oitemstack = CraftItemStack.asCraftMirror(this.splitStack(i, world.spigotConfig.hopperAmount)); // Spigot
|
|
|
|
Inventory destinationInventory;
|
|
// Have to special case large chests as they work oddly
|
|
@@ -216,9 +221,10 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
|
this.getWorld().getServer().getPluginManager().callEvent(event);
|
|
if (event.isCancelled()) {
|
|
this.setItem(i, itemstack);
|
|
- this.setCooldown(8); // Delay hopper checks
|
|
+ this.setCooldown(world.spigotConfig.hopperTransfer); // Spigot
|
|
return false;
|
|
}
|
|
+ int origCount = event.getItem().getAmount(); // Spigot
|
|
ItemStack itemstack1 = addItem(this, iinventory, CraftItemStack.asNMSCopy(event.getItem()), enumdirection);
|
|
|
|
if (itemstack1.isEmpty()) {
|
|
@@ -231,6 +237,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
|
return true;
|
|
}
|
|
|
|
+ itemstack.subtract(origCount - itemstack1.getCount()); // Spigot
|
|
this.setItem(i, itemstack);
|
|
}
|
|
}
|
|
@@ -351,7 +358,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
|
ItemStack itemstack1 = itemstack.cloneItemStack();
|
|
// ItemStack itemstack2 = addItem(iinventory, ihopper, iinventory.splitStack(i, 1), (EnumDirection) null);
|
|
// 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
|
|
@@ -368,13 +375,13 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
|
iinventory.setItem(i, itemstack1);
|
|
|
|
if (ihopper instanceof TileEntityHopper) {
|
|
- ((TileEntityHopper) ihopper).setCooldown(8); // Delay hopper checks
|
|
+ ((TileEntityHopper) ihopper).setCooldown(ihopper.getWorld().spigotConfig.hopperTransfer); // Spigot
|
|
} else if (ihopper instanceof EntityMinecartHopper) {
|
|
- ((EntityMinecartHopper) ihopper).setCooldown(4); // Delay hopper minecart checks
|
|
+ ((EntityMinecartHopper) ihopper).setCooldown(ihopper.getWorld().spigotConfig.hopperTransfer / 2); // Spigot
|
|
}
|
|
-
|
|
return false;
|
|
}
|
|
+ int origCount = event.getItem().getAmount(); // Spigot
|
|
ItemStack itemstack2 = addItem(iinventory, ihopper, CraftItemStack.asNMSCopy(event.getItem()), null);
|
|
|
|
if (itemstack2.isEmpty()) {
|
|
@@ -387,6 +394,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
|
return true;
|
|
}
|
|
|
|
+ itemstack1.subtract(origCount - itemstack2.getCount()); // Spigot
|
|
iinventory.setItem(i, itemstack1);
|
|
}
|
|
|
|
@@ -477,7 +485,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper, ITi
|
|
}
|
|
}
|
|
|
|
- tileentityhopper.setCooldown(8 - b0);
|
|
+ tileentityhopper.setCooldown(tileentityhopper.world.spigotConfig.hopperTransfer - b0); // Spigot
|
|
}
|
|
}
|
|
|
|
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
|
index b23936889..cc173cb3e 100644
|
|
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
|
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
|
@@ -168,4 +168,20 @@ 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 );
|
|
+ if ( SpigotConfig.version < 11 )
|
|
+ {
|
|
+ set( "ticks-per.hopper-check", 1 );
|
|
+ }
|
|
+ hopperCheck = getInt( "ticks-per.hopper-check", 1 );
|
|
+ hopperAmount = getInt( "hopper-amount", 1 );
|
|
+ log( "Hopper Transfer: " + hopperTransfer + " Hopper Check: " + hopperCheck + " Hopper Amount: " + hopperAmount );
|
|
+ }
|
|
}
|
|
--
|
|
2.17.1
|
|
|