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

Conversation

Lyfts
Copy link
Member

@Lyfts Lyfts commented Jan 11, 2025

Closes GTNewHorizons/GT-New-Horizons-Modpack#18510

This problem arises when the multiple survivialBuildPiece() are += in survivalConstruct() since returning anything below 0 would previously cause the preview construction to abort.

A possible example for the YottTank with some edits to illustrate the point

    public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) {
        if (mMachine) return -1;
        int built = 0;
		// This piece is finished which causes built to be -1 
        built += survivialBuildPiece(YOTTANK_BOTTOM, stackSize, 2, 0, 0, elementBudget, env, false, true); 
        int height = 15;
		
		// This piece is also finished meaning built is now -2
        built += survivialBuildPiece(YOTTANK_TOP, stackSize, 2, height + 2, 0, elementBudget - built, env, false, true);

		// 14 of these were already finished and 
		// The last piece only placed a hatch in this round (which are always placed individually)
		// The return value ends up being -15 in this case
        while (height > 0) {
            built += survivialBuildPiece(YOTTANK_MID, stackSize, 2, height, 0, elementBudget - built, env, false, true);
            height--;
        }

		// returns -15 which causes the construction to abort despite not being finished.
        return built;
    }

Previously we fixed that by adding if (built > 0) return built; after most survivialBuildPiece() but that's kinda annoying and unnecessary, especially since we can check whether something was actually placed in the world to more reliably determine whether construction should stop.

@Lyfts Lyfts requested a review from a team January 11, 2025 23:18
@serenibyss serenibyss merged commit 90c1a11 into master Jan 12, 2025
1 check passed
@serenibyss serenibyss deleted the fix-incorrect-abort branch January 12, 2025 02:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

YOTTank NEI Multiblock Preview removes most of the top and bottom Casings when changing tier to 10+
2 participants