mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 23:38:25 +01:00
Do not allow null in CanPlaceDestroy NBT API
Fixes GH-1523
This commit is contained in:
parent
4899a1eb93
commit
ecde88a5f5
3 changed files with 54 additions and 21 deletions
|
@ -5,7 +5,7 @@ Subject: [PATCH] Implement an API for CanPlaceOn and CanDestroy NBT values
|
|||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
index 55afe8382c..d928119254 100644
|
||||
index 55afe8382c..598ad807a2 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
@@ -0,0 +0,0 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable {
|
||||
|
@ -52,6 +52,10 @@ index 55afe8382c..d928119254 100644
|
|||
+ NBTTagList list = tag.getList(CAN_DESTROY.NBT, CraftMagicNumbers.NBT.TAG_STRING);
|
||||
+ for (int i = 0; i < list.size(); i++) {
|
||||
+ Material material = Material.matchMaterial(list.getString(i), false);
|
||||
+ if (material == null) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ this.canDestroy.add(material);
|
||||
+ }
|
||||
+ }
|
||||
|
@ -60,6 +64,10 @@ index 55afe8382c..d928119254 100644
|
|||
+ NBTTagList list = tag.getList(CAN_PLACE_ON.NBT, CraftMagicNumbers.NBT.TAG_STRING);
|
||||
+ for (int i = 0; i < list.size(); i++) {
|
||||
+ Material material = Material.matchMaterial(list.getString(i), false);
|
||||
+ if (material == null) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ this.canPlaceOn.add(material);
|
||||
+ }
|
||||
+ }
|
||||
|
|
|
@ -390,6 +390,19 @@ index 5b54cbde18..769d599c59 100644
|
|||
}
|
||||
+ */ // Paper end - Decompile fix
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/PacketEncoder.java b/src/main/java/net/minecraft/server/PacketEncoder.java
|
||||
index 113e8780a8..8e312c7617 100644
|
||||
--- a/src/main/java/net/minecraft/server/PacketEncoder.java
|
||||
+++ b/src/main/java/net/minecraft/server/PacketEncoder.java
|
||||
@@ -0,0 +0,0 @@ public class PacketEncoder extends MessageToByteEncoder<Packet<?>> {
|
||||
}
|
||||
|
||||
// $FF: synthetic method
|
||||
- protected void encode(ChannelHandlerContext channelhandlercontext, Object object, ByteBuf bytebuf) throws Exception {
|
||||
+ protected void encode(ChannelHandlerContext channelhandlercontext, Packet<?> object, ByteBuf bytebuf) throws Exception { // Paper - decompiler fix
|
||||
this.a(channelhandlercontext, (Packet)object, bytebuf);
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/Registry.java b/src/main/java/net/minecraft/server/Registry.java
|
||||
index 5be9f0ff2f..9efec49d66 100644
|
||||
--- a/src/main/java/net/minecraft/server/Registry.java
|
||||
|
|
|
@ -5,7 +5,7 @@ Subject: [PATCH] MC Utils
|
|||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/BlockPosition.java b/src/main/java/net/minecraft/server/BlockPosition.java
|
||||
index 6ffc53514..5ed34cf7e 100644
|
||||
index 6ffc535146..5ed34cf7e3 100644
|
||||
--- a/src/main/java/net/minecraft/server/BlockPosition.java
|
||||
+++ b/src/main/java/net/minecraft/server/BlockPosition.java
|
||||
@@ -0,0 +0,0 @@ import org.apache.logging.log4j.Logger;
|
||||
|
@ -42,7 +42,7 @@ index 6ffc53514..5ed34cf7e 100644
|
|||
return this.c(MathHelper.floor(d0), MathHelper.floor(d1), MathHelper.floor(d2));
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index fe5328ef4..b7c40d5ce 100644
|
||||
index bc5e4a654a..d3eac35e4d 100644
|
||||
--- a/src/main/java/net/minecraft/server/Chunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
||||
@@ -0,0 +0,0 @@ import com.google.common.collect.Lists; // CraftBukkit
|
||||
|
@ -63,7 +63,7 @@ index fe5328ef4..b7c40d5ce 100644
|
|||
public TileEntity a(BlockPosition blockposition, Chunk.EnumTileEntityState chunk_enumtileentitystate) {
|
||||
// CraftBukkit start
|
||||
diff --git a/src/main/java/net/minecraft/server/ChunkCoordIntPair.java b/src/main/java/net/minecraft/server/ChunkCoordIntPair.java
|
||||
index 744762b8b..d9608121b 100644
|
||||
index 744762b8b9..d9608121b6 100644
|
||||
--- a/src/main/java/net/minecraft/server/ChunkCoordIntPair.java
|
||||
+++ b/src/main/java/net/minecraft/server/ChunkCoordIntPair.java
|
||||
@@ -0,0 +0,0 @@ public class ChunkCoordIntPair {
|
||||
|
@ -76,7 +76,7 @@ index 744762b8b..d9608121b 100644
|
|||
return (long)i & 4294967295L | ((long)j & 4294967295L) << 32;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/ChunkTaskScheduler.java b/src/main/java/net/minecraft/server/ChunkTaskScheduler.java
|
||||
index 3b6b3b9a9..22af9c188 100644
|
||||
index 3b6b3b9a99..22af9c1885 100644
|
||||
--- a/src/main/java/net/minecraft/server/ChunkTaskScheduler.java
|
||||
+++ b/src/main/java/net/minecraft/server/ChunkTaskScheduler.java
|
||||
@@ -0,0 +0,0 @@ import org.apache.logging.log4j.Logger;
|
||||
|
@ -89,7 +89,7 @@ index 3b6b3b9a9..22af9c188 100644
|
|||
private final IChunkLoader e;
|
||||
private final IAsyncTaskHandler f;
|
||||
diff --git a/src/main/java/net/minecraft/server/DataBits.java b/src/main/java/net/minecraft/server/DataBits.java
|
||||
index 95ca5f6d8..0dc948a37 100644
|
||||
index 95ca5f6d80..0dc948a375 100644
|
||||
--- a/src/main/java/net/minecraft/server/DataBits.java
|
||||
+++ b/src/main/java/net/minecraft/server/DataBits.java
|
||||
@@ -0,0 +0,0 @@ public class DataBits {
|
||||
|
@ -101,7 +101,7 @@ index 95ca5f6d8..0dc948a37 100644
|
|||
return this.a;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/DataPalette.java b/src/main/java/net/minecraft/server/DataPalette.java
|
||||
index 7f905b1e0..fa5b9262b 100644
|
||||
index 7f905b1e09..fa5b9262b4 100644
|
||||
--- a/src/main/java/net/minecraft/server/DataPalette.java
|
||||
+++ b/src/main/java/net/minecraft/server/DataPalette.java
|
||||
@@ -0,0 +0,0 @@ package net.minecraft.server;
|
||||
|
@ -119,7 +119,7 @@ index 7f905b1e0..fa5b9262b 100644
|
|||
void b(PacketDataSerializer var1);
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/DataPaletteBlock.java b/src/main/java/net/minecraft/server/DataPaletteBlock.java
|
||||
index 304e47bf2..6e7454b13 100644
|
||||
index 304e47bf20..6e7454b134 100644
|
||||
--- a/src/main/java/net/minecraft/server/DataPaletteBlock.java
|
||||
+++ b/src/main/java/net/minecraft/server/DataPaletteBlock.java
|
||||
@@ -0,0 +0,0 @@ import java.util.function.Function;
|
||||
|
@ -161,7 +161,7 @@ index 304e47bf2..6e7454b13 100644
|
|||
this.b();
|
||||
packetdataserializer.writeByte(this.i);
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityCreature.java b/src/main/java/net/minecraft/server/EntityCreature.java
|
||||
index 2c6fbd1d6..a5c147b98 100644
|
||||
index 2c6fbd1d6f..a5c147b989 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityCreature.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityCreature.java
|
||||
@@ -0,0 +0,0 @@ import org.bukkit.event.entity.EntityUnleashEvent;
|
||||
|
@ -173,7 +173,7 @@ index 2c6fbd1d6..a5c147b98 100644
|
|||
private float b;
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java
|
||||
index ebb177927..60b1dcd8e 100644
|
||||
index ebb177927f..60b1dcd8ea 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityInsentient.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityInsentient.java
|
||||
@@ -0,0 +0,0 @@ public abstract class EntityInsentient extends EntityLiving {
|
||||
|
@ -185,7 +185,7 @@ index ebb177927..60b1dcd8e 100644
|
|||
// CraftBukkit start - fire event
|
||||
setGoalTarget(entityliving, EntityTargetEvent.TargetReason.UNKNOWN, true);
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
|
||||
index fd050c5f3..8d33c1658 100644
|
||||
index 1aefd3763a..76cc9085bd 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
||||
@@ -0,0 +0,0 @@ public abstract class EntityLiving extends Entity {
|
||||
|
@ -197,7 +197,7 @@ index fd050c5f3..8d33c1658 100644
|
|||
@Override
|
||||
public float getBukkitYaw() {
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityMonster.java b/src/main/java/net/minecraft/server/EntityMonster.java
|
||||
index c0f48bbc2..f3cc2cef0 100644
|
||||
index c0f48bbc29..f3cc2cef0a 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityMonster.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityMonster.java
|
||||
@@ -0,0 +0,0 @@
|
||||
|
@ -210,7 +210,7 @@ index c0f48bbc2..f3cc2cef0 100644
|
|||
super(entitytypes, world);
|
||||
this.b_ = 5;
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityTypes.java b/src/main/java/net/minecraft/server/EntityTypes.java
|
||||
index 17bfa356f..5c1ab6a0b 100644
|
||||
index 17bfa356f1..5c1ab6a0b6 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityTypes.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityTypes.java
|
||||
@@ -0,0 +0,0 @@ package net.minecraft.server;
|
||||
|
@ -261,7 +261,7 @@ index 17bfa356f..5c1ab6a0b 100644
|
|||
// Paper end
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/ItemStack.java b/src/main/java/net/minecraft/server/ItemStack.java
|
||||
index c54275bc2..318c4204d 100644
|
||||
index c54275bc2f..318c4204df 100644
|
||||
--- a/src/main/java/net/minecraft/server/ItemStack.java
|
||||
+++ b/src/main/java/net/minecraft/server/ItemStack.java
|
||||
@@ -0,0 +0,0 @@ import org.bukkit.TreeType;
|
||||
|
@ -292,7 +292,7 @@ index c54275bc2..318c4204d 100644
|
|||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java
|
||||
new file mode 100644
|
||||
index 000000000..faec94722
|
||||
index 0000000000..faec947224
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/net/minecraft/server/MCUtil.java
|
||||
@@ -0,0 +0,0 @@
|
||||
|
@ -637,7 +637,7 @@ index 000000000..faec94722
|
|||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/NBTTagCompound.java b/src/main/java/net/minecraft/server/NBTTagCompound.java
|
||||
index 41cd3ceab..2a66a3026 100644
|
||||
index 41cd3ceabe..2a66a30264 100644
|
||||
--- a/src/main/java/net/minecraft/server/NBTTagCompound.java
|
||||
+++ b/src/main/java/net/minecraft/server/NBTTagCompound.java
|
||||
@@ -0,0 +0,0 @@ import org.apache.logging.log4j.Logger;
|
||||
|
@ -682,7 +682,7 @@ index 41cd3ceab..2a66a3026 100644
|
|||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/NetworkManager.java b/src/main/java/net/minecraft/server/NetworkManager.java
|
||||
index 0afaea810..26da89724 100644
|
||||
index 0afaea8109..26da897243 100644
|
||||
--- a/src/main/java/net/minecraft/server/NetworkManager.java
|
||||
+++ b/src/main/java/net/minecraft/server/NetworkManager.java
|
||||
@@ -0,0 +0,0 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
|
||||
|
@ -723,7 +723,7 @@ index 0afaea810..26da89724 100644
|
|||
public QueuedPacket(Packet<?> packet, @Nullable GenericFutureListener<? extends Future<? super Void>> genericfuturelistener) {
|
||||
this.a = packet;
|
||||
diff --git a/src/main/java/net/minecraft/server/PacketDataSerializer.java b/src/main/java/net/minecraft/server/PacketDataSerializer.java
|
||||
index d04afceb7..a63a5811d 100644
|
||||
index d04afceb70..a63a5811d6 100644
|
||||
--- a/src/main/java/net/minecraft/server/PacketDataSerializer.java
|
||||
+++ b/src/main/java/net/minecraft/server/PacketDataSerializer.java
|
||||
@@ -0,0 +0,0 @@ public class PacketDataSerializer extends ByteBuf {
|
||||
|
@ -734,8 +734,20 @@ index d04afceb7..a63a5811d 100644
|
|||
public static int a(int i) {
|
||||
for (int j = 1; j < 5; ++j) {
|
||||
if ((i & -1 << j * 7) == 0) {
|
||||
diff --git a/src/main/java/net/minecraft/server/PacketEncoder.java b/src/main/java/net/minecraft/server/PacketEncoder.java
|
||||
index 8e312c7617..c20911c965 100644
|
||||
--- a/src/main/java/net/minecraft/server/PacketEncoder.java
|
||||
+++ b/src/main/java/net/minecraft/server/PacketEncoder.java
|
||||
@@ -0,0 +0,0 @@ public class PacketEncoder extends MessageToByteEncoder<Packet<?>> {
|
||||
packet.b(packetdataserializer);
|
||||
} catch (Throwable throwable) {
|
||||
a.error(throwable);
|
||||
+ throwable.printStackTrace(); // Paper - WHAT WAS IT? WHO DID THIS TO YOU? WHAT DID YOU SEE?
|
||||
if (packet.a()) {
|
||||
throw new SkipEncodeException(throwable);
|
||||
} else {
|
||||
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java b/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
|
||||
index 12d6c99cf..af382815f 100644
|
||||
index 12d6c99cf0..af382815f3 100644
|
||||
--- a/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
|
||||
@@ -0,0 +0,0 @@ public class PacketPlayOutMapChunk implements Packet<PacketListenerPlayOut> {
|
||||
|
@ -756,7 +768,7 @@ index 12d6c99cf..af382815f 100644
|
|||
int j = 0;
|
||||
ChunkSection[] achunksection = chunk.getSections();
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
index 8e4e6f3b9..996ffbdfa 100644
|
||||
index d455eadfc7..8db0b6a6db 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
@@ -0,0 +0,0 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
||||
|
@ -773,7 +785,7 @@ index 8e4e6f3b9..996ffbdfa 100644
|
|||
private volatile int chatThrottle;
|
||||
private static final AtomicIntegerFieldUpdater chatSpamField = AtomicIntegerFieldUpdater.newUpdater(PlayerConnection.class, "chatThrottle");
|
||||
diff --git a/src/main/java/net/minecraft/server/RegistryBlockID.java b/src/main/java/net/minecraft/server/RegistryBlockID.java
|
||||
index a21006290..6c6f006f3 100644
|
||||
index a21006290c..6c6f006f3a 100644
|
||||
--- a/src/main/java/net/minecraft/server/RegistryBlockID.java
|
||||
+++ b/src/main/java/net/minecraft/server/RegistryBlockID.java
|
||||
@@ -0,0 +0,0 @@ public class RegistryBlockID<T> implements Registry<T> {
|
||||
|
|
Loading…
Reference in a new issue