Pocketmine-mp: Entities are saved on wrong chunks in negative coordinates

Created on 9 Dec 2017  路  4Comments  路  Source: pmmp/PocketMine-MP

Issue description

Bad typecasts. An entity at (-16.5, 4, -91.5) should be saved on chunk (-2, -6), and instead is saved on (-1, -6). This is because int typecasts and flooring are not the same thing on negatives.

This problem also exists with bitshifts on possible floats, since float operands of bitshifts are silently casted to ints.

Core High Fixed

All 4 comments

Not sure how to fix this without breaking compatibility with existing worlds previously saved by PM (fixing the bug will prevent entities saved on wrong chunks being loaded).

It will only affect the saved entity? It's just better to fix now than to waste time, I think so.

Correction on the above: It will cause entities in the bounds of undefined areas (-16.0 > w > -17.0, -32 > w > -33, etc) to be deleted, not all entities in negative chunks would be affected.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dktapps picture dktapps  路  3Comments

beetree picture beetree  路  3Comments

dktapps picture dktapps  路  3Comments

XDqrkneZ picture XDqrkneZ  路  3Comments

Muqsit picture Muqsit  路  3Comments