Skip to content

Commit

Permalink
Fix some multiblock placements aborting too early (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyfts authored Jan 12, 2025
1 parent 7ad4629 commit 90c1a11
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class TrackedDummyWorld extends DummyWorld {
private final Vector3f minPos = new Vector3f(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE);
private final Vector3f maxPos = new Vector3f(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE);
private final Vector3f size = new Vector3f();
private boolean hasChanged;

@Override
public boolean setBlock(int x, int y, int z, Block block, int meta, int flags) {
Expand All @@ -50,6 +51,7 @@ public boolean setBlock(int x, int y, int z, Block block, int meta, int flags) {
block.onBlockAdded(this, x, y, z);
}

hasChanged = true;
minPos.x = Math.min(minPos.x, x);
minPos.y = Math.min(minPos.y, y);
minPos.z = Math.min(minPos.z, z);
Expand Down Expand Up @@ -312,4 +314,10 @@ && isBlockTargeted(movingobjectposition1, targetedBlocks)) {
private boolean isBlockTargeted(MovingObjectPosition result, LongSet targetedBlocks) {
return targetedBlocks.contains(CoordinatePacker.pack(result.blockX, result.blockY, result.blockZ));
}

public boolean hasChanged() {
boolean changed = hasChanged;
hasChanged = false;
return changed;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,14 @@ protected void placeMultiblock() {
IMetaTileEntity mte = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity();

if (mte instanceof ISurvivalConstructable survivalConstructable) {
int result, iterations = 0;
int iterations = 0;
do {
result = survivalConstructable.survivalConstruct(
survivalConstructable.survivalConstruct(
getBuildTriggerStack(),
Integer.MAX_VALUE,
ISurvivalBuildEnvironment.create(CreativeItemSource.instance, FAKE_PLAYER));
iterations++;
} while (result > 0 && iterations < MAX_PLACE_ROUNDS);
} while (renderer.world.hasChanged() && iterations < MAX_PLACE_ROUNDS);
} else if (tTileEntity instanceof IConstructableProvider iConstructableProvider) {
constructable = iConstructableProvider.getConstructable();
} else if (tTileEntity instanceof IConstructable iConstructable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected void placeMultiblock() {
tryConstruct = true;
break;
}
} while (result > 0 && iterations < MAX_PLACE_ROUNDS);
} while (renderer.world.hasChanged() && iterations < MAX_PLACE_ROUNDS);

if (tryConstruct) {
multi.construct(getBuildTriggerStack(), false);
Expand Down

0 comments on commit 90c1a11

Please sign in to comment.