Properly repeat extents for negative coordinates

An extent's content was returned flipped when applied for negative positions, as e.g. `Math.abs(-2) % 3` returns 2 instead of 1 (as 1 + -1 * 3 = -2)

(cherry picked from commit b0cf5dd2bf1b9bcbf1c7efff0fe25de7ee9a2090)
This commit is contained in:
Hannes Greule 2020-12-11 16:06:32 +01:00 committed by Octavia Togami
parent df2eb157b0
commit 544793d541

View File

@ -88,9 +88,9 @@ public class RepeatingExtentPattern extends AbstractExtentPattern {
@Override
public BaseBlock applyBlock(BlockVector3 position) {
BlockVector3 base = position.add(offset);
int x = Math.abs(base.getBlockX()) % size.getBlockX();
int y = Math.abs(base.getBlockY()) % size.getBlockY();
int z = Math.abs(base.getBlockZ()) % size.getBlockZ();
int x = Math.floorMod(base.getBlockX(), size.getBlockX());
int y = Math.floorMod(base.getBlockY(), size.getBlockY());
int z = Math.floorMod(base.getBlockZ(), size.getBlockZ());
return getExtent().getFullBlock(BlockVector3.at(x, y, z).add(origin));
}