I am updating my code from 1.12.2 to 1.14.4 and I am having trouble with converting BlockPos.getAllInBoxMutable() to an ArrayList. My issue is that the last BlockPos in the Iterable is copied to all parts of the array instead of each to their own.
My code and output are here:
CODE:
ArrayList<BlockPos> list = new ArrayList<BlockPos>();
Iterable<BlockPos> blocks = BlockPos.getAllInBoxMutable(new MutableBlockPos(0,0,0),new MutableBlockPos(2,0,0));
Iterable<BlockPos> iterable = Arrays.asList(new MutableBlockPos(0,0,0),new MutableBlockPos(1,0,0),new MutableBlockPos(2,0,0));
if(!ZBuild.doneSelection) {
try {
blocks.forEach(x->System.out.println(x));
blocks.forEach(x->list.add(x));
System.out.println(list+"\n\n");
list.clear();
iterable.forEach(x->System.out.println(x));
iterable.forEach(x->list.add(x));
System.out.println(list);
}catch(Exception e) {
System.out.println(e);
}
ZBuild.doneSelection=true;
}
======================================================================================================
OUTPUT:
MutableBlockPos{x=0, y=0, z=0}
MutableBlockPos{x=1, y=0, z=0}
MutableBlockPos{x=2, y=0, z=0}
[MutableBlockPos{x=2, y=0, z=0}, MutableBlockPos{x=2, y=0, z=0}, MutableBlockPos{x=2, y=0, z=0}]
MutableBlockPos{x=0, y=0, z=0}
MutableBlockPos{x=1, y=0, z=0}
MutableBlockPos{x=2, y=0, z=0}
[MutableBlockPos{x=0, y=0, z=0}, MutableBlockPos{x=1, y=0, z=0}, MutableBlockPos{x=2, y=0, z=0}]
Some of the solutions I have tried so far include:
a for loop that adds each BlockPos individually
changing getAllInBoxMutable to getAllInBox and converting the stream into an array
changing all MutableBlockPos into BlockPos
commenting out all code in the class that pertains to any of the variables
Everything so far has yielded the same results and I am not quite sure why. Any help would be appreciated.