diff options
| author | Jason Mitchell <mitchej@gmail.com> | 2023-04-22 22:33:35 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-23 07:33:35 +0200 |
| commit | 56f2269f4af6d2130bdb2b6e6ac6e13bce89e47b (patch) | |
| tree | 745e6d92025ec4ef449fc59fa5fdd741200b0489 /src/main/java/gregtech/common/blocks | |
| parent | ac0b7a7da46646d325def36eed811941dbfc5950 (diff) | |
| download | GT5-Unofficial-56f2269f4af6d2130bdb2b6e6ac6e13bce89e47b.tar.gz GT5-Unofficial-56f2269f4af6d2130bdb2b6e6ac6e13bce89e47b.tar.bz2 GT5-Unofficial-56f2269f4af6d2130bdb2b6e6ac6e13bce89e47b.zip | |
Forge direction (#1895)
* ForgeDirection
Also refactor the clusterfuck that was `getCoordinateScan`
Co-authored by: Jason Mitchell <mitchej@gmail.com>
* Fix rendering of Frame Boxes
Frame boxes needed their own implementation of getTexture with int connexion mask,
which is returning an error texture for the MetaTileEntity, because pipes (FrameBox
**is** a pipe) do use this method to return different textures based on connexion
status.
---------
Co-authored-by: Léa Gris <lea.gris@noiraude.net>
Diffstat (limited to 'src/main/java/gregtech/common/blocks')
21 files changed, 175 insertions, 148 deletions
diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings1.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings1.java index ea5c569ac7..7610bfa769 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings1.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings1.java @@ -62,7 +62,7 @@ public class GT_Block_Casings1 extends GT_Block_Casings_Abstract { } @Override - public IIcon getIcon(int aSide, int aMeta) { + public IIcon getIcon(int ordinalSide, int aMeta) { if ((aMeta >= 0) && (aMeta < 16)) { switch (aMeta) { case 10 -> { @@ -84,10 +84,10 @@ public class GT_Block_Casings1 extends GT_Block_Casings_Abstract { return Textures.BlockIcons.MACHINE_COIL_SUPERCONDUCTOR.getIcon(); } } - if (aSide == 0) { + if (ordinalSide == 0) { return Textures.BlockIcons.MACHINECASINGS_BOTTOM[aMeta].getIcon(); } - if (aSide == 1) { + if (ordinalSide == 1) { return Textures.BlockIcons.MACHINECASINGS_TOP[aMeta].getIcon(); } return Textures.BlockIcons.MACHINECASINGS_SIDE[aMeta].getIcon(); diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings2.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings2.java index 14960eea10..c93d613936 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings2.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings2.java @@ -67,7 +67,7 @@ public class GT_Block_Casings2 extends GT_Block_Casings_Abstract { } @Override - public IIcon getIcon(int aSide, int aMeta) { + public IIcon getIcon(int ordinalSide, int aMeta) { return switch (aMeta) { case 0 -> Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); case 1 -> Textures.BlockIcons.MACHINE_CASING_FROST_PROOF.getIcon(); diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings3.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings3.java index 92bb58aead..3d81a8de18 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings3.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings3.java @@ -51,7 +51,7 @@ public class GT_Block_Casings3 extends GT_Block_Casings_Abstract { } @Override - public IIcon getIcon(int aSide, int aMeta) { + public IIcon getIcon(int ordinalSide, int aMeta) { return switch (aMeta) { case 0 -> Textures.BlockIcons.MACHINE_CASING_STRIPES_A.getIcon(); case 1 -> Textures.BlockIcons.MACHINE_CASING_STRIPES_B.getIcon(); @@ -66,11 +66,11 @@ public class GT_Block_Casings3 extends GT_Block_Casings_Abstract { case 10 -> Textures.BlockIcons.MACHINE_CASING_GRATE.getIcon(); case 11 -> Textures.BlockIcons.MACHINE_CASING_VENT.getIcon(); case 12 -> Textures.BlockIcons.MACHINE_CASING_RADIATIONPROOF.getIcon(); - case 13 -> aSide > 1 ? Textures.BlockIcons.MACHINE_CASING_FIREBOX_BRONZE.getIcon() + case 13 -> ordinalSide > 1 ? Textures.BlockIcons.MACHINE_CASING_FIREBOX_BRONZE.getIcon() : Textures.BlockIcons.MACHINE_BRONZEPLATEDBRICKS.getIcon(); - case 14 -> aSide > 1 ? Textures.BlockIcons.MACHINE_CASING_FIREBOX_STEEL.getIcon() + case 14 -> ordinalSide > 1 ? Textures.BlockIcons.MACHINE_CASING_FIREBOX_STEEL.getIcon() : Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); - case 15 -> aSide > 1 ? Textures.BlockIcons.MACHINE_CASING_FIREBOX_TUNGSTENSTEEL.getIcon() + case 15 -> ordinalSide > 1 ? Textures.BlockIcons.MACHINE_CASING_FIREBOX_TUNGSTENSTEEL.getIcon() : Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL.getIcon(); default -> Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); }; diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings4.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings4.java index 5b1972b59e..023f97d5b1 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings4.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings4.java @@ -86,12 +86,12 @@ public class GT_Block_Casings4 extends GT_Block_Casings_Abstract { } @Override - public IIcon getIcon(int aSide, int aMeta) { + public IIcon getIcon(int ordinalSide, int aMeta) { return switch (aMeta) { case 0, 12 -> Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL.getIcon(); case 1, 10 -> Textures.BlockIcons.MACHINE_CASING_CLEAN_STAINLESSSTEEL.getIcon(); case 2, 11 -> Textures.BlockIcons.MACHINE_CASING_STABLE_TITANIUM.getIcon(); - case 3 -> aSide > 1 ? Textures.BlockIcons.MACHINE_CASING_FIREBOX_TITANIUM.getIcon() + case 3 -> ordinalSide > 1 ? Textures.BlockIcons.MACHINE_CASING_FIREBOX_TITANIUM.getIcon() : Textures.BlockIcons.MACHINE_CASING_STABLE_TITANIUM.getIcon(); case 4 -> // Do not overwrite! @@ -142,11 +142,11 @@ public class GT_Block_Casings4 extends GT_Block_Casings_Abstract { }; } - private static int isTurbineControllerWithSide(IBlockAccess aWorld, int aX, int aY, int aZ, int aSide) { + private static int isTurbineControllerWithSide(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) { TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (!(tTileEntity instanceof IGregTechTileEntity tTile)) return 0; - if (tTile.getMetaTileEntity() instanceof GT_MetaTileEntity_LargeTurbine turbine - && tTile.getFrontFacing() == aSide) { + if (tTile.getMetaTileEntity() instanceof GT_MetaTileEntity_LargeTurbine turbine && tTile.getFrontFacing() + .ordinal() == ordinalSide) { if (turbine.isNewStyleRendering()) return 0; if (tTile.isActive()) return 1; return turbine.hasTurbine() ? 2 : 3; @@ -156,23 +156,27 @@ public class GT_Block_Casings4 extends GT_Block_Casings_Abstract { @Override @SideOnly(Side.CLIENT) - public IIcon getIcon(IBlockAccess aWorld, int xCoord, int yCoord, int zCoord, int aSide) { + public IIcon getIcon(IBlockAccess aWorld, int xCoord, int yCoord, int zCoord, int ordinalSide) { aWorld = GT_RenderingWorld.getInstance(aWorld); int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); if (tMeta != 6 && tMeta != 8 && tMeta != 9 && tMeta != 10 && tMeta != 11 && tMeta != 12 || !mConnectedMachineTextures) { - return getIcon(aSide, tMeta); + return getIcon(ordinalSide, tMeta); } if (tMeta > 8 && tMeta < 13) { - int tInvertLeftRightMod = aSide % 2 * 2 - 1; - switch (aSide / 2) { + int tInvertLeftRightMod = ordinalSide % 2 * 2 - 1; + switch (ordinalSide / 2) { case 0 -> { for (int i = -1; i < 2; i++) { for (int j = -1; j < 2; j++) { if (i == 0 && j == 0) continue; int tState; - if ((tState = isTurbineControllerWithSide(aWorld, xCoord + j, yCoord, zCoord + i, aSide)) - != 0) { + if ((tState = isTurbineControllerWithSide( + aWorld, + xCoord + j, + yCoord, + zCoord + i, + ordinalSide)) != 0) { return getTurbineCasing(tMeta, 4 - i * 3 - j, tState == 1, tState == 2); } } @@ -183,8 +187,12 @@ public class GT_Block_Casings4 extends GT_Block_Casings_Abstract { for (int j = -1; j < 2; j++) { if (i == 0 && j == 0) continue; int tState; - if ((tState = isTurbineControllerWithSide(aWorld, xCoord + j, yCoord + i, zCoord, aSide)) - != 0) { + if ((tState = isTurbineControllerWithSide( + aWorld, + xCoord + j, + yCoord + i, + zCoord, + ordinalSide)) != 0) { return getTurbineCasing( tMeta, 4 + i * 3 - j * tInvertLeftRightMod, @@ -199,8 +207,12 @@ public class GT_Block_Casings4 extends GT_Block_Casings_Abstract { for (int j = -1; j < 2; j++) { if (i == 0 && j == 0) continue; int tState; - if ((tState = isTurbineControllerWithSide(aWorld, xCoord, yCoord + i, zCoord + j, aSide)) - != 0) { + if ((tState = isTurbineControllerWithSide( + aWorld, + xCoord, + yCoord + i, + zCoord + j, + ordinalSide)) != 0) { return getTurbineCasing( tMeta, 4 + i * 3 + j * tInvertLeftRightMod, @@ -226,7 +238,7 @@ public class GT_Block_Casings4 extends GT_Block_Casings_Abstract { if (isSameBlock(aWorld, xCoord, yCoord, zCoord + 1, tMeta)) tIndexIntoMapping |= 1 << 3; if (isSameBlock(aWorld, xCoord - 1, yCoord, zCoord, tMeta)) tIndexIntoMapping |= 1 << 4; if (isSameBlock(aWorld, xCoord, yCoord, zCoord - 1, tMeta)) tIndexIntoMapping |= 1 << 5; - return Textures.BlockIcons.CONNECTED_HULLS[tStartIndex + mapping[aSide][tIndexIntoMapping]].getIcon(); + return Textures.BlockIcons.CONNECTED_HULLS[tStartIndex + mapping[ordinalSide][tIndexIntoMapping]].getIcon(); } private boolean isSameBlock(IBlockAccess aWorld, int aX, int aY, int aZ, int aMeta) { diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings5.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings5.java index 50101dae49..d5746b4360 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings5.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings5.java @@ -57,7 +57,7 @@ public class GT_Block_Casings5 extends GT_Block_Casings_Abstract implements IHea @Override @SideOnly(Side.CLIENT) - public IIcon getIcon(int aSide, int aMeta) { + public IIcon getIcon(int ordinalSide, int aMeta) { return switch (aMeta) { case 0 -> Textures.BlockIcons.MACHINE_COIL_CUPRONICKEL.getIcon(); case 1 -> Textures.BlockIcons.MACHINE_COIL_KANTHAL.getIcon(); diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings6.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings6.java index cde7a8b5fa..d359a30df0 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings6.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings6.java @@ -55,11 +55,11 @@ public class GT_Block_Casings6 extends GT_Block_Casings_Abstract { @Override @SideOnly(Side.CLIENT) - public IIcon getIcon(int aSide, int aMeta) { - if (aSide == 0) { + public IIcon getIcon(int ordinalSide, int aMeta) { + if (ordinalSide == 0) { return Textures.BlockIcons.MACHINECASINGS_BOTTOM[aMeta].getIcon(); } - if (aSide == 1) { + if (ordinalSide == 1) { return Textures.BlockIcons.MACHINECASINGS_TOP[aMeta].getIcon(); } return switch (aMeta) { diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings8.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings8.java index b4778ec12e..a864132549 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings8.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings8.java @@ -74,7 +74,7 @@ public class GT_Block_Casings8 extends GT_Block_Casings_Abstract { @Override @SideOnly(Side.CLIENT) - public IIcon getIcon(int aSide, int aMeta) { + public IIcon getIcon(int ordinalSide, int aMeta) { return switch (aMeta) { case 0 -> Textures.BlockIcons.MACHINE_CASING_CHEMICALLY_INERT.getIcon(); case 1 -> Textures.BlockIcons.MACHINE_CASING_PIPE_POLYTETRAFLUOROETHYLENE.getIcon(); @@ -117,11 +117,11 @@ public class GT_Block_Casings8 extends GT_Block_Casings_Abstract { }; } - private static int isTurbineControllerWithSide(IBlockAccess aWorld, int aX, int aY, int aZ, int aSide) { + private static int isTurbineControllerWithSide(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) { TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (!(tTileEntity instanceof IGregTechTileEntity tTile)) return 0; - if (tTile.getMetaTileEntity() instanceof GT_MetaTileEntity_LargeTurbine turbine - && tTile.getFrontFacing() == aSide) { + if (tTile.getMetaTileEntity() instanceof GT_MetaTileEntity_LargeTurbine turbine && tTile.getFrontFacing() + .ordinal() == ordinalSide) { if (turbine.isNewStyleRendering()) return 0; if (tTile.isActive()) return 1; return turbine.hasTurbine() ? 2 : 3; @@ -131,22 +131,26 @@ public class GT_Block_Casings8 extends GT_Block_Casings_Abstract { @Override @SideOnly(Side.CLIENT) - public IIcon getIcon(IBlockAccess aWorld, int xCoord, int yCoord, int zCoord, int aSide) { + public IIcon getIcon(IBlockAccess aWorld, int xCoord, int yCoord, int zCoord, int ordinalSide) { aWorld = GT_RenderingWorld.getInstance(aWorld); - int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); + final int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); if (tMeta != 9 || !mConnectedMachineTextures) { - return getIcon(aSide, tMeta); + return getIcon(ordinalSide, tMeta); } if (tMeta == 9) { - int tInvertLeftRightMod = aSide % 2 * 2 - 1; - switch (aSide / 2) { + int tInvertLeftRightMod = ordinalSide % 2 * 2 - 1; + switch (ordinalSide / 2) { case 0 -> { for (int i = -1; i < 2; i++) { for (int j = -1; j < 2; j++) { if (i == 0 && j == 0) continue; int tState; - if ((tState = isTurbineControllerWithSide(aWorld, xCoord + j, yCoord, zCoord + i, aSide)) - != 0) { + if ((tState = isTurbineControllerWithSide( + aWorld, + xCoord + j, + yCoord, + zCoord + i, + ordinalSide)) != 0) { return getTurbineCasing(tMeta, 4 - i * 3 - j, tState == 1, tState == 2); } } @@ -157,8 +161,12 @@ public class GT_Block_Casings8 extends GT_Block_Casings_Abstract { for (int j = -1; j < 2; j++) { if (i == 0 && j == 0) continue; int tState; - if ((tState = isTurbineControllerWithSide(aWorld, xCoord + j, yCoord + i, zCoord, aSide)) - != 0) { + if ((tState = isTurbineControllerWithSide( + aWorld, + xCoord + j, + yCoord + i, + zCoord, + ordinalSide)) != 0) { return getTurbineCasing( tMeta, 4 + i * 3 - j * tInvertLeftRightMod, @@ -173,8 +181,12 @@ public class GT_Block_Casings8 extends GT_Block_Casings_Abstract { for (int j = -1; j < 2; j++) { if (i == 0 && j == 0) continue; int tState; - if ((tState = isTurbineControllerWithSide(aWorld, xCoord, yCoord + i, zCoord + j, aSide)) - != 0) { + if ((tState = isTurbineControllerWithSide( + aWorld, + xCoord, + yCoord + i, + zCoord + j, + ordinalSide)) != 0) { return getTurbineCasing( tMeta, 4 + i * 3 + j * tInvertLeftRightMod, diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Casings9.java b/src/main/java/gregtech/common/blocks/GT_Block_Casings9.java index 0aa9ca916f..3aa1756d0c 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings9.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings9.java @@ -29,7 +29,7 @@ public class GT_Block_Casings9 extends GT_Block_Casings_Abstract { @Override @SideOnly(Side.CLIENT) - public IIcon getIcon(int aSide, int aMeta) { + public IIcon getIcon(int ordinalSide, int aMeta) { return switch (aMeta) { case 0 -> Textures.BlockIcons.MACHINE_CASING_PIPE_POLYBENZIMIDAZOLE.getIcon(); case 1 -> Textures.BlockIcons.MACHINE_CASING_VENT_T2.getIcon(); diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Concretes.java b/src/main/java/gregtech/common/blocks/GT_Block_Concretes.java index ae3588cfa3..c7b7e2bb04 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Concretes.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Concretes.java @@ -63,7 +63,7 @@ public class GT_Block_Concretes extends GT_Block_Stones_Abstract implements IBlo } @Override - public IIcon getIcon(int aSide, int aMeta) { + public IIcon getIcon(int ordinalSide, int aMeta) { if ((aMeta >= 0) && (aMeta < 16)) { return gregtech.api.enums.Textures.BlockIcons.CONCRETES[aMeta].getIcon(); } diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Granites.java b/src/main/java/gregtech/common/blocks/GT_Block_Granites.java index df50c5223f..69ebc2e733 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Granites.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Granites.java @@ -63,7 +63,7 @@ public class GT_Block_Granites extends GT_Block_Stones_Abstract { } @Override - public IIcon getIcon(int aSide, int aMeta) { + public IIcon getIcon(int ordinalSide, int aMeta) { if ((aMeta >= 0) && (aMeta < 16)) { return gregtech.api.enums.Textures.BlockIcons.GRANITES[aMeta].getIcon(); } diff --git a/src/main/java/gregtech/common/blocks/GT_Block_Machines.java b/src/main/java/gregtech/common/blocks/GT_Block_Machines.java index c9a93ecaec..78044ed44b 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Machines.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Machines.java @@ -1,8 +1,6 @@ package gregtech.common.blocks; import static gregtech.GT_Mod.GT_FML_LOGGER; -import static gregtech.api.enums.GT_Values.ALL_VALID_SIDES; -import static gregtech.api.enums.GT_Values.SIDE_UP; import static gregtech.api.objects.XSTR.XSTR_INSTANCE; import java.util.ArrayList; @@ -41,6 +39,7 @@ import gregtech.api.GregTech_API; import gregtech.api.enums.Textures; import gregtech.api.interfaces.IDebugableBlock; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IColoredTileEntity; import gregtech.api.interfaces.tileentity.ICoverable; import gregtech.api.interfaces.tileentity.IDebugableTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -160,7 +159,7 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo } @Override - public boolean canConnectRedstone(IBlockAccess aWorld, int aX, int aY, int aZ, int aSide) { + public boolean canConnectRedstone(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) { return true; } @@ -211,13 +210,13 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo @SideOnly(Side.CLIENT) @Override - public IIcon getIcon(IBlockAccess aIBlockAccess, int aX, int aY, int aZ, int aSide) { + public IIcon getIcon(IBlockAccess aIBlockAccess, int aX, int aY, int aZ, int ordinalSide) { return Textures.BlockIcons.MACHINE_LV_SIDE.getIcon(); } @SideOnly(Side.CLIENT) @Override - public IIcon getIcon(int aSide, int aMeta) { + public IIcon getIcon(int ordinalSide, int aMeta) { return Textures.BlockIcons.MACHINE_LV_SIDE.getIcon(); } @@ -343,7 +342,7 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo } @Override - public boolean onBlockActivated(World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer, int aSide, + public boolean onBlockActivated(World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer, int ordinalSide, float aOffsetX, float aOffsetY, float aOffsetZ) { final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (tTileEntity == null) { @@ -356,15 +355,15 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo && !GT_Utility.isStackInList(tCurrentItem, GregTech_API.sWireCutterList) && !GT_Utility.isStackInList(tCurrentItem, GregTech_API.sSolderingToolList)) return false; } - if ((tTileEntity instanceof IGregTechTileEntity)) { - if (((IGregTechTileEntity) tTileEntity).getTimer() < 50L) { + if (tTileEntity instanceof IGregTechTileEntity gtTE) { + if (gtTE.getTimer() < 50L) { return false; } - if ((!aWorld.isRemote) && !((IGregTechTileEntity) tTileEntity).isUseableByPlayer(aPlayer)) { + if ((!aWorld.isRemote) && !gtTE.isUseableByPlayer(aPlayer)) { return true; } return ((IGregTechTileEntity) tTileEntity) - .onRightclick(aPlayer, (byte) aSide, aOffsetX, aOffsetY, aOffsetZ); + .onRightclick(aPlayer, ForgeDirection.getOrientation(ordinalSide), aOffsetX, aOffsetY, aOffsetZ); } return false; } @@ -372,16 +371,16 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo @Override public void onBlockClicked(World aWorld, int aX, int aY, int aZ, EntityPlayer aPlayer) { final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IGregTechTileEntity) { - ((IGregTechTileEntity) tTileEntity).onLeftclick(aPlayer); + if (tTileEntity instanceof IGregTechTileEntity gtTE) { + gtTE.onLeftclick(aPlayer); } } @Override public int getDamageValue(World aWorld, int aX, int aY, int aZ) { final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IGregTechTileEntity) { - return ((IGregTechTileEntity) tTileEntity).getMetaTileID(); + if (tTileEntity instanceof IGregTechTileEntity gtTE) { + return gtTE.getMetaTileID(); } return 0; } @@ -389,14 +388,14 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo @Override public void onBlockExploded(World aWorld, int aX, int aY, int aZ, Explosion aExplosion) { final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof BaseMetaTileEntity) { + if (tTileEntity instanceof BaseMetaTileEntity baseTE) { GT_Log.exp.printf( "Explosion at : %d | %d | %d DIMID: %s due to near explosion!%n", aX, aY, aZ, aWorld.provider.dimensionId); - ((BaseMetaTileEntity) tTileEntity).doEnergyExplosion(); + baseTE.doEnergyExplosion(); } super.onBlockExploded(aWorld, aX, aY, aZ, aExplosion); } @@ -405,15 +404,13 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo public void breakBlock(World aWorld, int aX, int aY, int aZ, Block aBlock, int aMetadata) { GregTech_API.causeMachineUpdate(aWorld, aX, aY, aZ); final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IGregTechTileEntity tGregTechTileEntity) { - tGregTechTileEntity.onBlockDestroyed(); - mTemporaryTileEntity.set(tGregTechTileEntity); - if (!(tGregTechTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_QuantumChest)) { - for (int i = 0; i < tGregTechTileEntity.getSizeInventory(); i++) { - final ItemStack tItem = tGregTechTileEntity.getStackInSlot(i); - if ((tItem != null) && (tItem.stackSize > 0) - && (tGregTechTileEntity.isValidSlot(i)) - && tGregTechTileEntity.shouldDropItemAt(i)) { + if (tTileEntity instanceof IGregTechTileEntity gtTE) { + gtTE.onBlockDestroyed(); + mTemporaryTileEntity.set(gtTE); + if (!(gtTE.getMetaTileEntity() instanceof GT_MetaTileEntity_QuantumChest)) { + for (int i = 0; i < gtTE.getSizeInventory(); i++) { + final ItemStack tItem = gtTE.getStackInSlot(i); + if ((tItem != null) && (tItem.stackSize > 0) && (gtTE.isValidSlot(i)) && gtTE.shouldDropItemAt(i)) { final EntityItem tItemEntity = new EntityItem( aWorld, aX + XSTR_INSTANCE.nextFloat() * 0.8F + 0.1F, @@ -431,7 +428,7 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo tItemEntity.motionZ = (XSTR_INSTANCE.nextGaussian() * 0.05D); aWorld.spawnEntityInWorld(tItemEntity); tItem.stackSize = 0; - tGregTechTileEntity.setInventorySlotContents(i, null); + gtTE.setInventorySlotContents(i, null); } } } @@ -443,8 +440,8 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo @Override public ArrayList<ItemStack> getDrops(World aWorld, int aX, int aY, int aZ, int aMeta, int aFortune) { final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if ((tTileEntity instanceof IGregTechTileEntity)) { - return ((IGregTechTileEntity) tTileEntity).getDrops(); + if (tTileEntity instanceof IGregTechTileEntity gtTE) { + return gtTE.getDrops(); } final IGregTechTileEntity tGregTechTileEntity = mTemporaryTileEntity.get(); final ArrayList<ItemStack> tDrops; @@ -470,34 +467,38 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo } @Override - public int getComparatorInputOverride(World aWorld, int aX, int aY, int aZ, int aSide) { + public int getComparatorInputOverride(World aWorld, int aX, int aY, int aZ, int ordinalSide) { final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IGregTechTileEntity) { - return ((IGregTechTileEntity) tTileEntity).getComparatorValue((byte) aSide); + if (tTileEntity instanceof IGregTechTileEntity gtTE) { + return gtTE.getComparatorValue(ForgeDirection.getOrientation(ordinalSide)); } return 0; } @Override - public int isProvidingWeakPower(IBlockAccess aWorld, int aX, int aY, int aZ, int aSide) { - if (aSide < 0 || aSide > 5) { + public int isProvidingWeakPower(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) { + if (ordinalSide < 0 || ordinalSide > 5) { return 0; } final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IGregTechTileEntity) { - return ((IGregTechTileEntity) tTileEntity).getOutputRedstoneSignal(GT_Utility.getOppositeSide(aSide)); + if (tTileEntity instanceof IGregTechTileEntity gtTE) { + return gtTE.getOutputRedstoneSignal( + ForgeDirection.getOrientation(ordinalSide) + .getOpposite()); } return 0; } @Override - public int isProvidingStrongPower(IBlockAccess aWorld, int aX, int aY, int aZ, int aSide) { - if (aSide < 0 || aSide > 5) { + public int isProvidingStrongPower(IBlockAccess aWorld, int aX, int aY, int aZ, int ordinalSide) { + if (ordinalSide < 0 || ordinalSide > 5) { return 0; } final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity instanceof IGregTechTileEntity) { - return ((IGregTechTileEntity) tTileEntity).getStrongOutputRedstoneSignal(GT_Utility.getOppositeSide(aSide)); + if (tTileEntity instanceof IGregTechTileEntity gtTE) { + return gtTE.getStrongOutputRedstoneSignal( + ForgeDirection.getOrientation(ordinalSide) + .getOpposite()); } return 0; } @@ -508,14 +509,14 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo if (!aWorld.isRemote) { final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); if (tTileEntity != null && (chance < 1.0F)) { - if (tTileEntity instanceof BaseMetaTileEntity && (GregTech_API.sMachineNonWrenchExplosions)) { + if (tTileEntity instanceof BaseMetaTileEntity bmte && (GregTech_API.sMachineNonWrenchExplosions)) { GT_Log.exp.printf( "Explosion at : %d | %d | %d DIMID: %s NonWrench picking/Rain!%n", aX, aY, aZ, aWorld.provider.dimensionId); - ((BaseMetaTileEntity) tTileEntity).doEnergyExplosion(); + bmte.doEnergyExplosion(); } } else { super.dropBlockAsItemWithChance(aWorld, aX, aY, aZ, aMetadata, chance, aFortune); @@ -524,7 +525,7 @@ public class GT_Block_Machines extends GT_Generic_Block implements IDebugableBlo } @Override - public boolean isSideSolid(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection aSide) { + public boolean isSideSolid(IBlockAccess aWorld, int aX, int aY, int aZ, ForgeDirection side) { if (aWorld.getBlockMetadata(aX, aY, aZ) == 0) { return true; |
