0
0
mirror of https://hub.spigotmc.org/stash/scm/spigot/craftbukkit.git synced 2024-11-22 14:46:16 +00:00
craftbukkit/nms-patches/net/minecraft/world/level/block/entity/CrafterBlockEntity.patch
2024-04-24 01:15:00 +10:00

70 lines
2.2 KiB
Diff

--- a/net/minecraft/world/level/block/entity/CrafterBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/CrafterBlockEntity.java
@@ -23,6 +23,12 @@
import net.minecraft.world.level.block.CrafterBlock;
import net.minecraft.world.level.block.state.IBlockData;
+// CraftBukkit start
+import org.bukkit.Location;
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.entity.HumanEntity;
+// CraftBukkit end
+
public class CrafterBlockEntity extends TileEntityLootable implements InventoryCrafting {
public static final int CONTAINER_WIDTH = 3;
@@ -35,12 +41,52 @@
private NonNullList<ItemStack> items;
public int craftingTicksRemaining;
protected final IContainerProperties containerData;
+ // CraftBukkit start - add fields and methods
+ public List<HumanEntity> transaction = new java.util.ArrayList<>();
+ private int maxStack = MAX_STACK;
+
+ @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 size) {
+ maxStack = size;
+ }
+
+ @Override
+ public Location getLocation() {
+ if (level == null) return null;
+ return new org.bukkit.Location(level.getWorld(), worldPosition.getX(), worldPosition.getY(), worldPosition.getZ());
+ }
+ // CraftBukkit end
public CrafterBlockEntity(BlockPosition blockposition, IBlockData iblockdata) {
super(TileEntityTypes.CRAFTER, blockposition, iblockdata);
this.items = NonNullList.withSize(9, ItemStack.EMPTY);
this.craftingTicksRemaining = 0;
- this.containerData = new IContainerProperties(this) {
+ this.containerData = new IContainerProperties() { // CraftBukkit - decompile error
private final int[] slotStates = new int[9];
private int triggered = 0;