diff options
author | Glease <4586901+Glease@users.noreply.github.com> | 2023-01-31 02:23:25 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-30 19:23:25 +0100 |
commit | 9285806d9e089b183caf9985718cee115ec75396 (patch) | |
tree | 697cb793cfb08f26d07829d4ca2e350cdfe4564b /src/main/java/gregtech/common | |
parent | df5f9d448647d5ccf9eb774a244319e54021ede0 (diff) | |
download | GT5-Unofficial-9285806d9e089b183caf9985718cee115ec75396.tar.gz GT5-Unofficial-9285806d9e089b183caf9985718cee115ec75396.tar.bz2 GT5-Unofficial-9285806d9e089b183caf9985718cee115ec75396.zip |
add back turbine wallsharing (#1699)
* add back turbine wallsharing
Signed-off-by: Glease <4586901+Glease@users.noreply.github.com>
* use new texture from @Jimbno
Signed-off-by: Glease <4586901+Glease@users.noreply.github.com>
* remove unnecessary structure checks
it turns out you cannot build 2 functional large turbine at these locations anyway, so why not?
Signed-off-by: Glease <4586901+Glease@users.noreply.github.com>
* spotless
Signed-off-by: Glease <4586901+Glease@users.noreply.github.com>
* update bs
* use the original grey for empty texture
these are slightly darker, and looks better
Signed-off-by: Glease <4586901+Glease@users.noreply.github.com>
---------
Signed-off-by: Glease <4586901+Glease@users.noreply.github.com>
Co-authored-by: Martin Robertz <dream-master@gmx.net>
Diffstat (limited to 'src/main/java/gregtech/common')
9 files changed, 177 insertions, 32 deletions
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 f5618c23b4..62c7649dc2 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings4.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings4.java @@ -158,6 +158,7 @@ public class GT_Block_Casings4 extends GT_Block_Casings_Abstract { } } + @Deprecated public IIcon getTurbineCasing(int meta, int iconIndex, boolean active, boolean hasTurbine) { switch (meta) { case 10: @@ -192,8 +193,10 @@ public class GT_Block_Casings4 extends GT_Block_Casings_Abstract { if (!(tTileEntity instanceof IGregTechTileEntity)) return 0; IGregTechTileEntity tTile = (IGregTechTileEntity) tTileEntity; if (tTile.getMetaTileEntity() instanceof GT_MetaTileEntity_LargeTurbine && tTile.getFrontFacing() == aSide) { + GT_MetaTileEntity_LargeTurbine turbine = (GT_MetaTileEntity_LargeTurbine) tTile.getMetaTileEntity(); + if (turbine.isNewStyleRendering()) return 0; if (tTile.isActive()) return 1; - return ((GT_MetaTileEntity_LargeTurbine) tTile.getMetaTileEntity()).hasTurbine() ? 2 : 3; + return turbine.hasTurbine() ? 2 : 3; } return 0; } 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 ae67f52730..03f7262219 100644 --- a/src/main/java/gregtech/common/blocks/GT_Block_Casings8.java +++ b/src/main/java/gregtech/common/blocks/GT_Block_Casings8.java @@ -143,8 +143,10 @@ public class GT_Block_Casings8 extends GT_Block_Casings_Abstract { if (!(tTileEntity instanceof IGregTechTileEntity)) return 0; IGregTechTileEntity tTile = (IGregTechTileEntity) tTileEntity; if (tTile.getMetaTileEntity() instanceof GT_MetaTileEntity_LargeTurbine && tTile.getFrontFacing() == aSide) { + GT_MetaTileEntity_LargeTurbine turbine = (GT_MetaTileEntity_LargeTurbine) tTile.getMetaTileEntity(); + if (turbine.isNewStyleRendering()) return 0; if (tTile.isActive()) return 1; - return ((GT_MetaTileEntity_LargeTurbine) tTile.getMetaTileEntity()).hasTurbine() ? 2 : 3; + return turbine.hasTurbine() ? 2 : 3; } return 0; } diff --git a/src/main/java/gregtech/common/render/GT_RenderUtil.java b/src/main/java/gregtech/common/render/GT_RenderUtil.java index ef0cae11ff..df490f4806 100644 --- a/src/main/java/gregtech/common/render/GT_RenderUtil.java +++ b/src/main/java/gregtech/common/render/GT_RenderUtil.java @@ -1,9 +1,36 @@ package gregtech.common.render; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.util.IIcon; public class GT_RenderUtil { + + public static void renderBlockIcon( + RenderBlocks aRenderer, Block aBlock, double aX, double aY, double aZ, IIcon aIcon, byte aSide) { + switch (aSide) { + case 0: + aRenderer.renderFaceYNeg(aBlock, aX, aY, aZ, aIcon); + return; + case 1: + aRenderer.renderFaceYPos(aBlock, aX, aY, aZ, aIcon); + return; + case 2: + aRenderer.renderFaceZNeg(aBlock, aX, aY, aZ, aIcon); + return; + case 3: + aRenderer.renderFaceZPos(aBlock, aX, aY, aZ, aIcon); + return; + case 4: + aRenderer.renderFaceXNeg(aBlock, aX, aY, aZ, aIcon); + return; + case 5: + aRenderer.renderFaceXPos(aBlock, aX, aY, aZ, aIcon); + return; + } + } + public static void renderItemIcon(IIcon icon, double size, double z, float nx, float ny, float nz) { renderItemIcon(icon, 0.0D, 0.0D, size, size, z, nx, ny, nz); } 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 978456c435..84e6ab520c 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 @@ -4,27 +4,37 @@ import static com.gtnewhorizon.structurelib.structure.StructureUtility.lazy; import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; import static gregtech.api.enums.GT_HatchElement.*; +import static gregtech.api.enums.Textures.BlockIcons.TURBINE_NEW; +import static gregtech.api.enums.Textures.BlockIcons.TURBINE_NEW_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.TURBINE_NEW_EMPTY; import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; +import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; -import com.gtnewhorizon.structurelib.structure.IStructureElementCheckOnly; import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import gregtech.api.enums.Dyes; +import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.items.GT_MetaGenerated_Tool; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMultiBlockBase; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Dynamo; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Muffler; import gregtech.api.util.GT_Utility; +import gregtech.api.util.LightingHelper; import gregtech.common.items.GT_MetaGenerated_Tool_01; +import gregtech.common.render.GT_RenderUtil; import java.util.ArrayList; import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; +import net.minecraft.world.IBlockAccess; +import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; public abstract class GT_MetaTileEntity_LargeTurbine @@ -38,19 +48,19 @@ public abstract class GT_MetaTileEntity_LargeTurbine return StructureDefinition.<GT_MetaTileEntity_LargeTurbine>builder() .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][] { { - " ", "xxxxx", "xxxxx", "xxxxx", "xxxxx", + " ", " ", " ", " ", " ", }, { - " --- ", "xcccx", "xhhhx", "xhhhx", "xhhhx", + " --- ", " ccc ", " hhh ", " hhh ", " hhh ", }, { - " --- ", "xc~cx", "xh-hx", "xh-hx", "xhdhx", + " --- ", " c~c ", " h-h ", " h-h ", " hdh ", }, { - " --- ", "xcccx", "xhhhx", "xhhhx", "xhhhx", + " --- ", " ccc ", " hhh ", " hhh ", " hhh ", }, { - " ", "xxxxx", "xxxxx", "xxxxx", "xxxxx", + " ", " ", " ", " ", " ", }, })) .addElement('c', lazy(t -> ofBlock(t.getCasingBlock(), t.getCasingMeta()))) @@ -60,13 +70,6 @@ public abstract class GT_MetaTileEntity_LargeTurbine .casingIndex(t.getCasingTextureIndex()) .dot(2) .buildAndChain(t.getCasingBlock(), t.getCasingMeta()))) - .addElement('x', (IStructureElementCheckOnly<GT_MetaTileEntity_LargeTurbine>) - (aContext, aWorld, aX, aY, aZ) -> { - TileEntity tTile = aWorld.getTileEntity(aX, aY, aZ); - return !(tTile instanceof IGregTechTileEntity) - || !(((IGregTechTileEntity) tTile).getMetaTileEntity() - instanceof GT_MetaTileEntity_LargeTurbine); - }) .build(); } }; @@ -80,6 +83,9 @@ public abstract class GT_MetaTileEntity_LargeTurbine protected int overflowMultiplier = 0; protected float[] flowMultipliers = new float[] {1, 1, 1}; + // client side stuff + protected boolean mHasTurbine; + public GT_MetaTileEntity_LargeTurbine(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } @@ -111,6 +117,86 @@ public abstract class GT_MetaTileEntity_LargeTurbine public abstract int getCasingTextureIndex(); + public boolean isNewStyleRendering() { + return false; + } + + public IIconContainer[] getTurbineTextureActive() { + return TURBINE_NEW_ACTIVE; + } + + public IIconContainer[] getTurbineTextureFull() { + return TURBINE_NEW; + } + + public IIconContainer[] getTurbineTextureEmpty() { + return TURBINE_NEW_EMPTY; + } + + @Override + public boolean renderInWorld(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, RenderBlocks aRenderer) { + if (!isNewStyleRendering() || !mMachine) return false; + int[] tABCCoord = new int[] {-1, -1, 0}; + int[] tXYZOffset = new int[3]; + byte tFacing = getBaseMetaTileEntity().getFrontFacing(); + ExtendedFacing tExtendedFacing = getExtendedFacing(); + ForgeDirection tDirection = tExtendedFacing.getDirection(); + LightingHelper tLighting = new LightingHelper(aRenderer); + + // for some reason +x and -z need this field set to true, but not any other sides + if (tFacing == 2 || tFacing == 5) aRenderer.field_152631_f = true; + Block tBlock = getCasingBlock(); + + IIconContainer[] tTextures; + if (getBaseMetaTileEntity().isActive()) tTextures = getTurbineTextureActive(); + else if (hasTurbine()) tTextures = getTurbineTextureFull(); + else tTextures = getTurbineTextureEmpty(); + + assert tTextures != null && tTextures.length == tABCCoord.length; + + for (int i = 0; i < 9; i++) { + if (i != 4) { // do not draw ourselves again. + tExtendedFacing.getWorldOffset(tABCCoord, tXYZOffset); + // since structure check passed, we can assume it is turbine casing + int tX = tXYZOffset[0] + aX; + int tY = tXYZOffset[1] + aY; + int tZ = tXYZOffset[2] + aZ; + // we skip the occlusion test, as we always require a working turbine to have a block of air before it + // so the front face cannot be occluded whatsoever in the most cases. + Tessellator.instance.setBrightness(tBlock.getMixedBrightnessForBlock( + aWorld, aX + tDirection.offsetX, tY + tDirection.offsetY, aZ + tDirection.offsetZ)); + tLighting.setupLighting(tBlock, tX, tY, tZ, tFacing).setupColor(tFacing, Dyes._NULL.mRGBa); + GT_RenderUtil.renderBlockIcon( + aRenderer, + tBlock, + tX + tDirection.offsetX * 0.001, + tY + tDirection.offsetY * 0.001, + tZ + tDirection.offsetZ * 0.001, + tTextures[i].getIcon(), + tFacing); + } + if (++tABCCoord[0] == 2) { + tABCCoord[0] = -1; + tABCCoord[1]++; + } + } + + aRenderer.field_152631_f = false; + return false; + } + + @Override + public void onValueUpdate(byte aValue) { + mHasTurbine = (aValue & 0x1) != 0; + mMachine = (aValue & 0x2) != 0; + super.onValueUpdate(aValue); + } + + @Override + public byte getUpdateData() { + return (byte) ((hasTurbine() ? 1 : 0) | (mMachine ? 2 : 0)); + } + @Override public boolean addToMachineList(IGregTechTileEntity tTileEntity, int aBaseCasingIndex) { return addMaintenanceToMachineList(tTileEntity, getCasingTextureIndex()) @@ -328,7 +414,9 @@ public abstract class GT_MetaTileEntity_LargeTurbine } public boolean hasTurbine() { - return this.getMaxEfficiency(mInventory[1]) > 0; + return getBaseMetaTileEntity() != null && getBaseMetaTileEntity().isClientSide() + ? mHasTurbine + : this.getMaxEfficiency(mInventory[1]) > 0; } @Override diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java index 85e0a1700b..ad56dd7be4 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java @@ -40,14 +40,14 @@ public class GT_MetaTileEntity_LargeTurbine_Gas extends GT_MetaTileEntity_LargeT aFacing == aSide ? (aActive ? TextureFactory.builder() - .addIcon(LARGETURBINE_SS_ACTIVE5) + .addIcon(LARGETURBINE_NEW_ACTIVE5) .build() : hasTurbine() ? TextureFactory.builder() - .addIcon(LARGETURBINE_SS5) + .addIcon(LARGETURBINE_NEW5) .build() : TextureFactory.builder() - .addIcon(LARGETURBINE_SS_EMPTY5) + .addIcon(LARGETURBINE_NEW_EMPTY5) .build()) : casingTexturePages[0][58] }; @@ -103,6 +103,11 @@ public class GT_MetaTileEntity_LargeTurbine_Gas extends GT_MetaTileEntity_LargeT } @Override + public boolean isNewStyleRendering() { + return true; + } + + @Override public int getPollutionPerSecond(ItemStack aStack) { return GT_Mod.gregtechproxy.mPollutionLargeGasTurbinePerSecond; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_GasAdvanced.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_GasAdvanced.java index 727ae5d8fd..185da58b28 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_GasAdvanced.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_GasAdvanced.java @@ -39,14 +39,14 @@ public class GT_MetaTileEntity_LargeTurbine_GasAdvanced extends GT_MetaTileEntit aFacing == aSide ? (aActive ? TextureFactory.builder() - .addIcon(LARGETURBINE_ADVGAS_ACTIVE5) + .addIcon(LARGETURBINE_NEW_ACTIVE5) .build() : hasTurbine() ? TextureFactory.builder() - .addIcon(LARGETURBINE_ADVGAS5) + .addIcon(LARGETURBINE_NEW5) .build() : TextureFactory.builder() - .addIcon(LARGETURBINE_ADVGAS_EMPTY5) + .addIcon(LARGETURBINE_NEW_EMPTY5) .build()) : casingTexturePages[1][57] }; @@ -102,6 +102,11 @@ public class GT_MetaTileEntity_LargeTurbine_GasAdvanced extends GT_MetaTileEntit } @Override + public boolean isNewStyleRendering() { + return true; + } + + @Override public int getPollutionPerSecond(ItemStack aStack) { return GT_Mod.gregtechproxy.mPollutionLargeGasTurbinePerSecond; } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_HPSteam.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_HPSteam.java index 8b10b2e74b..779de1a17a 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_HPSteam.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_HPSteam.java @@ -46,14 +46,14 @@ public class GT_MetaTileEntity_LargeTurbine_HPSteam extends GT_MetaTileEntity_La aFacing == aSide ? (aActive ? TextureFactory.builder() - .addIcon(LARGETURBINE_TI_ACTIVE5) + .addIcon(LARGETURBINE_NEW_ACTIVE5) .build() : hasTurbine() ? TextureFactory.builder() - .addIcon(LARGETURBINE_TI5) + .addIcon(LARGETURBINE_NEW5) .build() : TextureFactory.builder() - .addIcon(LARGETURBINE_TI_EMPTY5) + .addIcon(LARGETURBINE_NEW_EMPTY5) .build()) : casingTexturePages[0][59] }; @@ -101,6 +101,11 @@ public class GT_MetaTileEntity_LargeTurbine_HPSteam extends GT_MetaTileEntity_La } @Override + public boolean isNewStyleRendering() { + return true; + } + + @Override int fluidIntoPower( ArrayList<FluidStack> aFluids, int aOptFlow, diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java index fb06c383fd..272a3ddcc1 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java @@ -46,14 +46,14 @@ public class GT_MetaTileEntity_LargeTurbine_Plasma extends GT_MetaTileEntity_Lar aFacing == aSide ? (aActive ? TextureFactory.builder() - .addIcon(LARGETURBINE_TU_ACTIVE5) + .addIcon(LARGETURBINE_NEW_ACTIVE5) .build() : hasTurbine() ? TextureFactory.builder() - .addIcon(LARGETURBINE_TU5) + .addIcon(LARGETURBINE_NEW5) .build() : TextureFactory.builder() - .addIcon(LARGETURBINE_TU_EMPTY5) + .addIcon(LARGETURBINE_NEW_EMPTY5) .build()) : casingTexturePages[0][60] }; @@ -106,6 +106,11 @@ public class GT_MetaTileEntity_LargeTurbine_Plasma extends GT_MetaTileEntity_Lar } @Override + public boolean isNewStyleRendering() { + return true; + } + + @Override int fluidIntoPower( ArrayList<FluidStack> aFluids, int aOptFlow, diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java index 79f833fa31..b66bf85fb7 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java @@ -47,14 +47,14 @@ public class GT_MetaTileEntity_LargeTurbine_Steam extends GT_MetaTileEntity_Larg aFacing == aSide ? (aActive ? TextureFactory.builder() - .addIcon(LARGETURBINE_ST_ACTIVE5) + .addIcon(LARGETURBINE_NEW_ACTIVE5) .build() : hasTurbine() ? TextureFactory.builder() - .addIcon(LARGETURBINE_ST5) + .addIcon(LARGETURBINE_NEW5) .build() : TextureFactory.builder() - .addIcon(LARGETURBINE_ST_EMPTY5) + .addIcon(LARGETURBINE_NEW_EMPTY5) .build()) : casingTexturePages[0][57] }; @@ -101,6 +101,11 @@ public class GT_MetaTileEntity_LargeTurbine_Steam extends GT_MetaTileEntity_Larg return 16; } + @Override + public boolean isNewStyleRendering() { + return true; + } + private int condenseSteam(int steam) { excessWater += steam; int water = excessWater / STEAM_PER_WATER; |