From 66e64ee13acd8ce0f4570c9ce73c849e125c67b9 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Fri, 25 Jun 2021 17:32:39 +0800 Subject: fix turbine casing dynamic texture Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- .../gregtech/common/blocks/GT_Block_Casings4.java | 440 ++++----------------- .../gregtech/common/blocks/GT_Item_Machines.java | 4 +- 2 files changed, 78 insertions(+), 366 deletions(-) (limited to 'src/main/java/gregtech/common/blocks') 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 6fb40784c1..809c76d720 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings4.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings4.java @@ -4,7 +4,6 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.ItemList; import gregtech.api.enums.Textures; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_LanguageManager; @@ -15,12 +14,20 @@ import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; public class GT_Block_Casings4 extends GT_Block_Casings_Abstract { + private static int[][] mapping = new int[][]{ + {7, 7, 7, 7, 0, 7, 0, 7, 1, 7, 1, 7, 8, 7, 8, 7, 0, 7, 0, 7, 0, 7, 0, 7, 9, 7, 9, 7, 3, 7, 3, 7, 1, 7, 1, 7, 11, 7, 11, 7, 1, 7, 1, 7, 2, 7, 2, 7, 10, 7, 10, 7, 5, 7, 5, 7, 4, 7, 4, 7, 6, 7, 6, 7}, + {7, 7, 7, 7, 0, 0, 7, 7, 1, 1, 7, 7, 8, 8, 7, 7, 0, 0, 7, 7, 0, 0, 7, 7, 9, 9, 7, 7, 3, 3, 7, 7, 1, 1, 7, 7, 11, 11, 7, 7, 1, 1, 7, 7, 2, 2, 7, 7, 10, 10, 7, 7, 5, 5, 7, 7, 4, 4, 7, 7, 6, 6, 7, 7}, + {7, 1, 1, 1, 0, 9, 10, 4, 7, 1, 1, 1, 0, 9, 10, 4, 0, 8, 11, 2, 0, 3, 5, 6, 0, 8, 11, 2, 0, 3, 5, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7}, + {7, 1, 1, 1, 0, 8, 11, 2, 7, 7, 7, 7, 7, 7, 7, 7, 0, 9, 10, 4, 0, 3, 5, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 1, 1, 1, 0, 8, 11, 2, 7, 7, 7, 7, 7, 7, 7, 7, 0, 9, 10, 4, 0, 3, 5, 6, 7, 7, 7, 7, 7, 7, 7, 7}, + {7, 1, 1, 1, 7, 1, 1, 1, 0, 8, 11, 2, 0, 8, 11, 2, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 0, 9, 10, 4, 0, 9, 10, 4, 0, 3, 5, 6, 0, 3, 5, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7}, + {7, 1, 1, 1, 7, 7, 7, 7, 0, 9, 10, 4, 7, 7, 7, 7, 7, 1, 1, 1, 7, 7, 7, 7, 0, 9, 10, 4, 7, 7, 7, 7, 0, 8, 11, 2, 7, 7, 7, 7, 0, 3, 5, 6, 7, 7, 7, 7, 0, 8, 11, 2, 7, 7, 7, 7, 0, 3, 5, 6, 7, 7, 7, 7}, + }; public static boolean mConnectedMachineTextures = true; public GT_Block_Casings4() { super(GT_Item_Casings4.class, "gt.blockcasings4", GT_Material_Casings.INSTANCE); for (byte i = 0; i < 16; i = (byte) (i + 1)) { - Textures.BlockIcons.casingTexturePages[0][(i + 48)] = TextureFactory.of(this, i); + Textures.BlockIcons.casingTexturePages[0][i + 48] = TextureFactory.of(this, i); } GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "Robust Tungstensteel Machine Casing"); GT_LanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "Clean Stainless Steel Machine Casing"); @@ -59,18 +66,21 @@ public class GT_Block_Casings4 extends GT_Block_Casings_Abstract { public IIcon getIcon(int aSide, int aMeta) { switch (aMeta) { case 0: + case 12: return Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL.getIcon(); case 1: + case 10: return Textures.BlockIcons.MACHINE_CASING_CLEAN_STAINLESSSTEEL.getIcon(); case 2: + case 11: return Textures.BlockIcons.MACHINE_CASING_STABLE_TITANIUM.getIcon(); case 3: return aSide > 1 ? Textures.BlockIcons.MACHINE_CASING_FIREBOX_TITANIUM.getIcon() : Textures.BlockIcons.MACHINE_CASING_STABLE_TITANIUM.getIcon(); case 4: - //Do not overwrite! + //Do not overwrite! return Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS_YELLOW.getIcon(); case 5: - //Do not overwrite! + //Do not overwrite! return Textures.BlockIcons.MACHINE_CASING_FUSION_GLASS.getIcon(); case 6: return Textures.BlockIcons.MACHINE_CASING_FUSION.getIcon(); @@ -80,12 +90,6 @@ public class GT_Block_Casings4 extends GT_Block_Casings_Abstract { return Textures.BlockIcons.MACHINE_CASING_FUSION_2.getIcon(); case 9: return Textures.BlockIcons.MACHINE_CASING_TURBINE.getIcon(); - case 10: - return Textures.BlockIcons.MACHINE_CASING_CLEAN_STAINLESSSTEEL.getIcon(); - case 11: - return Textures.BlockIcons.MACHINE_CASING_STABLE_TITANIUM.getIcon(); - case 12: - return Textures.BlockIcons.MACHINE_CASING_ROBUST_TUNGSTENSTEEL.getIcon(); case 13: return Textures.BlockIcons.MACHINE_CASING_ENGINE_INTAKE.getIcon(); case 14: @@ -98,8 +102,6 @@ public class GT_Block_Casings4 extends GT_Block_Casings_Abstract { public IIcon getTurbineCasing(int meta, int iconIndex, boolean active) { switch (meta) { - case 9: - return active ? Textures.BlockIcons.TURBINE_ACTIVE[iconIndex].getIcon() : Textures.BlockIcons.TURBINE[iconIndex].getIcon(); case 10: return active ? Textures.BlockIcons.TURBINE_ACTIVE1[iconIndex].getIcon() : Textures.BlockIcons.TURBINE1[iconIndex].getIcon(); case 11: @@ -111,121 +113,63 @@ public class GT_Block_Casings4 extends GT_Block_Casings_Abstract { } } + private static int isTurbineControllerWithSide(IBlockAccess aWorld, int aX, int aY, int aZ, int aSide) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (!(tTileEntity instanceof IGregTechTileEntity)) return 0; + IGregTechTileEntity tTile = (IGregTechTileEntity) tTileEntity; + if (tTile.getMetaTileEntity() instanceof GT_MetaTileEntity_LargeTurbine && tTile.getFrontFacing() == aSide) + return tTile.isActive() ? 1 : 2; + return 0; + } + @Override @SideOnly(Side.CLIENT) public IIcon getIcon(IBlockAccess aWorld, int xCoord, int yCoord, int zCoord, int aSide) { int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); - if ((tMeta != 6) && (tMeta != 8) && (tMeta != 9) && (tMeta != 10) && (tMeta != 11) && (tMeta != 12) || (!mConnectedMachineTextures)) { + if (tMeta != 6 && tMeta != 8 && tMeta != 9 && tMeta != 10 && tMeta != 11 && tMeta != 12 || !mConnectedMachineTextures) { return getIcon(aSide, tMeta); } - int tStartIndex = tMeta == 6 ? 1 : 13; - if ((tMeta == 9) || (tMeta == 10) || (tMeta == 11) || (tMeta == 12)) { - if ((aSide == 2) || (aSide == 3)) { - TileEntity tTileEntity; - IMetaTileEntity tMetaTileEntity; - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return getTurbineCasing(tMeta, 0, true); - } - return getTurbineCasing(tMeta, 0, false); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return getTurbineCasing(tMeta, 3, true); - } - return getTurbineCasing(tMeta, 3, false); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 3 ? 1 : -1), yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return getTurbineCasing(tMeta, 6, true); - } - return getTurbineCasing(tMeta, 6, false); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return getTurbineCasing(tMeta, 1, true); - } - return getTurbineCasing(tMeta, 1, false); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return getTurbineCasing(tMeta, 7, true); - } - return getTurbineCasing(tMeta, 7, false); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return getTurbineCasing(tMeta, 8, true); - } - return getTurbineCasing(tMeta, 8, false); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return getTurbineCasing(tMeta, 5, true); - } - return getTurbineCasing(tMeta, 5, false); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord + (aSide == 2 ? 1 : -1), yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return getTurbineCasing(tMeta, 2, true); - } - return getTurbineCasing(tMeta, 2, false); - } - } else if ((aSide == 4) || (aSide == 5)) { - TileEntity tTileEntity; - Object tMetaTileEntity; - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return getTurbineCasing(tMeta, 0, true); - } - return getTurbineCasing(tMeta, 0, false); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return getTurbineCasing(tMeta, 3, true); - } - return getTurbineCasing(tMeta, 3, false); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord + (aSide == 4 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return getTurbineCasing(tMeta, 6, true); - } - return getTurbineCasing(tMeta, 6, false); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return getTurbineCasing(tMeta, 1, true); - } - return getTurbineCasing(tMeta, 1, false); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return getTurbineCasing(tMeta, 7, true); - } - return getTurbineCasing(tMeta, 7, false); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord + 1, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return getTurbineCasing(tMeta, 8, true); - } - return getTurbineCasing(tMeta, 8, false); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return getTurbineCasing(tMeta, 5, true); - } - return getTurbineCasing(tMeta, 5, false); - } - if ((null != (tTileEntity = aWorld.getTileEntity(xCoord, yCoord - 1, zCoord + (aSide == 5 ? 1 : -1)))) && ((tTileEntity instanceof IGregTechTileEntity)) && (((IGregTechTileEntity) tTileEntity).getFrontFacing() == aSide) && (null != (tMetaTileEntity = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity())) && ((tMetaTileEntity instanceof GT_MetaTileEntity_LargeTurbine))) { - if (((IGregTechTileEntity) tTileEntity).isActive()) { - return getTurbineCasing(tMeta, 2, true); - } - return getTurbineCasing(tMeta, 2, false); - } + if (tMeta > 8 && tMeta < 13) { + int tInvertLeftRightMod = aSide % 2 * 2 - 1; + switch (aSide / 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) { + return getTurbineCasing(tMeta, 4 - i * 3 - j, tState == 1); + } + } + } + break; + case 1: + 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 + i, zCoord, aSide)) != 0) { + return getTurbineCasing(tMeta, 4 + i * 3 - j * tInvertLeftRightMod, tState == 1); + } + } + } + break; + case 2: + 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, yCoord + i, zCoord + j, aSide)) != 0) { + return getTurbineCasing(tMeta, 4 + i * 3 + j * tInvertLeftRightMod, tState == 1); + } + } + } + break; } switch (tMeta) { - case 9: - return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); case 10: return Textures.BlockIcons.MACHINE_CASING_CLEAN_STAINLESSSTEEL.getIcon(); case 11: @@ -236,250 +180,18 @@ public class GT_Block_Casings4 extends GT_Block_Casings_Abstract { return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); } } - boolean[] tConnectedSides = {(aWorld.getBlock(xCoord, yCoord - 1, zCoord) == this) && (aWorld.getBlockMetadata(xCoord, yCoord - 1, zCoord) == tMeta), (aWorld.getBlock(xCoord, yCoord + 1, zCoord) == this) && (aWorld.getBlockMetadata(xCoord, yCoord + 1, zCoord) == tMeta), (aWorld.getBlock(xCoord + 1, yCoord, zCoord) == this) && (aWorld.getBlockMetadata(xCoord + 1, yCoord, zCoord) == tMeta), (aWorld.getBlock(xCoord, yCoord, zCoord + 1) == this) && (aWorld.getBlockMetadata(xCoord, yCoord, zCoord + 1) == tMeta), (aWorld.getBlock(xCoord - 1, yCoord, zCoord) == this) && (aWorld.getBlockMetadata(xCoord - 1, yCoord, zCoord) == tMeta), (aWorld.getBlock(xCoord, yCoord, zCoord - 1) == this) && (aWorld.getBlockMetadata(xCoord, yCoord, zCoord - 1) == tMeta)}; - switch (aSide) { - case 0: - if (tConnectedSides[0]) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); - } - if ((!tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); - } - if ((tConnectedSides[4]) && (!tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); - } - if ((tConnectedSides[4]) && (tConnectedSides[5]) && (!tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); - } - if ((tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (!tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); - } - if ((!tConnectedSides[4]) && (!tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); - } - if ((tConnectedSides[4]) && (!tConnectedSides[5]) && (!tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); - } - if ((tConnectedSides[4]) && (tConnectedSides[5]) && (!tConnectedSides[2]) && (!tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); - } - if ((!tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (!tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); - } - if ((!tConnectedSides[4]) && (!tConnectedSides[5]) && (!tConnectedSides[2]) && (!tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((!tConnectedSides[4]) && (!tConnectedSides[2])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); - } - if ((!tConnectedSides[5]) && (!tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); - } - case 1: - if (tConnectedSides[1]) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); - } - if ((!tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); - } - if ((tConnectedSides[4]) && (!tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); - } - if ((tConnectedSides[4]) && (tConnectedSides[5]) && (!tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); - } - if ((tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (!tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); - } - if ((!tConnectedSides[4]) && (!tConnectedSides[5]) && (tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); - } - if ((tConnectedSides[4]) && (!tConnectedSides[5]) && (!tConnectedSides[2]) && (tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); - } - if ((tConnectedSides[4]) && (tConnectedSides[5]) && (!tConnectedSides[2]) && (!tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); - } - if ((!tConnectedSides[4]) && (tConnectedSides[5]) && (tConnectedSides[2]) && (!tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); - } - if ((!tConnectedSides[4]) && (!tConnectedSides[5]) && (!tConnectedSides[2]) && (!tConnectedSides[3])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((!tConnectedSides[2]) && (!tConnectedSides[4])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); - } - if ((!tConnectedSides[3]) && (!tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); - } - case 2: - if (tConnectedSides[5]) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); - } - if ((!tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); - } - if ((tConnectedSides[2]) && (!tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); - } - if ((tConnectedSides[2]) && (tConnectedSides[0]) && (!tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); - } - if ((tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); - } - if ((!tConnectedSides[2]) && (!tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); - } - if ((tConnectedSides[2]) && (!tConnectedSides[0]) && (!tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); - } - if ((tConnectedSides[2]) && (tConnectedSides[0]) && (!tConnectedSides[4]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); - } - if ((!tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); - } - if ((!tConnectedSides[2]) && (!tConnectedSides[0]) && (!tConnectedSides[4]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((!tConnectedSides[2]) && (!tConnectedSides[4])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); - } - if ((!tConnectedSides[0]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); - } - case 3: - if (tConnectedSides[3]) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); - } - if ((!tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); - } - if ((tConnectedSides[2]) && (!tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); - } - if ((tConnectedSides[2]) && (tConnectedSides[0]) && (!tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); - } - if ((tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); - } - if ((!tConnectedSides[2]) && (!tConnectedSides[0]) && (tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); - } - if ((tConnectedSides[2]) && (!tConnectedSides[0]) && (!tConnectedSides[4]) && (tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); - } - if ((tConnectedSides[2]) && (tConnectedSides[0]) && (!tConnectedSides[4]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); - } - if ((!tConnectedSides[2]) && (tConnectedSides[0]) && (tConnectedSides[4]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); - } - if ((!tConnectedSides[2]) && (!tConnectedSides[0]) && (!tConnectedSides[4]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((!tConnectedSides[2]) && (!tConnectedSides[4])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); - } - if ((!tConnectedSides[0]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); - } - case 4: - if (tConnectedSides[4]) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); - } - if ((!tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); - } - if ((tConnectedSides[0]) && (!tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); - } - if ((tConnectedSides[0]) && (tConnectedSides[3]) && (!tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); - } - if ((tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (!tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); - } - if ((!tConnectedSides[0]) && (!tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); - } - if ((tConnectedSides[0]) && (!tConnectedSides[3]) && (!tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); - } - if ((tConnectedSides[0]) && (tConnectedSides[3]) && (!tConnectedSides[1]) && (!tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); - } - if ((!tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (!tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); - } - if ((!tConnectedSides[0]) && (!tConnectedSides[3]) && (!tConnectedSides[1]) && (!tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((!tConnectedSides[0]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); - } - if ((!tConnectedSides[3]) && (!tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); - } - case 5: - if (tConnectedSides[2]) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 6)].getIcon(); - } - if ((!tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 5)].getIcon(); - } - if ((tConnectedSides[0]) && (!tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 2)].getIcon(); - } - if ((tConnectedSides[0]) && (tConnectedSides[3]) && (!tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 3)].getIcon(); - } - if ((tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (!tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 4)].getIcon(); - } - if ((!tConnectedSides[0]) && (!tConnectedSides[3]) && (tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 11)].getIcon(); - } - if ((tConnectedSides[0]) && (!tConnectedSides[3]) && (!tConnectedSides[1]) && (tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 8)].getIcon(); - } - if ((tConnectedSides[0]) && (tConnectedSides[3]) && (!tConnectedSides[1]) && (!tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 9)].getIcon(); - } - if ((!tConnectedSides[0]) && (tConnectedSides[3]) && (tConnectedSides[1]) && (!tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 10)].getIcon(); - } - if ((!tConnectedSides[0]) && (!tConnectedSides[3]) && (!tConnectedSides[1]) && (!tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); - } - if ((!tConnectedSides[0]) && (!tConnectedSides[1])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 0)].getIcon(); - } - if ((!tConnectedSides[3]) && (!tConnectedSides[5])) { - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 1)].getIcon(); - } - break; - } - return Textures.BlockIcons.CONNECTED_HULLS[(tStartIndex + 7)].getIcon(); + int tStartIndex = tMeta == 6 ? 1 : 13; + int tIndexIntoMapping = 0; + if (isSameBlock(aWorld, xCoord, yCoord - 1, zCoord, tMeta)) tIndexIntoMapping |= 1; + if (isSameBlock(aWorld, xCoord, yCoord + 1, zCoord, tMeta)) tIndexIntoMapping |= 1 << 1; + if (isSameBlock(aWorld, xCoord + 1, yCoord, zCoord, tMeta)) tIndexIntoMapping |= 1 << 2; + 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(); + } + + private boolean isSameBlock(IBlockAccess aWorld, int aX, int aY, int aZ, int aMeta) { + return aWorld.getBlock(aX, aY, aZ) == this && aWorld.getBlockMetadata(aX, aY, aZ) == aMeta; } } diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Machines.java b/src/main/java/gregtech/common/blocks/GT_Item_Machines.java index 39eecdd5e4..c8e77f9b0a 100644 --- a/src/main/java/gregtech/common/blocks/GT_Item_Machines.java +++ b/src/main/java/gregtech/common/blocks/GT_Item_Machines.java @@ -55,8 +55,8 @@ public class GT_Item_Machines extends ItemBlock { if(tDescription.contains("%%%")){ String[] tString = tDescription.split("%%%"); if(tString.length>=2){ - StringBuffer tBuffer = new StringBuffer(); - Object tRep[] = new String[tString.length / 2]; + StringBuilder tBuffer = new StringBuilder(); + String[] tRep = new String[tString.length / 2]; for (int j = 0; j < tString.length; j++) if (j % 2 == 0) tBuffer.append(tString[j]); else {tBuffer.append(" %s"); tRep[j / 2] = tString[j];} -- cgit From e5a6de86d47d12130afe179303d7de5b78c85bff Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Fri, 25 Jun 2021 20:54:11 +0800 Subject: general bugfix & tweaking pass for multis 1. stupid typo in EBF preventing it from working at all. 2. All multis now require exactly one maintenance hatch to form. 3. All multis now use the unified overclocking mechanism if possible. 4. All multis that emits pollution now require at least one muffler hatch to form. 5. Coil structure element slightly tweaked. Signed-off-by: Glease <4586901+Glease@users.noreply.github.com> --- .../java/gregtech/api/enums/HeatingCoilLevel.java | 10 ++++++-- .../gregtech/api/util/GT_StructureUtility.java | 30 ++++++++-------------- .../gregtech/common/blocks/GT_Block_Casings5.java | 29 +++++++++++++++++++++ .../multi/GT_MetaTileEntity_AssemblyLine.java | 26 +++++++------------ .../multi/GT_MetaTileEntity_DistillationTower.java | 19 ++++++++++---- .../multi/GT_MetaTileEntity_DrillerBase.java | 2 +- .../GT_MetaTileEntity_ElectricBlastFurnace.java | 1 + .../multi/GT_MetaTileEntity_LargeTurbine.java | 2 +- .../multi/GT_MetaTileEntity_MultiFurnace.java | 3 +++ .../multi/GT_MetaTileEntity_OilCracker.java | 29 ++++++++++++--------- .../multi/GT_MetaTileEntity_PyrolyseOven.java | 3 ++- 11 files changed, 96 insertions(+), 58 deletions(-) (limited to 'src/main/java/gregtech/common/blocks') diff --git a/src/main/java/gregtech/api/enums/HeatingCoilLevel.java b/src/main/java/gregtech/api/enums/HeatingCoilLevel.java index d4446e31d0..c2e3ff075a 100644 --- a/src/main/java/gregtech/api/enums/HeatingCoilLevel.java +++ b/src/main/java/gregtech/api/enums/HeatingCoilLevel.java @@ -23,6 +23,8 @@ public enum HeatingCoilLevel { MAX, ; + private static final HeatingCoilLevel[] VALUES = values(); + /** * @return the Coils Tier Name */ @@ -61,9 +63,13 @@ public enum HeatingCoilLevel { } public static HeatingCoilLevel getFromTier(byte tier){ - if (tier < 0 || tier > HeatingCoilLevel.values().length -1) + if (tier < 0 || tier > VALUES.length -1) return HeatingCoilLevel.None; - return HeatingCoilLevel.values()[tier+2]; + return VALUES[tier+2]; + } + + public static int size() { + return VALUES.length; } } diff --git a/src/main/java/gregtech/api/util/GT_StructureUtility.java b/src/main/java/gregtech/api/util/GT_StructureUtility.java index 2670d9e684..5067c698ab 100644 --- a/src/main/java/gregtech/api/util/GT_StructureUtility.java +++ b/src/main/java/gregtech/api/util/GT_StructureUtility.java @@ -7,6 +7,7 @@ import gregtech.api.GregTech_API; import gregtech.api.enums.HeatingCoilLevel; import gregtech.api.interfaces.IHeatingCoil; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.common.blocks.GT_Block_Casings5; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; @@ -19,8 +20,6 @@ import java.util.function.Function; import static com.gtnewhorizon.structurelib.StructureLibAPI.HINT_BLOCK_META_GENERIC_11; public class GT_StructureUtility { - public static final int HINT_COIL_DEFAULT_DOTS = HINT_BLOCK_META_GENERIC_11; - private GT_StructureUtility() { throw new AssertionError("Not instantiable"); } @@ -81,22 +80,14 @@ public class GT_StructureUtility { } /** - * Assume a default of LV coil. Assume all coils accepted. Assumes using {@link #HINT_COIL_DEFAULT_DOTS} as dots. - * @see #ofCoil(BiPredicate, Function, int, Block, int) + * Assume all coils accepted. + * @see #ofCoil(BiPredicate, Function) */ public static IStructureElement ofCoil(BiConsumer heatingCoilSetter, Function heatingCoilGetter) { return ofCoil((t, l) -> { heatingCoilSetter.accept(t, l); return true; - }, heatingCoilGetter, HINT_COIL_DEFAULT_DOTS, GregTech_API.sBlockCasings5, 0); - } - - /** - * Assumes using {@link #HINT_COIL_DEFAULT_DOTS} as dots - * @see #ofCoil(BiPredicate, Function, int, Block, int) - */ - public static IStructureElement ofCoil(BiPredicate heatingCoilSetter, Function heatingCoilGetter, Block defaultCoil, int defaultMeta) { - return ofCoil(heatingCoilSetter, heatingCoilGetter, HINT_COIL_DEFAULT_DOTS, defaultCoil, defaultMeta); + }, heatingCoilGetter); } /** @@ -106,11 +97,8 @@ public class GT_StructureUtility { * Might be called less times if structure test fails. * If the setter returns false then it assumes the coil is rejected. * @param heatingCoilGetter Get the current heating level. Null means no coil recorded yet. - * @param dots The hinting dots - * @param defaultCoil The block to place when auto constructing - * @param defaultMeta The block meta to place when auto constructing */ - public static IStructureElement ofCoil(BiPredicate heatingCoilSetter, Function heatingCoilGetter, int dots, Block defaultCoil, int defaultMeta) { + public static IStructureElement ofCoil(BiPredicate heatingCoilSetter, Function heatingCoilGetter) { if (heatingCoilSetter == null || heatingCoilGetter == null) { throw new IllegalArgumentException(); } @@ -131,13 +119,17 @@ public class GT_StructureUtility { @Override public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) { - StructureLibAPI.hintParticle(world, x, y, z, StructureLibAPI.getBlockHint(), dots); + StructureLibAPI.hintParticle(world, x, y, z, GregTech_API.sBlockCasings5, getMeta(trigger)); return true; } + private int getMeta(ItemStack trigger) { + return GT_Block_Casings5.getMetaFromCoilHeat(HeatingCoilLevel.getFromTier((byte) Math.min(HeatingCoilLevel.size(), Math.max(0, trigger.stackSize)))); + } + @Override public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) { - return world.setBlock(x, y, z, defaultCoil, defaultMeta, 3); + return world.setBlock(x, y, z, GregTech_API.sBlockCasings5, getMeta(trigger), 3); } }; } 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 296bf765b0..63645f3c3f 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings5.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings5.java @@ -108,6 +108,35 @@ public class GT_Block_Casings5 extends GT_Block_Casings_Abstract implements IHea } } + public static int getMetaFromCoilHeat(HeatingCoilLevel level) { + switch (level) { + case LV: + return 0; + case MV: + return 1; + case HV: + return 2; + case EV: + return 3; + case IV: + return 4; + case ZPM: + return 5; + case UV: + return 6; + case UEV: + return 7; + case UIV: + return 8; + case LuV: + return 9; + case UHV: + return 10; + default: + return 0; + } + } + @Override public HeatingCoilLevel getCoilHeat(int meta) { getOnCoilCheck().accept(this); diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java index 5d363d9aa1..dd10b2465d 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_AssemblyLine.java @@ -242,13 +242,19 @@ public class GT_MetaTileEntity_AssemblyLine extends GT_MetaTileEntity_EnhancedMu if (!tTag.hasKey("time")) continue; - mMaxProgresstime = tTag.getInteger("time"); - if (mMaxProgresstime <= 0) + int tMaxProgressTime = tTag.getInteger("time"); + if (tMaxProgressTime <= 0) continue; if (!tTag.hasKey("eu")) continue; - mEUt = tTag.getInteger("eu"); + + calculateOverclockedNessMulti(tTag.getInteger("eu"), tMaxProgressTime, 1, getMaxInputVoltage()); + //In case recipe is too OP for that machine + if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) { + if (GT_Values.D1) GT_FML_LOGGER.info("Recipe too OP"); + continue; + } if (GT_Values.D1) GT_FML_LOGGER.info("Find avaiable recipe"); findRecipe = true; @@ -274,22 +280,8 @@ public class GT_MetaTileEntity_AssemblyLine extends GT_MetaTileEntity_EnhancedMu } if (GT_Values.D1) GT_FML_LOGGER.info("Check overclock"); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(getMaxInputVoltage())); this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); this.mEfficiencyIncrease = 10000; - if (mEUt <= 16) { - this.mEUt = (mEUt * (1 << tTier - 1) * (1 << tTier - 1)); - this.mMaxProgresstime = (mMaxProgresstime / (1 << tTier - 1)); - } else { - while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { - this.mEUt *= 4; - this.mMaxProgresstime /= 2; - } - } - if (this.mEUt > 0) { - this.mEUt = -this.mEUt; - } - this.mMaxProgresstime = Math.max(1, this.mMaxProgresstime); updateSlots(); if (GT_Values.D1) GT_FML_LOGGER.info("Recipe sucessfull"); 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 73bbfe056a..bbbaed929a 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 @@ -59,7 +59,11 @@ public class GT_MetaTileEntity_DistillationTower extends GT_MetaTileEntity_Enhan onElementPass(GT_MetaTileEntity_DistillationTower::onCasingFound, ofBlock(GregTech_API.sBlockCasings4, 1)) )) .addElement('c', ofChain( - onElementPass(GT_MetaTileEntity_DistillationTower::onTopLayerFound, ofBlock(GregTech_API.sBlockCasings4, 1)), + onElementPass(t -> t.onTopLayerFound(false), ofHatchAdder(GT_MetaTileEntity_DistillationTower::addEnergyInputToMachineList, CASING_INDEX, 1)), + onElementPass(t -> t.onTopLayerFound(false), ofHatchAdder(GT_MetaTileEntity_DistillationTower::addOutputToMachineList, CASING_INDEX, 1)), + onElementPass(t -> t.onTopLayerFound(false), ofHatchAdder(GT_MetaTileEntity_DistillationTower::addInputToMachineList, CASING_INDEX, 1)), + onElementPass(t -> t.onTopLayerFound(false), ofHatchAdder(GT_MetaTileEntity_DistillationTower::addMaintenanceToMachineList, CASING_INDEX, 1)), + onElementPass(t -> t.onTopLayerFound(true), ofBlock(GregTech_API.sBlockCasings4, 1)), isAir() )) .build(); @@ -96,7 +100,7 @@ public class GT_MetaTileEntity_DistillationTower extends GT_MetaTileEntity_Enhan .addMaintenanceHatch("Any casing") .addInputHatch("Any bottom layer casing") .addOutputBus("Any bottom layer casing") - .addOutputHatch("2-11x Output Hatches (One per layer except bottom layer)") + .addOutputHatch("2-11x Output Hatches (At least one per layer except bottom layer)") .toolTipFinisher("Gregtech"); return tt; } @@ -182,9 +186,10 @@ public class GT_MetaTileEntity_DistillationTower extends GT_MetaTileEntity_Enhan mCasing++; } - protected void onTopLayerFound() { + protected void onTopLayerFound(boolean aIsCasing) { mTopLayerFound = true; - onCasingFound(); + if (aIsCasing) + onCasingFound(); } protected boolean addLayerOutputHatch(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { @@ -220,9 +225,13 @@ public class GT_MetaTileEntity_DistillationTower extends GT_MetaTileEntity_Enhan return false; // check each layer - while (mHeight < 12 && checkPiece(STRUCTURE_PIECE_LAYER, 1, mHeight, 0) && !mTopLayerFound) + while (mHeight < 12 && checkPiece(STRUCTURE_PIECE_LAYER, 1, mHeight, 0) && !mTopLayerFound) { + if (mOutputHatchesByLayer.get(mHeight - 1).isEmpty()) + // layer without output hatch + return false; // not top mHeight++; + } // validate final invariants... return mCasing >= 7 * mHeight - 5 && mHeight >= 2 && mTopLayerFound && mMaintenanceHatches.size() == 1; 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 9bd2a66250..0ea04f1cfa 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 @@ -361,7 +361,7 @@ public abstract class GT_MetaTileEntity_DrillerBase extends GT_MetaTileEntity_En @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { updateCoordinates(); - return checkPiece(STRUCTURE_PIECE_MAIN, 1, 6, 0) && checkHatches() && GT_Utility.getTier(getMaxInputVoltage()) >= getMinTier(); + return checkPiece(STRUCTURE_PIECE_MAIN, 1, 6, 0) && checkHatches() && GT_Utility.getTier(getMaxInputVoltage()) >= getMinTier() && mMaintenanceHatches.size() == 1; } private void updateCoordinates() { diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java index 23c6685d8a..c7a3c3490d 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_ElectricBlastFurnace.java @@ -269,6 +269,7 @@ public class GT_MetaTileEntity_ElectricBlastFurnace extends GT_MetaTileEntity_Ab return false; if (mMaintenanceHatches.size() != 1) + return false; this.mHeatingCapacity = (int) getCoilLevel().getHeat() + 100 * (GT_Utility.getTier(getMaxInputVoltage()) - 2); return true; 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 8cede375dc..fd3117e451 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 @@ -79,7 +79,7 @@ public abstract class GT_MetaTileEntity_LargeTurbine extends GT_MetaTileEntity_E @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - return checkPiece(STRUCTURE_PIECE_MAIN, 2, 2, 1); + return checkPiece(STRUCTURE_PIECE_MAIN, 2, 2, 1) && mMaintenanceHatches.size() == 1 && mMufflerHatches.isEmpty() == (getPollutionPerTick(null) == 0); } public abstract Block getCasingBlock(); diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java index ba77716622..edfce02aad 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_MultiFurnace.java @@ -184,6 +184,9 @@ public class GT_MetaTileEntity_MultiFurnace extends GT_MetaTileEntity_AbstractMu if (getCoilLevel() == HeatingCoilLevel.None) return false; + if (mMaintenanceHatches.size() != 1) + return false; + this.mLevel = getCoilLevel().getLevel(); this.mCostDiscount = getCoilLevel().getCostDiscount(); return true; diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java index e4f96db248..8a257db8ee 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_OilCracker.java @@ -49,11 +49,11 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_EnhancedMult .addElement('c', ofCoil(GT_MetaTileEntity_OilCracker::setCoilLevel, GT_MetaTileEntity_OilCracker::getCoilLevel)) .addElement('l', ofChain( ofHatchAdder(GT_MetaTileEntity_OilCracker::addLeftHatchToMachineList, CASING_INDEX, 2), - onElementPass(GT_MetaTileEntity_OilCracker::onCasingAdded, ofBlock(GregTech_API.sBlockCasings4, 2)) + onElementPass(GT_MetaTileEntity_OilCracker::onCasingAdded, ofBlock(GregTech_API.sBlockCasings4, 1)) )) .addElement('r', ofChain( ofHatchAdder(GT_MetaTileEntity_OilCracker::addRightHatchToMachineList, CASING_INDEX, 2), - onElementPass(GT_MetaTileEntity_OilCracker::onCasingAdded, ofBlock(GregTech_API.sBlockCasings4, 3)) + onElementPass(GT_MetaTileEntity_OilCracker::onCasingAdded, ofBlock(GregTech_API.sBlockCasings4, 1)) )) .addElement('m', ofChain( ofHatchAdder(GT_MetaTileEntity_OilCracker::addMiddleInputToMachineList, CASING_INDEX, 1), @@ -90,10 +90,10 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_EnhancedMult .addController("Front center") .addCasingInfo("Clean Stainless Steel Machine Casing", 18) .addOtherStructurePart("2 Rings of 8 Coils", "Each side of the controller") - .addInfo("Gets 5% energy cost reduction per coil tier") + .addInfo("Gets 5% EU/t reduction per coil tier") .addEnergyHatch("Any casing") .addMaintenanceHatch("Any casing") - .addInputHatch("Steam/Hydrogen, Any middle ring casing") + .addInputHatch("Steam/Hydrogen ONLY, Any middle ring casing") .addInputHatch("Any left/right side casing") .addOutputHatch("Any left/right side casing") .addStructureInfo("Input/Output Hatches must be on opposite sides!") @@ -119,6 +119,11 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_EnhancedMult return new GT_GUIContainer_MultiMachine(aPlayerInventory, aBaseMetaTileEntity, getLocalName(), "OilCrackingUnit.png"); } + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return GT_Recipe.GT_Recipe_Map.sCrakingRecipes; + } + @Override public boolean checkRecipe(ItemStack aStack) { ArrayList tInputList = getStoredFluids(); @@ -126,7 +131,7 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_EnhancedMult long tVoltage = getMaxInputVoltage(); byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - GT_Recipe tRecipe = GT_Recipe.GT_Recipe_Map.sCrakingRecipes.findRecipe( + GT_Recipe tRecipe = getRecipeMap().findRecipe( getBaseMetaTileEntity(), false, gregtech.api.enums.GT_Values.V[tTier], @@ -140,12 +145,10 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_EnhancedMult if (tRecipe.isRecipeInputEqual(true, tFluidInputs, mInventory[1])) { this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); this.mEfficiencyIncrease = 10000; - this.mEUt = tRecipe.mEUt; - this.mMaxProgresstime = tRecipe.mDuration; - while (this.mEUt <= gregtech.api.enums.GT_Values.V[(tTier - 1)]) { - this.mEUt *= 4; - this.mMaxProgresstime /= 2; - } + calculateOverclockedNessMulti(tRecipe.mEUt, tRecipe.mDuration, 1, tVoltage); + //In case recipe is too OP for that machine + if (mMaxProgresstime == Integer.MAX_VALUE - 1 && mEUt == Integer.MAX_VALUE - 1) + return false; this.mEUt *= Math.pow(0.95D, this.heatLevel.getTier()); @@ -248,7 +251,9 @@ public class GT_MetaTileEntity_OilCracker extends GT_MetaTileEntity_EnhancedMult mInputOnSide = -1; mOutputOnSide = -1; replaceDeprecatedCoils(aBaseMetaTileEntity); - return checkPiece(STRUCTURE_PIECE_MAIN, 2, 1, 0) && mInputOnSide != -1 && mOutputOnSide != -1 && mCasingAmount >= 18; + return checkPiece(STRUCTURE_PIECE_MAIN, 2, 1, 0) && + mInputOnSide != -1 && mOutputOnSide != -1 && mCasingAmount >= 18 && + mMaintenanceHatches.size() == 1 && !mMiddleInputHatches.isEmpty(); } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java index 9ad84d061a..76bdb8423a 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PyrolyseOven.java @@ -188,7 +188,8 @@ public class GT_MetaTileEntity_PyrolyseOven extends GT_MetaTileEntity_EnhancedMu coilHeat = HeatingCoilLevel.None; mCasingAmount = 0; replaceDeprecatedCoils(aBaseMetaTileEntity); - return checkPiece("main", 2, 3, 0) && mCasingAmount >= 60; + return checkPiece("main", 2, 3, 0) && mCasingAmount >= 60 && + mMaintenanceHatches.size() == 1 && !mMufflerHatches.isEmpty(); } @Override -- cgit From 1f862e953334cee47a942df3847dcab13ffcc54c Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Fri, 30 Jul 2021 14:59:31 +0800 Subject: Add documentation for CTM mapping array --- src/main/java/gregtech/common/blocks/GT_Block_Casings4.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/main/java/gregtech/common/blocks') 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 809c76d720..d217064d30 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings4.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings4.java @@ -14,7 +14,14 @@ import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; public class GT_Block_Casings4 extends GT_Block_Casings_Abstract { - private static int[][] mapping = new int[][]{ + /** + * This mapping is used to look up which texture should be used to render the connected texture for fusion casings. + * + * This mapping is computed from that giant if ladder from #getIcon in commit da3421547afadc49938b5b6a7f9a9679afa1d570 + * The exact meaning of these numbers are like black magic. Read the original getIcon implementation to understand why + * it is 0, 1, etc, if that if ladder is even intelligible. + */ + private static final int[][] mapping = new int[][]{ {7, 7, 7, 7, 0, 7, 0, 7, 1, 7, 1, 7, 8, 7, 8, 7, 0, 7, 0, 7, 0, 7, 0, 7, 9, 7, 9, 7, 3, 7, 3, 7, 1, 7, 1, 7, 11, 7, 11, 7, 1, 7, 1, 7, 2, 7, 2, 7, 10, 7, 10, 7, 5, 7, 5, 7, 4, 7, 4, 7, 6, 7, 6, 7}, {7, 7, 7, 7, 0, 0, 7, 7, 1, 1, 7, 7, 8, 8, 7, 7, 0, 0, 7, 7, 0, 0, 7, 7, 9, 9, 7, 7, 3, 3, 7, 7, 1, 1, 7, 7, 11, 11, 7, 7, 1, 1, 7, 7, 2, 2, 7, 7, 10, 10, 7, 7, 5, 5, 7, 7, 4, 4, 7, 7, 6, 6, 7, 7}, {7, 1, 1, 1, 0, 9, 10, 4, 7, 1, 1, 1, 0, 9, 10, 4, 0, 8, 11, 2, 0, 3, 5, 6, 0, 8, 11, 2, 0, 3, 5, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7}, -- cgit From 05505604c98a63b66171ea8a0ed9a2cdce407d37 Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Sat, 7 Aug 2021 02:06:44 -0600 Subject: Add number formatting for tooltips & recipes --- build.properties | 2 +- .../GT_MetaTileEntity_Hatch_Input.java | 4 +++- .../GT_MetaTileEntity_Hatch_Output.java | 2 +- src/main/java/gregtech/api/util/GT_Utility.java | 27 ++++++++++++++++++++++ .../gregtech/common/blocks/GT_Item_Machines.java | 8 +++---- .../java/gregtech/nei/GT_NEI_AssLineHandler.java | 8 +++---- .../java/gregtech/nei/GT_NEI_DefaultHandler.java | 10 ++++---- 7 files changed, 45 insertions(+), 16 deletions(-) (limited to 'src/main/java/gregtech/common/blocks') diff --git a/build.properties b/build.properties index 9c6f282480..407cf4ff61 100644 --- a/build.properties +++ b/build.properties @@ -1,6 +1,6 @@ minecraft.version=1.7.10 forge.version=10.13.4.1614-1.7.10 -gt.version=5.09.37.06 +gt.version=5.09.37.07 structurelib.version=1.0.6 ae2.version=rv3-beta-22 applecore.version=1.7.10-1.2.1+107.59407 diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Input.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Input.java index e37d2160a2..fd7eb0fc94 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Input.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Input.java @@ -16,7 +16,9 @@ public class GT_MetaTileEntity_Hatch_Input extends GT_MetaTileEntity_Hatch { public GT_Recipe_Map mRecipeMap = null; public GT_MetaTileEntity_Hatch_Input(int aID, String aName, String aNameRegional, int aTier) { - super(aID, aName, aNameRegional, aTier, 3, new String[]{"Fluid Input for Multiblocks", "Capacity: " + (8000+8000*(aTier*(aTier+1)>>1)) + "L"}); + super(aID, aName, aNameRegional, aTier, 3, new String[]{ + "Fluid Input for Multiblocks", + "Capacity: " + GT_Utility.formatNumbers(8000+8000*(aTier*(aTier+1)>>1)) + "L"}); } public GT_MetaTileEntity_Hatch_Input(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java index 9965b88a17..db80c4685b 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Output.java @@ -27,7 +27,7 @@ public class GT_MetaTileEntity_Hatch_Output extends GT_MetaTileEntity_Hatch { public GT_MetaTileEntity_Hatch_Output(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, 3, new String[]{ "Fluid Output for Multiblocks", - "Capacity: " + (8000+8000*(aTier*(aTier+1)>>1)) + "L", + "Capacity: " + GT_Utility.formatNumbers(8000+8000*(aTier*(aTier+1)>>1)) + "L", "Right click with screwdriver to restrict output", "Can be restricted to put out Items and/or Steam/No Steam/1 specific Fluid", "Restricted Output Hatches are given priority for Multiblock Fluid output"}); diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index 94195d76ce..29aa1a561a 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -2224,9 +2224,36 @@ public class GT_Utility { DecimalFormat formatter = (DecimalFormat) NumberFormat.getInstance(Locale.US); DecimalFormatSymbols symbols = formatter.getDecimalFormatSymbols(); symbols.setGroupingSeparator(' '); + formatter.setDecimalFormatSymbols(symbols); return formatter.format(aNumber); } + /** + * Formats a positive integer with grouping separators, and also attempts to display it as a (small multiple of a) + * power of 2. + */ + public static String formatPow2(long number) { + String formatted = formatNumbers(number); + if (number == V[V.length - 1]) { + formatted += " (MAX)"; + } else if (number >= 256) { + // Try to figure out if number is a (small multiple of a) power of 2. + long curr = number; + int pow = 0; + while ((curr & 1) == 0) { + curr = curr >>> 1; + pow++; + } + + if (curr == 1) { + formatted += String.format(" (2^%d)", pow); + } else if (curr <= 7) { + formatted += String.format(" (%d*2^%d)", curr, pow); + } + } + return formatted; + } + /* * Check if stack has enough items of given type and subtract from stack, if there's no creative or 111 stack. */ diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Machines.java b/src/main/java/gregtech/common/blocks/GT_Item_Machines.java index c8e77f9b0a..ee99c8a053 100644 --- a/src/main/java/gregtech/common/blocks/GT_Item_Machines.java +++ b/src/main/java/gregtech/common/blocks/GT_Item_Machines.java @@ -70,16 +70,16 @@ public class GT_Item_Machines extends ItemBlock { if (tTileEntity.getEUCapacity() > 0L) { if (tTileEntity.getInputVoltage() > 0L) { int inputTier = GT_Utility.getTier(tTileEntity.getInputVoltage()); - aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_IN", "Voltage IN: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.GREEN + tTileEntity.getInputVoltage() + " (" + GT_Values.TIER_COLORS[inputTier] + GT_Values.VN[inputTier] + EnumChatFormatting.GREEN +")" + EnumChatFormatting.GRAY); + aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_IN", "Voltage IN: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.GREEN + GT_Utility.formatPow2(tTileEntity.getInputVoltage()) + " (" + GT_Values.TIER_COLORS[inputTier] + GT_Values.VN[inputTier] + EnumChatFormatting.GREEN +")" + EnumChatFormatting.GRAY); } if (tTileEntity.getOutputVoltage() > 0L) { int outputTier = GT_Utility.getTier(tTileEntity.getOutputVoltage()); - aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_OUT", "Voltage OUT: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.GREEN + tTileEntity.getOutputVoltage() + " (" + GT_Values.TIER_COLORS[outputTier] + GT_Values.VN[outputTier] + EnumChatFormatting.GREEN + ")" + EnumChatFormatting.GRAY); + aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_OUT", "Voltage OUT: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.GREEN + GT_Utility.formatPow2(tTileEntity.getOutputVoltage()) + " (" + GT_Values.TIER_COLORS[outputTier] + GT_Values.VN[outputTier] + EnumChatFormatting.GREEN + ")" + EnumChatFormatting.GRAY); } if (tTileEntity.getOutputAmperage() > 1L) { - aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_AMOUNT", "Amperage: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.YELLOW + tTileEntity.getOutputAmperage() + EnumChatFormatting.GRAY); + aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_AMOUNT", "Amperage: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.YELLOW + GT_Utility.formatPow2(tTileEntity.getOutputAmperage()) + EnumChatFormatting.GRAY); } - aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_STORE", "Capacity: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.BLUE + tTileEntity.getEUCapacity() + EnumChatFormatting.GRAY); + aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_STORE", "Capacity: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.BLUE + GT_Utility.formatPow2(tTileEntity.getEUCapacity()) + EnumChatFormatting.GRAY); } } NBTTagCompound aNBT = aStack.getTagCompound(); diff --git a/src/main/java/gregtech/nei/GT_NEI_AssLineHandler.java b/src/main/java/gregtech/nei/GT_NEI_AssLineHandler.java index c692a2dce1..b9cd8ef687 100644 --- a/src/main/java/gregtech/nei/GT_NEI_AssLineHandler.java +++ b/src/main/java/gregtech/nei/GT_NEI_AssLineHandler.java @@ -235,11 +235,11 @@ public class GT_NEI_AssLineHandler extends TemplateRecipeHandler { String[] recipeDesc = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.getNeiDesc(); if (recipeDesc == null) { if (tEUt != 0) { - drawText(10, 73, trans("152","Total: ") + ((long)tDuration * tEUt) + " EU", -16777216); - drawText(10, 83, trans("153","Usage: ") + tEUt + " EU/t", -16777216); + drawText(10, 73, trans("152","Total: ") + GT_Utility.formatNumbers((long)tDuration * tEUt) + " EU", -16777216); + drawText(10, 83, trans("153","Usage: ") + GT_Utility.formatNumbers(tEUt) + " EU/t", -16777216); if (this.mRecipeMap.mShowVoltageAmperageInNEI) { - drawText(10, 93, trans("154","Voltage: ") + tEUt / this.mRecipeMap.mAmperage + " EU", -16777216); - drawText(10, 103, trans("155","Amperage: ") + this.mRecipeMap.mAmperage, -16777216); + drawText(10, 93, trans("154","Voltage: ") + GT_Utility.formatNumbers(tEUt / this.mRecipeMap.mAmperage) + " EU", -16777216); + drawText(10, 103, trans("155","Amperage: ") + GT_Utility.formatNumbers(this.mRecipeMap.mAmperage), -16777216); } else { drawText(10, 93, trans("156","Voltage: unspecified"), -16777216); drawText(10, 103, trans("157","Amperage: unspecified"), -16777216); diff --git a/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java b/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java index a4fc75a24e..2e9a265ff9 100644 --- a/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java +++ b/src/main/java/gregtech/nei/GT_NEI_DefaultHandler.java @@ -217,16 +217,16 @@ public class GT_NEI_DefaultHandler extends TemplateRecipeHandler { String[] recipeDesc = ((CachedDefaultRecipe) this.arecipes.get(aRecipeIndex)).mRecipe.getNeiDesc(); if (recipeDesc == null) { if (tEUt != 0) { - drawText(10, 73, trans("152","Total: ") + ((long)tDuration * tEUt) + " EU", -16777216); - drawText(10, 83, trans("153","Usage: ") + tEUt + " EU/t", -16777216); + drawText(10, 73, trans("152","Total: ") + GT_Utility.formatNumbers((long)tDuration * tEUt) + " EU", -16777216); + drawText(10, 83, trans("153","Usage: ") + GT_Utility.formatNumbers(tEUt) + " EU/t", -16777216); if (this.mRecipeMap.mShowVoltageAmperageInNEI) { byte tier=GT_Utility.getTier(tEUt / this.mRecipeMap.mAmperage); if(tier<0||tier>=16){ - drawText(10, 93, trans("154","Voltage: ") + tEUt / this.mRecipeMap.mAmperage + " EU", 0xffFF0000); + drawText(10, 93, trans("154","Voltage: ") + GT_Utility.formatNumbers(tEUt / this.mRecipeMap.mAmperage) + " EU", 0xffFF0000); //add here gt logger }else{ - drawText(10, 93, trans("154","Voltage: ") + tEUt / this.mRecipeMap.mAmperage + " EU ("+GT_Values.VN[tier]+")", -16777216); - }drawText(10, 103, trans("155","Amperage: ") + this.mRecipeMap.mAmperage, -16777216); + drawText(10, 93, trans("154","Voltage: ") + GT_Utility.formatNumbers(tEUt / this.mRecipeMap.mAmperage) + " EU ("+GT_Values.VN[tier]+")", -16777216); + }drawText(10, 103, trans("155","Amperage: ") + GT_Utility.formatNumbers(this.mRecipeMap.mAmperage), -16777216); } else { drawText(10, 93, trans("156","Voltage: unspecified"), -16777216); drawText(10, 103, trans("157","Amperage: unspecified"), -16777216); -- cgit From f9afedeb5cebbfc7f7dc228fdbdbd2675859064a Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Sat, 7 Aug 2021 05:33:27 -0600 Subject: Fix compiler warning --- src/main/java/gregtech/common/blocks/GT_Item_Machines.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main/java/gregtech/common/blocks') diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Machines.java b/src/main/java/gregtech/common/blocks/GT_Item_Machines.java index ee99c8a053..4be48b902d 100644 --- a/src/main/java/gregtech/common/blocks/GT_Item_Machines.java +++ b/src/main/java/gregtech/common/blocks/GT_Item_Machines.java @@ -60,7 +60,7 @@ public class GT_Item_Machines extends ItemBlock { for (int j = 0; j < tString.length; j++) if (j % 2 == 0) tBuffer.append(tString[j]); else {tBuffer.append(" %s"); tRep[j / 2] = tString[j];} - aList.add(String.format(GT_LanguageManager.addStringLocalization("TileEntity_" + suffix + "DESCRIPTION_" + tDamage + "_Index_" + i++, tBuffer.toString(), !GregTech_API.sPostloadFinished ), tRep)); + aList.add(String.format(GT_LanguageManager.addStringLocalization("TileEntity_" + suffix + "DESCRIPTION_" + tDamage + "_Index_" + i++, tBuffer.toString(), !GregTech_API.sPostloadFinished ), (Object[]) tRep)); } }else{String tTranslated = GT_LanguageManager.addStringLocalization("TileEntity_" + suffix + "DESCRIPTION_" + tDamage + "_Index_" + i++, tDescription, !GregTech_API.sPostloadFinished ); aList.add(tTranslated.equals("") ? tDescription : tTranslated);} -- cgit From 72c54aa140492f25d3ce4a03d61abb7de9642f87 Mon Sep 17 00:00:00 2001 From: D-Cysteine <54219287+D-Cysteine@users.noreply.github.com> Date: Sat, 7 Aug 2021 14:50:43 -0600 Subject: Print powers of 10 instead, for large numbers only --- .../implementations/GT_MetaPipeEntity_Cable.java | 6 +-- src/main/java/gregtech/api/util/GT_Utility.java | 46 ++++++++-------------- .../gregtech/common/blocks/GT_Item_Machines.java | 8 ++-- 3 files changed, 23 insertions(+), 37 deletions(-) (limited to 'src/main/java/gregtech/common/blocks') diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java index c5a33f7ae0..b4396aec3e 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaPipeEntity_Cable.java @@ -329,9 +329,9 @@ public class GT_MetaPipeEntity_Cable extends MetaPipeEntity implements IMetaTile @Override public String[] getDescription() { return new String[]{ - "Max Voltage: %%%" + EnumChatFormatting.GREEN + GT_Utility.formatPow2(mVoltage) + " (" + VN[GT_Utility.getTier(mVoltage)] + ")" + EnumChatFormatting.GRAY, - "Max Amperage: %%%" + EnumChatFormatting.YELLOW + GT_Utility.formatPow2(mAmperage) + EnumChatFormatting.GRAY, - "Loss/Meter/Ampere: %%%" + EnumChatFormatting.RED + GT_Utility.formatPow2(mCableLossPerMeter) + EnumChatFormatting.GRAY + "%%% EU-Volt" + "Max Voltage: %%%" + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(mVoltage) + " (" + VN[GT_Utility.getTier(mVoltage)] + ")" + EnumChatFormatting.GRAY, + "Max Amperage: %%%" + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(mAmperage) + EnumChatFormatting.GRAY, + "Loss/Meter/Ampere: %%%" + EnumChatFormatting.RED + GT_Utility.formatNumbers(mCableLossPerMeter) + EnumChatFormatting.GRAY + "%%% EU-Volt" }; } diff --git a/src/main/java/gregtech/api/util/GT_Utility.java b/src/main/java/gregtech/api/util/GT_Utility.java index da5c902c0e..f1f83c3c14 100644 --- a/src/main/java/gregtech/api/util/GT_Utility.java +++ b/src/main/java/gregtech/api/util/GT_Utility.java @@ -94,7 +94,11 @@ import static gregtech.common.GT_UndergroundOil.undergroundOilReadInformation; * Just a few Utility Functions I use. */ public class GT_Utility { - private static final DecimalFormat decimalFormat = new DecimalFormat(); + /** Formats a number with group separator and at most 2 fraction digits. */ + private static final DecimalFormat basicFormatter = new DecimalFormat(); + /** Formats a number into scientific notation with at most 2 fraction digits. Meant for large numbers. */ + private static final DecimalFormat scientificNotationFormatter = new DecimalFormat("0.##E0"); + /** * Forge screwed the Fluid Registry up again, so I make my own, which is also much more efficient than the stupid Stuff over there. */ @@ -108,10 +112,10 @@ public class GT_Utility { public static UUID defaultUuid = null; // maybe default non-null? UUID.fromString("00000000-0000-0000-0000-000000000000"); static { - DecimalFormatSymbols symbols = decimalFormat.getDecimalFormatSymbols(); + DecimalFormatSymbols symbols = basicFormatter.getDecimalFormatSymbols(); symbols.setGroupingSeparator(' '); - decimalFormat.setDecimalFormatSymbols(symbols); - decimalFormat.setMaximumFractionDigits(2); + basicFormatter.setDecimalFormatSymbols(symbols); + basicFormatter.setMaximumFractionDigits(2); GregTech_API.sItemStackMappings.add(sFilledContainerToData); GregTech_API.sItemStackMappings.add(sEmptyContainerToFluidToData); @@ -2226,35 +2230,17 @@ public class GT_Utility { } public static String formatNumbers(long aNumber) { - return decimalFormat.format(aNumber); + String formatted = basicFormatter.format(aNumber); + if (aNumber >= 1_000_000_000L) { + formatted += " [" + scientificNotationFormatter.format(aNumber) + "]"; + } + return formatted; } public static String formatNumbers(double aNumber) { - return decimalFormat.format(aNumber); - } - - /** - * Formats a positive integer with grouping separators, and also attempts to display it as a (small multiple of a) - * power of 2. - */ - public static String formatPow2(long number) { - String formatted = formatNumbers(number); - if (number == V[V.length - 1]) { - formatted += " (MAX)"; - } else if (number >= 256) { - // Try to figure out if number is a (small multiple of a) power of 2. - long curr = number; - int pow = 0; - while ((curr & 1) == 0) { // N.B. this won't terminate if curr == 0 - curr = curr >>> 1; - pow++; - } - - if (curr == 1) { - formatted += String.format(" (2^%d)", pow); - } else if (curr <= 7) { - formatted += String.format(" (%d*2^%d)", curr, pow); - } + String formatted = basicFormatter.format(aNumber); + if (aNumber >= 1_000_000_000d) { + formatted += " [" + scientificNotationFormatter.format(aNumber) + "]"; } return formatted; } diff --git a/src/main/java/gregtech/common/blocks/GT_Item_Machines.java b/src/main/java/gregtech/common/blocks/GT_Item_Machines.java index 4be48b902d..74e3e3653d 100644 --- a/src/main/java/gregtech/common/blocks/GT_Item_Machines.java +++ b/src/main/java/gregtech/common/blocks/GT_Item_Machines.java @@ -70,16 +70,16 @@ public class GT_Item_Machines extends ItemBlock { if (tTileEntity.getEUCapacity() > 0L) { if (tTileEntity.getInputVoltage() > 0L) { int inputTier = GT_Utility.getTier(tTileEntity.getInputVoltage()); - aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_IN", "Voltage IN: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.GREEN + GT_Utility.formatPow2(tTileEntity.getInputVoltage()) + " (" + GT_Values.TIER_COLORS[inputTier] + GT_Values.VN[inputTier] + EnumChatFormatting.GREEN +")" + EnumChatFormatting.GRAY); + aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_IN", "Voltage IN: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(tTileEntity.getInputVoltage()) + " (" + GT_Values.TIER_COLORS[inputTier] + GT_Values.VN[inputTier] + EnumChatFormatting.GREEN +")" + EnumChatFormatting.GRAY); } if (tTileEntity.getOutputVoltage() > 0L) { int outputTier = GT_Utility.getTier(tTileEntity.getOutputVoltage()); - aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_OUT", "Voltage OUT: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.GREEN + GT_Utility.formatPow2(tTileEntity.getOutputVoltage()) + " (" + GT_Values.TIER_COLORS[outputTier] + GT_Values.VN[outputTier] + EnumChatFormatting.GREEN + ")" + EnumChatFormatting.GRAY); + aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_OUT", "Voltage OUT: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.GREEN + GT_Utility.formatNumbers(tTileEntity.getOutputVoltage()) + " (" + GT_Values.TIER_COLORS[outputTier] + GT_Values.VN[outputTier] + EnumChatFormatting.GREEN + ")" + EnumChatFormatting.GRAY); } if (tTileEntity.getOutputAmperage() > 1L) { - aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_AMOUNT", "Amperage: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.YELLOW + GT_Utility.formatPow2(tTileEntity.getOutputAmperage()) + EnumChatFormatting.GRAY); + aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_AMOUNT", "Amperage: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(tTileEntity.getOutputAmperage()) + EnumChatFormatting.GRAY); } - aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_STORE", "Capacity: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.BLUE + GT_Utility.formatPow2(tTileEntity.getEUCapacity()) + EnumChatFormatting.GRAY); + aList.add(GT_LanguageManager.addStringLocalization("TileEntity_EUp_STORE", "Capacity: ", !GregTech_API.sPostloadFinished ) + EnumChatFormatting.BLUE + GT_Utility.formatNumbers(tTileEntity.getEUCapacity()) + EnumChatFormatting.GRAY); } } NBTTagCompound aNBT = aStack.getTagCompound(); -- cgit