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

Exploring some various ForgeDirection fixes #1950

Merged
merged 7 commits into from May 6, 2023
Merged

Conversation

mitchej123
Copy link
Contributor

  • Fix mFacing NPEs

mitchej123 and others added 4 commits May 3, 2023 23:05
* QuickFixes incomplete facing fixes

* fix Neither UP nor DOWN conditions as offsetY == 0 is not valid test

* fix neither up nor down again

* Still not fixed: use ForgeDirection.flag for clarty

killed more ordinal siding.

* get ride of offset testing

---------

Co-authored-by: Jakub <53441451+kuba6000@users.noreply.github.com>
Co-authored-by: Jason Mitchell <mitchej@gmail.com>
IGregTechTileEntity te = getBaseMetaTileEntity();
if (te != null && te.getWorld().isRemote) {
mMainFacing = te.getFrontFacing();
te.setFrontFacing(te.getBackFacing());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not gonna work

                te.setFrontFacing(te.getBackFacing());

With the current implementation of getBackFacing() in BaseMetaTileEntity:

    @Override
    public ForgeDirection getBackFacing() {
        return mFacing.getOpposite();
    }

And with the implementation of BaseMetaPipeEntity it is getting even worse with an infinite recursion:

    @Override
    public ForgeDirection getBackFacing() {
        return getFrontFacing().getOpposite();
    }

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would there be infinite recursion? I've tested this and it runs correctly. Arguments are evaluated first, and then passed into the method call, so the code is executed as:

arg0 = te.getBackFacing()
 - (calculates opposite facing to the current state)
te.setFrontFacing(arg0) - just updates a member variable

I don't see where this would cause recursion.
Pipe's facing is just:

@Override
    public ForgeDirection getBackFacing() {
        return getFrontFacing().getOpposite();
    }

    @Override
    public ForgeDirection getFrontFacing() {
        return ForgeDirection.UNKNOWN;
    }

so it would return UNKNOWN, which doesn't matter because afaik machines can't be pipe tile entities.

Copy link
Member

@Dream-Master Dream-Master left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i not seen any issue ingame so lets pull this for the next dev version to test more

@Dream-Master Dream-Master merged commit d945860 into master May 6, 2023
2 checks passed
@Dream-Master Dream-Master deleted the exploration branch May 6, 2023 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants