3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-18 20:40:08 +01:00
Paper/nms-patches/TileEntityBarrel.patch
2020-07-29 19:41:00 +10:00

82 Zeilen
2.6 KiB
Diff

--- a/net/minecraft/server/TileEntityBarrel.java
+++ b/net/minecraft/server/TileEntityBarrel.java
@@ -1,7 +1,55 @@
package net.minecraft.server;
+// CraftBukkit start
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import org.bukkit.Location;
+import org.bukkit.block.Barrel;
+import org.bukkit.block.Lectern;
+import org.bukkit.craftbukkit.block.CraftBlock;
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.entity.HumanEntity;
+import org.bukkit.inventory.InventoryHolder;
+// CraftBukkit end
+
public class TileEntityBarrel extends TileEntityLootable {
+ // CraftBukkit start - add fields and methods
+ public List<HumanEntity> transaction = new ArrayList<>();
+ private int maxStack = MAX_STACK;
+ public boolean opened;
+
+ @Override
+ public List<ItemStack> getContents() {
+ return this.items;
+ }
+
+ @Override
+ public void onOpen(CraftHumanEntity who) {
+ transaction.add(who);
+ }
+
+ @Override
+ public void onClose(CraftHumanEntity who) {
+ transaction.remove(who);
+ }
+
+ @Override
+ public List<HumanEntity> getViewers() {
+ return transaction;
+ }
+
+ @Override
+ public int getMaxStackSize() {
+ return maxStack;
+ }
+
+ @Override
+ public void setMaxStackSize(int i) {
+ maxStack = i;
+ }
+ // CraftBukkit end
private NonNullList<ItemStack> items;
private int b;
@@ -100,7 +148,7 @@
return;
}
- boolean flag = (Boolean) iblockdata.get(BlockBarrel.b);
+ boolean flag = (Boolean) iblockdata.get(BlockBarrel.b) && !opened; // CraftBukkit - only set flag if Barrel isn't set open by API.
if (flag) {
this.a(iblockdata, SoundEffects.BLOCK_BARREL_CLOSE);
@@ -118,11 +166,11 @@
}
- private void a(IBlockData iblockdata, boolean flag) {
+ public void a(IBlockData iblockdata, boolean flag) { // PAIL private -> public, rename setFlag
this.world.setTypeAndData(this.getPosition(), (IBlockData) iblockdata.set(BlockBarrel.b, flag), 3);
}
- private void a(IBlockData iblockdata, SoundEffect soundeffect) {
+ public void a(IBlockData iblockdata, SoundEffect soundeffect) { // PAIL private -> public, rename playSound
BaseBlockPosition baseblockposition = ((EnumDirection) iblockdata.get(BlockBarrel.a)).p();
double d0 = (double) this.position.getX() + 0.5D + (double) baseblockposition.getX() / 2.0D;
double d1 = (double) this.position.getY() + 0.5D + (double) baseblockposition.getY() / 2.0D;