mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-02 04:56:50 +01:00
Fix hoppers replacing the items with the left overs from removing instead taking the items off the stack
This commit is contained in:
parent
3139af91dc
commit
c3eeab45cd
2 changed files with 27 additions and 18 deletions
|
@ -1,4 +1,4 @@
|
||||||
From 0467adc477c07485d63c96122b135c5b4ab5602b Mon Sep 17 00:00:00 2001
|
From 331a947c4c7512a3f2ee370832717fe9229ed725 Mon Sep 17 00:00:00 2001
|
||||||
From: erocs <github@erocs.org>
|
From: erocs <github@erocs.org>
|
||||||
Date: Sun, 8 Sep 2013 12:06:15 -0700
|
Date: Sun, 8 Sep 2013 12:06:15 -0700
|
||||||
Subject: [PATCH] Hopper Customisations
|
Subject: [PATCH] Hopper Customisations
|
||||||
|
@ -6,7 +6,7 @@ Subject: [PATCH] Hopper Customisations
|
||||||
Allows editing hopper cooldowns and amount transferred per tick.
|
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
|
diff --git a/src/main/java/net/minecraft/server/TileEntityHopper.java b/src/main/java/net/minecraft/server/TileEntityHopper.java
|
||||||
index 48a882a..ba015aa 100644
|
index 48a882a..51cbdad 100644
|
||||||
--- a/src/main/java/net/minecraft/server/TileEntityHopper.java
|
--- a/src/main/java/net/minecraft/server/TileEntityHopper.java
|
||||||
+++ b/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 {
|
@@ -189,12 +189,18 @@ public class TileEntityHopper extends TileEntity implements IHopper {
|
||||||
|
@ -38,7 +38,7 @@ index 48a882a..ba015aa 100644
|
||||||
|
|
||||||
Inventory destinationInventory;
|
Inventory destinationInventory;
|
||||||
// Have to special case large chests as they work oddly
|
// Have to special case large chests as they work oddly
|
||||||
@@ -260,7 +266,7 @@ public class TileEntityHopper extends TileEntity implements IHopper {
|
@@ -260,11 +266,11 @@ public class TileEntityHopper extends TileEntity implements IHopper {
|
||||||
this.getWorld().getServer().getPluginManager().callEvent(event);
|
this.getWorld().getServer().getPluginManager().callEvent(event);
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
this.setItem(j, itemstack);
|
this.setItem(j, itemstack);
|
||||||
|
@ -46,16 +46,21 @@ index 48a882a..ba015aa 100644
|
||||||
+ this.c(world.spigotConfig.hopperTransfer); // Spigot
|
+ this.c(world.spigotConfig.hopperTransfer); // Spigot
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
+ int origCount = event.getItem().getAmount(); // Spigot
|
||||||
ItemStack itemstack1 = addItem(iinventory, CraftItemStack.asNMSCopy(event.getItem()), i);
|
ItemStack itemstack1 = addItem(iinventory, CraftItemStack.asNMSCopy(event.getItem()), i);
|
||||||
@@ -275,7 +281,7 @@ public class TileEntityHopper extends TileEntity implements IHopper {
|
-
|
||||||
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
-
|
||||||
- this.setItem(j, itemstack);
|
+ itemstack.count -= origCount - itemstack1.count; // Spigot
|
||||||
+ this.setItem(j, itemstack1); // Spigot
|
this.setItem(j, itemstack);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -379,7 +385,7 @@ public class TileEntityHopper extends TileEntity implements IHopper {
|
@@ -379,7 +385,7 @@ public class TileEntityHopper extends TileEntity implements IHopper {
|
||||||
if (itemstack != null && canTakeItemFromInventory(iinventory, itemstack, i, j)) {
|
if (itemstack != null && canTakeItemFromInventory(iinventory, itemstack, i, j)) {
|
||||||
ItemStack itemstack1 = itemstack.cloneItemStack();
|
ItemStack itemstack1 = itemstack.cloneItemStack();
|
||||||
|
@ -65,7 +70,7 @@ index 48a882a..ba015aa 100644
|
||||||
|
|
||||||
Inventory sourceInventory;
|
Inventory sourceInventory;
|
||||||
// Have to special case large chests as they work oddly
|
// Have to special case large chests as they work oddly
|
||||||
@@ -396,9 +402,9 @@ public class TileEntityHopper extends TileEntity implements IHopper {
|
@@ -396,13 +402,14 @@ public class TileEntityHopper extends TileEntity implements IHopper {
|
||||||
iinventory.setItem(i, itemstack1);
|
iinventory.setItem(i, itemstack1);
|
||||||
|
|
||||||
if (ihopper instanceof TileEntityHopper) {
|
if (ihopper instanceof TileEntityHopper) {
|
||||||
|
@ -77,16 +82,20 @@ index 48a882a..ba015aa 100644
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -416,7 +422,7 @@ public class TileEntityHopper extends TileEntity implements IHopper {
|
}
|
||||||
|
+ 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;
|
return true;
|
||||||
}
|
}
|
||||||
|
+ itemstack1.count -= origCount - itemstack2.count; // Spigot
|
||||||
|
|
||||||
- iinventory.setItem(i, itemstack1);
|
iinventory.setItem(i, itemstack1);
|
||||||
+ iinventory.setItem(i, itemstack2); // Spigot
|
|
||||||
}
|
}
|
||||||
|
@@ -502,7 +510,7 @@ public class TileEntityHopper extends TileEntity implements IHopper {
|
||||||
return false;
|
|
||||||
@@ -502,7 +508,7 @@ public class TileEntityHopper extends TileEntity implements IHopper {
|
|
||||||
|
|
||||||
if (flag) {
|
if (flag) {
|
||||||
if (iinventory instanceof TileEntityHopper) {
|
if (iinventory instanceof TileEntityHopper) {
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
From 71c7e576a8b091ad66e1b6991b9a483440e71ee3 Mon Sep 17 00:00:00 2001
|
From 71f6a24e3236699189ff43b1bd0918491969c900 Mon Sep 17 00:00:00 2001
|
||||||
From: Thinkofdeath <thethinkofdeath@gmail.com>
|
From: Thinkofdeath <thethinkofdeath@gmail.com>
|
||||||
Date: Wed, 5 Mar 2014 20:27:27 +0000
|
Date: Wed, 5 Mar 2014 20:27:27 +0000
|
||||||
Subject: [PATCH] Prevent hoppers from loading chunks
|
Subject: [PATCH] Prevent hoppers from loading chunks
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/server/TileEntityHopper.java b/src/main/java/net/minecraft/server/TileEntityHopper.java
|
diff --git a/src/main/java/net/minecraft/server/TileEntityHopper.java b/src/main/java/net/minecraft/server/TileEntityHopper.java
|
||||||
index e661462..9445139 100644
|
index 51cbdad..b620394 100644
|
||||||
--- a/src/main/java/net/minecraft/server/TileEntityHopper.java
|
--- a/src/main/java/net/minecraft/server/TileEntityHopper.java
|
||||||
+++ b/src/main/java/net/minecraft/server/TileEntityHopper.java
|
+++ b/src/main/java/net/minecraft/server/TileEntityHopper.java
|
||||||
@@ -540,6 +540,7 @@ public class TileEntityHopper extends TileEntity implements IHopper {
|
@@ -542,6 +542,7 @@ public class TileEntityHopper extends TileEntity implements IHopper {
|
||||||
int i = MathHelper.floor(d0);
|
int i = MathHelper.floor(d0);
|
||||||
int j = MathHelper.floor(d1);
|
int j = MathHelper.floor(d1);
|
||||||
int k = MathHelper.floor(d2);
|
int k = MathHelper.floor(d2);
|
||||||
|
|
Loading…
Reference in a new issue