Archiviert
13
0
Dieses Repository wurde am 2024-12-25 archiviert. Du kannst Dateien ansehen und es klonen, aber nicht pushen oder Issues/Pull-Requests öffnen.
Paper-Old/nms-patches/TileEntityChest.patch

103 Zeilen
3.7 KiB
Diff

2015-02-26 23:41:06 +01:00
--- /home/matt/mc-dev-private//net/minecraft/server/TileEntityChest.java 2015-02-26 22:40:23.127608134 +0000
+++ src/main/java/net/minecraft/server/TileEntityChest.java 2015-02-26 22:40:23.127608134 +0000
@@ -3,6 +3,11 @@
import java.util.Iterator;
import java.util.List;
+// CraftBukkit start
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.entity.HumanEntity;
+// CraftBukkit end
+
public class TileEntityChest extends TileEntityContainer implements IUpdatePlayerListBox, IInventory {
private ItemStack[] items = new ItemStack[27];
2015-02-26 23:41:06 +01:00
@@ -20,6 +25,31 @@
public TileEntityChest() {}
2015-02-26 23:41:06 +01:00
+ // CraftBukkit start - add fields and methods
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
+ private int maxStack = MAX_STACK;
+
+ public ItemStack[] getContents() {
+ 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
+
public int getSize() {
return 27;
2015-02-26 23:41:06 +01:00
}
@@ -125,10 +155,11 @@
}
public int getMaxStackSize() {
- return 64;
+ return maxStack; // CraftBukkit
}
public boolean a(EntityHuman entityhuman) {
+ if (this.world == null) return true; // CraftBukkit
return this.world.getTileEntity(this.position) != this ? false : entityhuman.e((double) this.position.getX() + 0.5D, (double) this.position.getY() + 0.5D, (double) this.position.getZ() + 0.5D) <= 64.0D;
}
2015-02-26 23:41:06 +01:00
@@ -304,9 +335,21 @@
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
this.world.playBlockAction(this.position, this.w(), 1, this.l);
+
+ // CraftBukkit start - Call redstone event
+ if (this.w() == Blocks.TRAPPED_CHEST) {
+ 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
this.world.applyPhysics(this.position, this.w());
this.world.applyPhysics(this.position.down(), this.w());
}
2015-02-26 23:41:06 +01:00
@@ -315,8 +358,20 @@
public void closeContainer(EntityHuman entityhuman) {
if (!entityhuman.v() && this.w() instanceof BlockChest) {
+ 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
this.world.playBlockAction(this.position, this.w(), 1, this.l);
2015-02-26 23:41:06 +01:00
+
+ // CraftBukkit start - Call redstone event
+ if (this.w() == Blocks.TRAPPED_CHEST) {
+ 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
this.world.applyPhysics(this.position, this.w());
this.world.applyPhysics(this.position.down(), this.w());
}