diff --git a/modules/API/src/main/java/com/comphenix/protocol/reflect/cloning/BukkitCloner.java b/modules/API/src/main/java/com/comphenix/protocol/reflect/cloning/BukkitCloner.java index 431f3d7f..ec39ecb7 100644 --- a/modules/API/src/main/java/com/comphenix/protocol/reflect/cloning/BukkitCloner.java +++ b/modules/API/src/main/java/com/comphenix/protocol/reflect/cloning/BukkitCloner.java @@ -25,6 +25,7 @@ import com.comphenix.protocol.wrappers.BlockPosition; import com.comphenix.protocol.wrappers.BukkitConverters; import com.comphenix.protocol.wrappers.ChunkPosition; import com.comphenix.protocol.wrappers.MinecraftKey; +import com.comphenix.protocol.wrappers.WrappedBlockData; import com.comphenix.protocol.wrappers.WrappedDataWatcher; import com.comphenix.protocol.wrappers.WrappedServerPing; import com.google.common.collect.Maps; @@ -61,6 +62,11 @@ public class BukkitCloner implements Cloner { addClass(5, MinecraftReflection.getDataWatcherSerializerClass()); addClass(6, MinecraftReflection.getMinecraftKeyClass()); } + + try { + addClass(7, MinecraftReflection.getIBlockDataClass()); + } catch (Throwable ex) { + } } private void addClass(int id, Class clazz) { @@ -112,7 +118,10 @@ public class BukkitCloner implements Cloner { return source; case 6: EquivalentConverter keyConverter = MinecraftKey.getConverter(); - return keyConverter.getGeneric(clonableClasses.get(5), keyConverter.getSpecific(source)); + return keyConverter.getGeneric(clonableClasses.get(6), keyConverter.getSpecific(source)); + case 7: + EquivalentConverter blockDataConverter = BukkitConverters.getWrappedBlockDataConverter(); + return blockDataConverter.getGeneric(clonableClasses.get(7), blockDataConverter.getSpecific(source).deepClone()); default: throw new IllegalArgumentException("Cannot clone objects of type " + source.getClass()); } diff --git a/modules/API/src/main/java/com/comphenix/protocol/wrappers/WrappedBlockData.java b/modules/API/src/main/java/com/comphenix/protocol/wrappers/WrappedBlockData.java index ed08cb30..010155e3 100644 --- a/modules/API/src/main/java/com/comphenix/protocol/wrappers/WrappedBlockData.java +++ b/modules/API/src/main/java/com/comphenix/protocol/wrappers/WrappedBlockData.java @@ -149,6 +149,14 @@ public class WrappedBlockData extends AbstractWrapper { return new WrappedBlockData(blockData); } + /** + * Retrieve a deep copy of the current wrapper object. + * @return The cloned object. + */ + public WrappedBlockData deepClone() { + return WrappedBlockData.createData(getType(), getData()); + } + @Override public String toString() { return "WrappedBlockData[handle=" + handle + "]";