Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some multiblock placements aborting too early #25

Merged
merged 1 commit into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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