ProtocolLib

3M Downloads

Conversion between new BockData API and WrappedBlockData

Opened this issue ยท 0 comments

commented

Hey I am trying to resend a block based on an existing block in the world, which was virtually destroyed before via packets via WrapperPlayServerBlockChange (PacketWrapper).

Setting the block data turned out not being so easy. The WrappedBlockData#setData(int data) method requires a magic value. The Spigot BlockData API classes don't expose the low level id.

I think I understand how the Spigot BlockData <-> CraftBlockData mapping works and that the state is an implementation of IBlockData saved in class attribute state. The PacketPlayOutBlockChange class is accessing IBlockData over IBlockAccess and the format (location, block) is the same as listed on wiki.vg. In the class PacketPlayOutBlockChange the method Block.getCombinedId(this.block) is used, which is probably translating the state to the magic value I need. However, MCP isn't out for 1.13 and JD-GUI can't decompile Block.class so I am not really sure if this is the right method.

Instead of continuing to research how to get this magic value, I would rather prefer to depend on Spigot's BlockData abstraction and not implementation detail. I would be really nice if you could overload the WrappedBlockData#setType method accepting the Spigot's BlockData. If you don't want extend the class because some architectural design choice restrictions, putting this in PacketWrappers would be fine too.