ProtocolLib and WrappedDataWatcher

Discussion in 'Spigot Plugin Development' started by Arektor, Jul 1, 2016.

  1. Hey!

    Right now I'm trying to play with packets for making a zombie appear as a human entity for players. But I'm getting some troubles with the datawatcher, it keeps crashing clients with the error:
    "java.lang.Integer cannot be cast to java.lang.Byte"

    I tried everything : Changing every byte value to an integer one, then every integer into bytes, also value per value: nothing to do, always the same error.
    I took a look at http://wiki.vg/Entities#Entity_Metadata_Format but according to what it says, everything is good.
    Am I doing something wrong?

    Code (Text):
                        WrappedDataWatcher metadata = new WrappedDataWatcher();
                        metadata.setObject(new WrappedDataWatcherObject(0, WrappedDataWatcher.Registry.get(Byte.class)), Byte.valueOf((byte)0));
                        metadata.setObject(new WrappedDataWatcherObject(1, WrappedDataWatcher.Registry.get(Integer.class)), 300);
                        metadata.setObject(new WrappedDataWatcherObject(2, WrappedDataWatcher.Registry.get(String.class)), human.usedSkin.getName());
                        metadata.setObject(new WrappedDataWatcherObject(3, WrappedDataWatcher.Registry.get(Boolean.class)), true);
                        metadata.setObject(new WrappedDataWatcherObject(4, WrappedDataWatcher.Registry.get(Boolean.class)), false);
                        metadata.setObject(new WrappedDataWatcherObject(5, WrappedDataWatcher.Registry.get(Boolean.class)), false);
                        metadata.setObject(new WrappedDataWatcherObject(6, WrappedDataWatcher.Registry.get(Byte.class)), Byte.valueOf((byte)0));
                        metadata.setObject(new WrappedDataWatcherObject(7, WrappedDataWatcher.Registry.get(Float.class)), 20.0F);
                        metadata.setObject(new WrappedDataWatcherObject(8, WrappedDataWatcher.Registry.get(Integer.class)), 0);
                        metadata.setObject(new WrappedDataWatcherObject(9, WrappedDataWatcher.Registry.get(Boolean.class)), false);
                        metadata.setObject(new WrappedDataWatcherObject(10, WrappedDataWatcher.Registry.get(Integer.class)), 0);
                        metadata.setObject(new WrappedDataWatcherObject(11, WrappedDataWatcher.Registry.get(Float.class)), 0F);
                        metadata.setObject(new WrappedDataWatcherObject(12, WrappedDataWatcher.Registry.get(Integer.class)), 0);
                        metadata.setObject(new WrappedDataWatcherObject(13, WrappedDataWatcher.Registry.get(Byte.class)), Byte.valueOf((byte)127));
                        metadata.setObject(new WrappedDataWatcherObject(14, WrappedDataWatcher.Registry.get(Byte.class)), new Random().nextInt(100)+1 >= 95 ? Byte.valueOf((byte)0) : Byte.valueOf((byte)1));