13
0
geforkt von Mirrors/Paper

Fix crash with juke boxes

By: md_5 <git@md-5.net>
Dieser Commit ist enthalten in:
CraftBukkit/Spigot 2023-03-15 18:14:15 +11:00
Ursprung 3ef3090e4a
Commit 28c4b7531f
2 geänderte Dateien mit 75 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -0,0 +1,68 @@
--- a/net/minecraft/world/level/block/entity/TileEntityJukeBox.java
+++ b/net/minecraft/world/level/block/entity/TileEntityJukeBox.java
@@ -24,6 +24,13 @@
import net.minecraft.world.phys.Vec3D;
import net.minecraft.world.ticks.ContainerSingleItem;
+// CraftBukkit start
+import java.util.List;
+import org.bukkit.Location;
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.entity.HumanEntity;
+// CraftBukkit end
+
public class TileEntityJukeBox extends TileEntity implements Clearable, ContainerSingleItem {
private static final int SONG_END_PADDING = 20;
@@ -32,6 +39,42 @@
private long tickCount;
private long recordStartedTick;
private boolean isPlaying;
+ // CraftBukkit start - add fields and methods
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
+ 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 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 TileEntityJukeBox(BlockPosition blockposition, IBlockData iblockdata) {
super(TileEntityTypes.JUKEBOX, blockposition, iblockdata);
@@ -150,7 +193,7 @@
@Override
public int getMaxStackSize() {
- return 1;
+ return maxStack; // CraftBukkit
}
@Override

Datei anzeigen

@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/block/entity/TileEntityLectern.java
+++ b/net/minecraft/world/level/block/entity/TileEntityLectern.java
@@ -25,13 +25,71 @@
@@ -25,13 +25,72 @@
import net.minecraft.world.phys.Vec2F;
import net.minecraft.world.phys.Vec3D;
@ -58,6 +58,7 @@
+
+ @Override
+ public Location getLocation() {
+ if (level == null) return null;
+ return new Location(level.getWorld(), worldPosition.getX(), worldPosition.getY(), worldPosition.getZ());
+ }
+
@ -74,7 +75,7 @@
@Override
public int getContainerSize() {
return 1;
@@ -76,11 +134,20 @@
@@ -76,11 +135,20 @@
}
@Override
@ -97,7 +98,7 @@
}
@Override
@@ -160,7 +227,7 @@
@@ -160,7 +228,7 @@
if (j != this.page) {
this.page = j;
this.setChanged();
@ -106,7 +107,7 @@
}
}
@@ -183,6 +250,32 @@
@@ -183,6 +251,32 @@
return itemstack;
}
@ -139,7 +140,7 @@
private CommandListenerWrapper createCommandSourceStack(@Nullable EntityHuman entityhuman) {
String s;
Object object;
@@ -197,7 +290,8 @@
@@ -197,7 +291,8 @@
Vec3D vec3d = Vec3D.atCenterOf(this.worldPosition);
@ -149,7 +150,7 @@
}
@Override
@@ -235,7 +329,7 @@
@@ -235,7 +330,7 @@
@Override
public Container createMenu(int i, PlayerInventory playerinventory, EntityHuman entityhuman) {