aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech
diff options
context:
space:
mode:
authorGlease <4586901+Glease@users.noreply.github.com>2023-09-23 01:08:48 +0800
committerGitHub <noreply@github.com>2023-09-22 19:08:48 +0200
commit23ad5cfcb2a08eff59d31f8a13f38dc3c264b42c (patch)
treedbdd32ad3939d2c6df2c9a0116206c0d865f7d15 /src/main/java/gregtech
parent2e429bb4ca5a4c756cf6e6c131e176217a9c4bd3 (diff)
downloadGT5-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')
-rw-r--r--src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_EnhancedMultiBlockBase.java42
-rw-r--r--src/main/java/gregtech/common/GT_Client.java19
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java5
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java5
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java24
5 files changed, 84 insertions, 11 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")
diff --git a/src/main/java/gregtech/common/GT_Client.java b/src/main/java/gregtech/common/GT_Client.java
index 0378e7f127..f741f56927 100644
--- a/src/main/java/gregtech/common/GT_Client.java
+++ b/src/main/java/gregtech/common/GT_Client.java
@@ -400,27 +400,34 @@ public class GT_Client extends GT_Proxy implements Runnable {
if (tAlignment != null) {
final ForgeDirection direction = tAlignment.getDirection();
if (direction.ordinal() == tSideHit)
- drawExtendedRotationMarker(ROTATION_MARKER_TRANSFORM_CENTER, aIsSneaking, false);
+ drawExtendedRotationMarker(ROTATION_MARKER_TRANSFORM_CENTER, aIsSneaking, tAlignment);
else if (direction.getOpposite()
.ordinal() == tSideHit) {
for (Transformation t : ROTATION_MARKER_TRANSFORMS_CORNER) {
- drawExtendedRotationMarker(t, aIsSneaking, true);
+ drawExtendedRotationMarker(t, aIsSneaking, tAlignment);
}
} else {
drawExtendedRotationMarker(
ROTATION_MARKER_TRANSFORMS_SIDES_TRANSFORMS[ROTATION_MARKER_TRANSFORMS_SIDES[tSideHit * 6
+ direction.ordinal()]],
aIsSneaking,
- true);
+ tAlignment);
}
}
}
GL11.glPopMatrix(); // get back to player center
}
- private static void drawExtendedRotationMarker(Transformation transform, boolean sneaking, boolean small) {
- if (sneaking) drawFlipMarker(transform);
- else drawRotationMarker(transform);
+ private static void drawExtendedRotationMarker(Transformation transform, boolean sneaking, IAlignment alignment) {
+ if (sneaking) {
+ if (alignment.isFlipChangeAllowed()) {
+ drawFlipMarker(transform);
+ }
+ } else {
+ if (alignment.isRotationChangeAllowed()) {
+ drawRotationMarker(transform);
+ }
+ }
}
private static void drawRotationMarker(Transformation transform) {
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java
index e368e43518..349614ea1e 100644
--- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java
+++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DistillationTower.java
@@ -232,6 +232,11 @@ public class GT_MetaTileEntity_DistillationTower extends
}
@Override
+ public boolean isRotationChangeAllowed() {
+ return false;
+ }
+
+ @Override
public IStructureDefinition<GT_MetaTileEntity_DistillationTower> getStructureDefinition() {
return STRUCTURE_DEFINITION;
}
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java
index 41e0712627..efb4b8e6d2 100644
--- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java
+++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_DrillerBase.java
@@ -626,6 +626,11 @@ public abstract class GT_MetaTileEntity_DrillerBase
}
@Override
+ public boolean isRotationChangeAllowed() {
+ return false;
+ }
+
+ @Override
public final IStructureDefinition<GT_MetaTileEntity_DrillerBase> getStructureDefinition() {
return STRUCTURE_DEFINITION.get(getClass());
}
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java
index a8961ce542..dc30cc79f0 100644
--- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java
+++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine.java
@@ -30,8 +30,11 @@ import net.minecraftforge.fluids.FluidStack;
import org.jetbrains.annotations.NotNull;
+import com.gtnewhorizon.structurelib.alignment.IAlignmentLimits;
import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable;
import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing;
+import com.gtnewhorizon.structurelib.alignment.enumerable.Flip;
+import com.gtnewhorizon.structurelib.alignment.enumerable.Rotation;
import com.gtnewhorizon.structurelib.structure.IStructureDefinition;
import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment;
import com.gtnewhorizon.structurelib.structure.StructureDefinition;
@@ -115,6 +118,27 @@ public abstract class GT_MetaTileEntity_LargeTurbine
}
@Override
+ protected IAlignmentLimits getInitialAlignmentLimits() {
+ return (d, r, f) -> r.isNotRotated() && f.isNotFlipped();
+ }
+
+ @Override
+ protected ExtendedFacing getCorrectedAlignment(ExtendedFacing aOldFacing) {
+ return aOldFacing.with(Flip.NONE)
+ .with(Rotation.NORMAL);
+ }
+
+ @Override
+ public boolean isFlipChangeAllowed() {
+ return false;
+ }
+
+ @Override
+ public boolean isRotationChangeAllowed() {
+ return false;
+ }
+
+ @Override
public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
return checkPiece(STRUCTURE_PIECE_MAIN, 2, 2, 1) && mMaintenanceHatches.size() == 1
&& mMufflerHatches.isEmpty() == (getPollutionPerTick(null) == 0);