mirror of
https://hub.spigotmc.org/stash/scm/spigot/spigot.git
synced 2025-09-18 21:33:01 +00:00
SPIGOT-7835: Fix issue with custom hopper settings
(cherry picked from commit 34bd42b7a4
)
This commit is contained in:
parent
bb63b137f9
commit
f6a4805476
1 changed files with 42 additions and 10 deletions
|
@ -1,4 +1,4 @@
|
|||
From cba51e793ae9ed6e99200193e2bb801f2b1705f3 Mon Sep 17 00:00:00 2001
|
||||
From ae487f3dfac93a37099323d1eb744816edaca13d 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
|
||||
|
@ -6,7 +6,7 @@ Subject: [PATCH] Hopper Customisations
|
|||
Allows editing hopper cooldowns and amount transferred per tick.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/block/entity/TileEntityHopper.java b/src/main/java/net/minecraft/world/level/block/entity/TileEntityHopper.java
|
||||
index ec211057ab..af49ac5da9 100644
|
||||
index ec211057a..54781f84c 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/block/entity/TileEntityHopper.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/block/entity/TileEntityHopper.java
|
||||
@@ -148,9 +148,14 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper {
|
||||
|
@ -43,7 +43,7 @@ index ec211057ab..af49ac5da9 100644
|
|||
|
||||
Inventory destinationInventory;
|
||||
// Have to special case large chests as they work oddly
|
||||
@@ -231,7 +236,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper {
|
||||
@@ -231,9 +236,10 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper {
|
||||
world.getCraftServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
tileentityhopper.setItem(i, original);
|
||||
|
@ -51,8 +51,23 @@ index ec211057ab..af49ac5da9 100644
|
|||
+ tileentityhopper.setCooldown(world.spigotConfig.hopperTransfer); // Delay hopper checks // Spigot
|
||||
return false;
|
||||
}
|
||||
+ int origCount = event.getItem().getAmount(); // Spigot
|
||||
ItemStack itemstack1 = addItem(tileentityhopper, iinventory, CraftItemStack.asNMSCopy(event.getItem()), enumdirection);
|
||||
@@ -317,7 +322,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper {
|
||||
// CraftBukkit end
|
||||
|
||||
@@ -243,7 +249,10 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper {
|
||||
}
|
||||
|
||||
itemstack.setCount(j);
|
||||
- if (j == 1) {
|
||||
+ // Spigot start
|
||||
+ itemstack.shrink(origCount - itemstack1.getCount());
|
||||
+ if (j <= world.spigotConfig.hopperAmount) {
|
||||
+ // Spigot end
|
||||
tileentityhopper.setItem(i, itemstack);
|
||||
}
|
||||
}
|
||||
@@ -317,7 +326,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper {
|
||||
for (int j = 0; j < i; ++j) {
|
||||
int k = aint[j];
|
||||
|
||||
|
@ -61,7 +76,7 @@ index ec211057ab..af49ac5da9 100644
|
|||
return true;
|
||||
}
|
||||
}
|
||||
@@ -342,14 +347,14 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper {
|
||||
@@ -342,14 +351,14 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper {
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,7 +93,7 @@ index ec211057ab..af49ac5da9 100644
|
|||
|
||||
Inventory sourceInventory;
|
||||
// Have to special case large chests as they work oddly
|
||||
@@ -368,7 +373,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper {
|
||||
@@ -368,11 +377,12 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper {
|
||||
iinventory.setItem(i, original);
|
||||
|
||||
if (ihopper instanceof TileEntityHopper) {
|
||||
|
@ -87,7 +102,24 @@ index ec211057ab..af49ac5da9 100644
|
|||
}
|
||||
|
||||
return false;
|
||||
@@ -485,6 +490,11 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper {
|
||||
}
|
||||
+ int origCount = event.getItem().getAmount(); // Spigot
|
||||
ItemStack itemstack1 = addItem(iinventory, ihopper, CraftItemStack.asNMSCopy(event.getItem()), null);
|
||||
// CraftBukkit end
|
||||
|
||||
@@ -382,7 +392,10 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper {
|
||||
}
|
||||
|
||||
itemstack.setCount(j);
|
||||
- if (j == 1) {
|
||||
+ // Spigot start
|
||||
+ itemstack.shrink(origCount - itemstack1.getCount());
|
||||
+ if (j <= world.spigotConfig.hopperAmount) {
|
||||
+ // Spigot end
|
||||
iinventory.setItem(i, itemstack);
|
||||
}
|
||||
}
|
||||
@@ -485,6 +498,11 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper {
|
||||
boolean flag1 = iinventory1.isEmpty();
|
||||
|
||||
if (itemstack1.isEmpty()) {
|
||||
|
@ -99,7 +131,7 @@ index ec211057ab..af49ac5da9 100644
|
|||
iinventory1.setItem(i, itemstack);
|
||||
itemstack = ItemStack.EMPTY;
|
||||
flag = true;
|
||||
@@ -512,7 +522,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper {
|
||||
@@ -512,7 +530,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper {
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -108,7 +140,7 @@ index ec211057ab..af49ac5da9 100644
|
|||
}
|
||||
}
|
||||
|
||||
@@ -581,6 +591,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper {
|
||||
@@ -581,6 +599,7 @@ public class TileEntityHopper extends TileEntityLootable implements IHopper {
|
||||
|
||||
@Nullable
|
||||
private static IInventory getBlockContainer(World world, BlockPosition blockposition, IBlockData iblockdata) {
|
||||
|
@ -117,7 +149,7 @@ index ec211057ab..af49ac5da9 100644
|
|||
|
||||
if (block instanceof IInventoryHolder) {
|
||||
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
index ab984b2109..cec948a055 100644
|
||||
index ab984b210..cec948a05 100644
|
||||
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
|
||||
@@ -228,4 +228,22 @@ public class SpigotWorldConfig
|
||||
|
|
Loading…
Add table
Reference in a new issue