Coordinates when operating with block procedures are sometimes off

Section

If your procedure does block operations and they execute on wrong positions, eg. place block procedure places a block off for 1 block, this may be caused by using x, y, and z dependencies directly.

This happens when the procedure trigger source returns a decimal location (eg. entity), but the block expects an integer location. In this case, by default in Java, decimals are stripped away without checking the sign (+ or -). This can result in wrong placement locations.

This can happen in the case of a procedure like this one:

Example of problematic procedure

While this procedure will run just fine in case it was triggered by a block trigger that returned integer, it will round incorectly if it is triggered by eg. entity procedure which returns location in a decimal form.

To resolve this problem, there are two solutions, depending on the MCreator version you use.

Solution for versions up to 2020.5

For example above, we can resolve the procedure to operate properly by chaning it to this:

Proper procedure for decimal numbers

A better solution for versions after (including) 2021.1

For our example, we can resolve the procedure to operate properly by chaning it to this:

Solution for procedure problem

Blocks "x ~ block", etc. will return properly rounded location for the current block position in case it is in decimal format.



Donate to MCreator

By donating to developers you can speed up development, as with more resources, we can dedicate more time to MCreator. It is a free project made by developers working on it in their free time.