From 2281c602df97f8be05ed0521b2e1746aaae7f578 Mon Sep 17 00:00:00 2001 From: tastybento Date: Mon, 22 Jul 2024 18:49:29 -0700 Subject: [PATCH] Fix for 1.20.6 --- pom.xml | 32 ++++++++++--------- .../bentobox/boxed/nms/AbstractMetaData.java | 22 +++++++------ .../v1_20_6_R0_1_SNAPSHOT/GetMetaData.java | 3 +- 3 files changed, 31 insertions(+), 26 deletions(-) diff --git a/pom.xml b/pom.xml index de50fbb..de10050 100644 --- a/pom.xml +++ b/pom.xml @@ -65,7 +65,7 @@ -LOCAL - 2.6.0 + 2.6.1 BentoBoxWorld_Boxed bentobox-world @@ -172,28 +172,30 @@ provided - - org.spigotmc - spigot - ${spigot.version} - provided - - - org.spigotmc..... - spigot - 1.21-R0.1-SNAPSHOT - provided - - + + org.spigotmc.... spigot 1.20.6-R0.1-SNAPSHOT provided + + org.spigotmc + spigot + ${spigot.version} + provided + + + org.spigotmc..... + spigot + 1.21-R0.1-SNAPSHOT + provided + + org.spigotmc. spigot - 1.20.3-R0.1-SNAPSHOT + 1.20.4-R0.1-SNAPSHOT provided diff --git a/src/main/java/world/bentobox/boxed/nms/AbstractMetaData.java b/src/main/java/world/bentobox/boxed/nms/AbstractMetaData.java index ccab4a5..94f7576 100644 --- a/src/main/java/world/bentobox/boxed/nms/AbstractMetaData.java +++ b/src/main/java/world/bentobox/boxed/nms/AbstractMetaData.java @@ -23,18 +23,22 @@ public abstract class AbstractMetaData { if (updatePacketMethod != null) { // Invoke the method to get the PacketPlayOutTileEntityData object updatePacketMethod.setAccessible(true); - PacketPlayOutTileEntityData packet = (PacketPlayOutTileEntityData) updatePacketMethod.invoke(te); + Object object = updatePacketMethod.invoke(te); + PacketPlayOutTileEntityData packet = (PacketPlayOutTileEntityData) object; + //if (object instanceof PacketPlayOutTileEntityData packet) { + // Access the private field for the NBTTagCompound getter in PacketPlayOutTileEntityData + Field fieldC = packet.getClass().getDeclaredField(field); + fieldC.setAccessible(true); + NBTTagCompound nbtTag = (NBTTagCompound) fieldC.get(packet); - // Access the private field for the NBTTagCompound getter in PacketPlayOutTileEntityData - Field fieldC = packet.getClass().getDeclaredField(field); - fieldC.setAccessible(true); - NBTTagCompound nbtTag = (NBTTagCompound) fieldC.get(packet); - - return nbtTag.toString(); // This will show what you want + return nbtTag.toString(); // This will show what you want + //} else { + // throw new ClassNotFoundException( + // object.getClass().getCanonicalName() + " is not a PacketPlayOutTileEntityData"); + //} } - } catch (NoSuchMethodException e) { - System.out.println("The method '" + method + "' does not exist in the TileEntity class."); } catch (Exception e) { + System.out.println("The method '" + method + "' does not exist in the TileEntity class."); e.printStackTrace(); } return ""; diff --git a/src/main/java/world/bentobox/boxed/nms/v1_20_6_R0_1_SNAPSHOT/GetMetaData.java b/src/main/java/world/bentobox/boxed/nms/v1_20_6_R0_1_SNAPSHOT/GetMetaData.java index 98c4a99..2855074 100644 --- a/src/main/java/world/bentobox/boxed/nms/v1_20_6_R0_1_SNAPSHOT/GetMetaData.java +++ b/src/main/java/world/bentobox/boxed/nms/v1_20_6_R0_1_SNAPSHOT/GetMetaData.java @@ -15,7 +15,6 @@ public class GetMetaData extends AbstractMetaData { Location w = block.getLocation(); CraftWorld cw = (CraftWorld) w.getWorld(); // CraftWorld is NMS one TileEntity te = cw.getHandle().c_(new BlockPosition(w.getBlockX(), w.getBlockY(), w.getBlockZ())); - - return getData(te, "j", "c"); + return getData(te, "au_", "tag"); } } \ No newline at end of file