getBlockPositionCollectionModifier() method returns erroneous BlockPositions
biglou36 opened this issue ยท 0 comments
Attempting to call the getBlockPositionCollectionModifier() method for packets of the following types return BlockPosition lists that contain null BlockPositions:
RECIPES
PLAYER_INFO
ENTITY_METADATA
WINDOW_ITEMS
UPDATE_ATTRIBUTES
LIGHT_UPDATE
This list is not exhaustive
Steps to reproduce the behavior:
- Call the following method on a packet of one of the above types:
packet.getBlockPositionCollectionModifier();
- Read the first BlockPosition List from the structure modifier, using
readSafely( 0 )
or equivalent. - Call the
size()
method on the resulting BlockPosition List.
Expected result: 0, Actual result: varies, always greater than zero. - Iterate through the BlockPosition list and call any method that retrieves data, example:
getX()
- NPE occurs and stack trace is shown.
Expected behavior is that the getBlockPositionCollectionModifier()
function should not return any BlockPosition Lists when used on irrelevant packets.
ProtocolLib dump: https://pastebin.com/UFKjb8Qs
A temporary workaround for those who encounter this problem is to catch the NPE and let it fail silently. It seems that most of the incorrect BlockPositions are actually NBT Tags, so you may handle them accordingly.