2015-05-25 12:37:24 +02:00
|
|
|
--- a/net/minecraft/server/TileEntityChest.java
|
|
|
|
+++ b/net/minecraft/server/TileEntityChest.java
|
2016-11-17 02:41:03 +01:00
|
|
|
@@ -3,6 +3,10 @@
|
|
|
|
import java.util.Iterator;
|
2014-11-25 22:32:16 +01:00
|
|
|
import java.util.List;
|
2016-05-10 13:47:39 +02:00
|
|
|
import javax.annotation.Nullable;
|
2014-11-25 22:32:16 +01:00
|
|
|
+// CraftBukkit start
|
|
|
|
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
|
|
|
+import org.bukkit.entity.HumanEntity;
|
|
|
|
+// CraftBukkit end
|
|
|
|
|
2016-11-17 02:41:03 +01:00
|
|
|
public class TileEntityChest extends TileEntityLootable implements ITickable {
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2016-11-17 02:41:03 +01:00
|
|
|
@@ -18,6 +22,31 @@
|
|
|
|
private int q;
|
|
|
|
private BlockChest.Type r;
|
2015-02-26 23:41:06 +01:00
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start - add fields and methods
|
|
|
|
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
|
|
|
|
+ private int maxStack = MAX_STACK;
|
|
|
|
+
|
2016-11-17 02:41:03 +01:00
|
|
|
+ public List<ItemStack> getContents() {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ return this.items;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void onOpen(CraftHumanEntity who) {
|
|
|
|
+ transaction.add(who);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void onClose(CraftHumanEntity who) {
|
|
|
|
+ transaction.remove(who);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public List<HumanEntity> getViewers() {
|
|
|
|
+ return transaction;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setMaxStackSize(int size) {
|
|
|
|
+ maxStack = size;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2016-11-17 02:41:03 +01:00
|
|
|
public TileEntityChest() {
|
|
|
|
this.items = NonNullList.a(27, ItemStack.a);
|
2015-02-26 23:41:06 +01:00
|
|
|
}
|
2016-11-17 02:41:03 +01:00
|
|
|
@@ -82,7 +111,7 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public int getMaxStackSize() {
|
|
|
|
- return 64;
|
|
|
|
+ return maxStack; // CraftBukkit
|
|
|
|
}
|
|
|
|
|
2016-11-17 02:41:03 +01:00
|
|
|
public void invalidateBlockCache() {
|
|
|
|
@@ -258,9 +287,21 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
if (this.l < 0) {
|
|
|
|
this.l = 0;
|
|
|
|
}
|
|
|
|
+ int oldPower = Math.max(0, Math.min(15, this.l)); // CraftBukkit - Get power before new viewer is added
|
|
|
|
|
|
|
|
++this.l;
|
|
|
|
+ if (this.world == null) return; // CraftBukkit
|
2016-02-29 22:32:46 +01:00
|
|
|
this.world.playBlockAction(this.position, this.getBlock(), 1, this.l);
|
2014-11-25 22:32:16 +01:00
|
|
|
+
|
|
|
|
+ // CraftBukkit start - Call redstone event
|
2016-02-29 22:32:46 +01:00
|
|
|
+ if (this.getBlock() == Blocks.TRAPPED_CHEST) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ int newPower = Math.max(0, Math.min(15, this.l));
|
|
|
|
+
|
|
|
|
+ if (oldPower != newPower) {
|
|
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(world, position.getX(), position.getY(), position.getZ(), oldPower, newPower);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2016-11-17 02:41:03 +01:00
|
|
|
this.world.applyPhysics(this.position, this.getBlock(), false);
|
|
|
|
if (this.p() == BlockChest.Type.TRAP) {
|
|
|
|
this.world.applyPhysics(this.position.down(), this.getBlock(), false);
|
|
|
|
@@ -271,12 +312,21 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
public void closeContainer(EntityHuman entityhuman) {
|
2016-02-29 22:32:46 +01:00
|
|
|
if (!entityhuman.isSpectator() && this.getBlock() instanceof BlockChest) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ int oldPower = Math.max(0, Math.min(15, this.l)); // CraftBukkit - Get power before new viewer is added
|
|
|
|
--this.l;
|
2016-02-29 22:32:46 +01:00
|
|
|
this.world.playBlockAction(this.position, this.getBlock(), 1, this.l);
|
2016-11-17 02:41:03 +01:00
|
|
|
this.world.applyPhysics(this.position, this.getBlock(), false);
|
2015-02-26 23:41:06 +01:00
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start - Call redstone event
|
2016-11-17 02:41:03 +01:00
|
|
|
if (this.p() == BlockChest.Type.TRAP) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ int newPower = Math.max(0, Math.min(15, this.l));
|
|
|
|
+
|
|
|
|
+ if (oldPower != newPower) {
|
|
|
|
+ org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(world, position.getX(), position.getY(), position.getZ(), oldPower, newPower);
|
|
|
|
+ }
|
2016-11-17 02:41:03 +01:00
|
|
|
this.world.applyPhysics(this.position.down(), this.getBlock(), false);
|
|
|
|
}
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
2016-03-30 21:50:59 +02:00
|
|
|
|
2015-06-12 07:30:12 +02:00
|
|
|
}
|
2016-11-17 02:41:03 +01:00
|
|
|
@@ -311,4 +361,11 @@
|
|
|
|
protected NonNullList<ItemStack> q() {
|
|
|
|
return this.items;
|
|
|
|
}
|
|
|
|
+
|
2015-06-12 07:30:12 +02:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ @Override
|
2016-02-29 22:32:46 +01:00
|
|
|
+ public boolean isFilteredNBT() {
|
2015-06-12 07:30:12 +02:00
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2016-11-17 02:41:03 +01:00
|
|
|
}
|