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
Conversation
mitchej123
commented
May 4, 2023
- Fix mFacing NPEs
* 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>
src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java
Outdated
Show resolved
Hide resolved
IGregTechTileEntity te = getBaseMetaTileEntity(); | ||
if (te != null && te.getWorld().isRemote) { | ||
mMainFacing = te.getFrontFacing(); | ||
te.setFrontFacing(te.getBackFacing()); |
There was a problem hiding this comment.
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();
}
There was a problem hiding this comment.
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.
There was a problem hiding this 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