mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-05 10:20:53 +01:00
111 lines
3.6 KiB
Diff
111 lines
3.6 KiB
Diff
--- a/net/minecraft/server/TileEntityChest.java
|
|
+++ b/net/minecraft/server/TileEntityChest.java
|
|
@@ -3,6 +3,10 @@
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import javax.annotation.Nullable;
|
|
+// CraftBukkit start
|
|
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
|
+import org.bukkit.entity.HumanEntity;
|
|
+// CraftBukkit end
|
|
|
|
public class TileEntityChest extends TileEntityLootable implements ITickable {
|
|
|
|
@@ -18,6 +22,31 @@
|
|
private int q;
|
|
private BlockChest.Type r;
|
|
|
|
+ // CraftBukkit start - add fields and methods
|
|
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
|
|
+ private int maxStack = MAX_STACK;
|
|
+
|
|
+ public List<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
|
|
+
|
|
public TileEntityChest() {
|
|
this.items = NonNullList.a(27, ItemStack.a);
|
|
}
|
|
@@ -82,7 +111,7 @@
|
|
}
|
|
|
|
public int getMaxStackSize() {
|
|
- return 64;
|
|
+ return maxStack; // CraftBukkit
|
|
}
|
|
|
|
public void invalidateBlockCache() {
|
|
@@ -258,9 +287,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.getBlock(), 1, this.l);
|
|
+
|
|
+ // CraftBukkit start - Call redstone event
|
|
+ if (this.getBlock() == 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.getBlock(), false);
|
|
if (this.p() == BlockChest.Type.TRAP) {
|
|
this.world.applyPhysics(this.position.down(), this.getBlock(), false);
|
|
@@ -271,12 +312,21 @@
|
|
|
|
public void closeContainer(EntityHuman entityhuman) {
|
|
if (!entityhuman.isSpectator() && this.getBlock() instanceof BlockChest) {
|
|
+ int oldPower = Math.max(0, Math.min(15, this.l)); // CraftBukkit - Get power before new viewer is added
|
|
--this.l;
|
|
this.world.playBlockAction(this.position, this.getBlock(), 1, this.l);
|
|
this.world.applyPhysics(this.position, this.getBlock(), false);
|
|
+
|
|
+ // CraftBukkit start - Call redstone event
|
|
if (this.p() == BlockChest.Type.TRAP) {
|
|
+ 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);
|
|
+ }
|
|
this.world.applyPhysics(this.position.down(), this.getBlock(), false);
|
|
}
|
|
+ // CraftBukkit end
|
|
}
|
|
|
|
}
|
|
@@ -311,4 +361,11 @@
|
|
protected NonNullList<ItemStack> q() {
|
|
return this.items;
|
|
}
|
|
+
|
|
+ // CraftBukkit start
|
|
+ @Override
|
|
+ public boolean isFilteredNBT() {
|
|
+ return true;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
}
|