SPIGOT-7534: Error when chunk with decorated pot trying to save

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot 2023-12-07 08:37:37 +11:00
parent bf7ca9b824
commit 64145dd66d

View file

@ -0,0 +1,61 @@
--- a/net/minecraft/world/level/block/entity/DecoratedPotBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/DecoratedPotBlockEntity.java
@@ -21,7 +21,58 @@
import net.minecraft.world.level.block.state.properties.BlockProperties;
import net.minecraft.world.ticks.ContainerSingleItem;
+// CraftBukkit start
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import org.bukkit.Location;
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.craftbukkit.util.CraftLocation;
+import org.bukkit.entity.HumanEntity;
+// CraftBukkit end
+
public class DecoratedPotBlockEntity extends TileEntity implements RandomizableContainer, ContainerSingleItem {
+
+ // CraftBukkit start - add fields and methods
+ public List<HumanEntity> transaction = new ArrayList<>();
+ private int maxStack = MAX_STACK;
+
+ @Override
+ public List<ItemStack> getContents() {
+ return Arrays.asList(this.item);
+ }
+
+ @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;
+ }
+
+ @Override
+ public Location getLocation() {
+ if (level == null) return null;
+ return CraftLocation.toBukkit(worldPosition, level.getWorld());
+ }
+ // CraftBukkit end
public static final String TAG_SHERDS = "sherds";
public static final String TAG_ITEM = "item";