diff options
author | Glease <4586901+Glease@users.noreply.github.com> | 2023-09-23 01:08:48 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-22 19:08:48 +0200 |
commit | 23ad5cfcb2a08eff59d31f8a13f38dc3c264b42c (patch) | |
tree | dbdd32ad3939d2c6df2c9a0116206c0d865f7d15 /src/main/java/gregtech/api | |
parent | 2e429bb4ca5a4c756cf6e6c131e176217a9c4bd3 (diff) | |
download | GT5-Unofficial-23ad5cfcb2a08eff59d31f8a13f38dc3c264b42c.tar.gz GT5-Unofficial-23ad5cfcb2a08eff59d31f8a13f38dc3c264b42c.tar.bz2 GT5-Unofficial-23ad5cfcb2a08eff59d31f8a13f38dc3c264b42c.zip |
disable large turbine rotation or flip (#2290)
also made the rotation and flip marker to not show up when the multi doesn't support rotating or flipping
Diffstat (limited to 'src/main/java/gregtech/api')
-rw-r--r-- | src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java index 9fac4a880c..cc585d1999 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java @@ -86,12 +86,17 @@ public abstract class GT_MetaTileEntity_EnhancedMultiBlockBase<T extends GT_Meta if (wrenchingSide != getBaseMetaTileEntity().getFrontFacing()) return super.onWrenchRightClick(side, wrenchingSide, entityPlayer, aX, aY, aZ); if (entityPlayer.isSneaking()) { - // we won't be allowing horizontal flips, as it can be perfectly emulated by rotating twice and flipping - // horizontally - // allowing an extra round of flip make it hard to draw meaningful flip markers in GT_Proxy#drawGrid - toolSetFlip(getFlip().isHorizontallyFlipped() ? Flip.NONE : Flip.HORIZONTAL); + if (isFlipChangeAllowed()) { + toolSetFlip(getFlip().isHorizontallyFlipped() ? Flip.NONE : Flip.HORIZONTAL); + } else { + return false; + } } else { - toolSetRotation(null); + if (isRotationChangeAllowed()) { + toolSetRotation(null); + } else { + return false; + } } return true; } @@ -148,6 +153,33 @@ public abstract class GT_MetaTileEntity_EnhancedMultiBlockBase<T extends GT_Meta getBaseMetaTileEntity().getFrontFacing(), Rotation.byIndex(aNBT.getByte("eRotation")), Flip.byIndex(aNBT.getByte("eFlip"))); + if (!getAlignmentLimits().isNewExtendedFacingValid(mExtendedFacing)) { + mExtendedFacing = getCorrectedAlignment(mExtendedFacing); + } + } + + /** + * When an old {@link ExtendedFacing} is loaded upon MTE deserialization, and the loaded facing cannot pass test of + * current {@link #getAlignmentLimits()}, this method will be called to retrieve a corrected version. This method + * is currently only intended to be used as a mean to migrate alignment limits, so if you never change the alignment + * limit then you can probably just use the default implementation. + * + * The returned new facing must be able to pass the test of {@link #isNewExtendedFacingValid(ExtendedFacing)} + */ + protected ExtendedFacing getCorrectedAlignment(ExtendedFacing aOldFacing) { + if (isNewExtendedFacingValid(ExtendedFacing.DEFAULT)) { + return ExtendedFacing.DEFAULT; + } + for (ExtendedFacing facing : ExtendedFacing.VALUES) { + if (facing.getFlip() + .isVerticallyFliped()) { + continue; + } + if (isNewExtendedFacingValid(facing)) { + return facing; + } + } + throw new AssertionError("No ExtendedFacing can pass the test of isNewExtendedFacingValid"); } @SuppressWarnings("unchecked") |