From 9fe5df3cfe06f2872100f8d14973aaf1519125a8 Mon Sep 17 00:00:00 2001 From: Dan Mulloy Date: Fri, 19 Jun 2015 22:17:34 -0400 Subject: [PATCH] Properly obtain read/write methods for tile entities --- .../protocol/compat/netty/shaded/ShadedByteBuf.java | 3 ++- .../protocol/compat/netty/shaded/ShadedNetty.java | 3 ++- .../protocol/wrappers/nbt/TileEntityAccessor.java | 13 +++++-------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Modules/ProtocolLib-ShadedNetty/src/main/java/com/comphenix/protocol/compat/netty/shaded/ShadedByteBuf.java b/Modules/ProtocolLib-ShadedNetty/src/main/java/com/comphenix/protocol/compat/netty/shaded/ShadedByteBuf.java index 4ec0e86f..f3899894 100644 --- a/Modules/ProtocolLib-ShadedNetty/src/main/java/com/comphenix/protocol/compat/netty/shaded/ShadedByteBuf.java +++ b/Modules/ProtocolLib-ShadedNetty/src/main/java/com/comphenix/protocol/compat/netty/shaded/ShadedByteBuf.java @@ -13,7 +13,8 @@ * You should have received a copy of the GNU General Public License along with this program; * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * 02111-1307 USA - */package com.comphenix.protocol.compat.netty.shaded; + */ +package com.comphenix.protocol.compat.netty.shaded; import java.io.IOException; import java.io.ObjectInputStream; diff --git a/Modules/ProtocolLib-ShadedNetty/src/main/java/com/comphenix/protocol/compat/netty/shaded/ShadedNetty.java b/Modules/ProtocolLib-ShadedNetty/src/main/java/com/comphenix/protocol/compat/netty/shaded/ShadedNetty.java index bef04687..d2f075cd 100644 --- a/Modules/ProtocolLib-ShadedNetty/src/main/java/com/comphenix/protocol/compat/netty/shaded/ShadedNetty.java +++ b/Modules/ProtocolLib-ShadedNetty/src/main/java/com/comphenix/protocol/compat/netty/shaded/ShadedNetty.java @@ -13,7 +13,8 @@ * You should have received a copy of the GNU General Public License along with this program; * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * 02111-1307 USA - */package com.comphenix.protocol.compat.netty.shaded; + */ +package com.comphenix.protocol.compat.netty.shaded; import java.io.DataInputStream; import java.io.DataOutputStream; diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/nbt/TileEntityAccessor.java b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/nbt/TileEntityAccessor.java index 597a5428..00192df2 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/nbt/TileEntityAccessor.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/wrappers/nbt/TileEntityAccessor.java @@ -46,16 +46,14 @@ class TileEntityAccessor { private boolean writeDetected; private boolean readDetected; - private TileEntityAccessor() { + public TileEntityAccessor() { // Do nothing } /** * Construct a new tile entity accessor. * @param tileEntityField - the tile entity field. - * @param tileEntity - the tile entity. - * @param tile - the block state. - * @throws IOException Cannot read tile entity. + * @param state - the block state. */ private TileEntityAccessor(FieldAccessor tileEntityField, T state) { if (tileEntityField != null) { @@ -64,7 +62,7 @@ class TileEntityAccessor { // Possible read/write methods try { - findMethodsUsingASM(type); + findMethodsUsingASM(); } catch (IOException ex1) { try { // Much slower though @@ -84,12 +82,11 @@ class TileEntityAccessor { /** * Find the read/write methods in TileEntity. - * @param tileEntityClass - the tile entity class. - * @param nbtCompoundClass - the compound clas. * @throws IOException If we cannot find these methods. */ - private void findMethodsUsingASM(final Class tileEntityClass) throws IOException { + private void findMethodsUsingASM() throws IOException { final Class nbtCompoundClass = MinecraftReflection.getNBTCompoundClass(); + final Class tileEntityClass = MinecraftReflection.getTileEntityClass(); final ClassReader reader = new ClassReader(tileEntityClass.getCanonicalName()); final String tagCompoundName = getJarName(MinecraftReflection.getNBTCompoundClass());