Erorr with WrappedWatchableObject / DataWatcher in Pipeline - Entity Metadata
Janmm14 opened this issue ยท 2 comments
Follow this template except for feature requests. Use pastebin when providing /protocol dump and any relevant errors.
Make sure you've done the following:
- You're using the latest build for your server version
- This isn't an issue caused by another plugin
- You've checked for duplicate issues
- You didn't use
/reload
Debug paste link: https://pastebin.com/s4Fnm1G1
Description and relevant errors:
Code:
public void setSneaking( boolean sneakState, Player player ) {
try {
int id = (int) this.entityPlayer.getClass().getMethod( "getId" ).invoke( this.entityPlayer );
ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
PacketContainer packetContainer = protocolManager.createPacket( PacketType.Play.Server.ENTITY_METADATA );
packetContainer.getModifier().writeDefaults();
packetContainer.getIntegers().write( 0, id );
List<WrappedWatchableObject> wwoList = new ArrayList<>();
byte bitmask = (byte) (sneakState ? 0x02 : 0x00);
wwoList.add(new WrappedWatchableObject(0, bitmask));
packetContainer.getWatchableCollectionModifier().write(0, wwoList);
protocolManager.sendServerPacket( player, packetContainer );
} catch ( Exception e ) {
e.printStackTrace();
}
}
Have you tried this with a wrapped data watcher instead? Using the watchable collection should also work but it would help in debugging.
No, I did not tried that.
Basically I used the code from PacketWrapper: https://github.com/dmulloy2/PacketWrapper/blob/master/PacketWrapper/src/main/java/com/comphenix/packetwrapper/WrapperPlayServerEntityMetadata.java