aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/goodgenerator/blocks/regularBlock/TurbineCasing.java
diff options
context:
space:
mode:
authorGlodBlock <1356392126@qq.com>2022-01-11 21:30:55 +0800
committerGlodBlock <1356392126@qq.com>2022-01-11 21:30:55 +0800
commit458632dd26f43268146498ec71ca6c021b546226 (patch)
tree84cd67cc1270c20fdbc352c92970c996f2a627d9 /src/main/java/goodgenerator/blocks/regularBlock/TurbineCasing.java
parentba4ef7e1534e5c909b4d1b366503112010454ca1 (diff)
downloadGT5-Unofficial-458632dd26f43268146498ec71ca6c021b546226.tar.gz
GT5-Unofficial-458632dd26f43268146498ec71ca6c021b546226.tar.bz2
GT5-Unofficial-458632dd26f43268146498ec71ca6c021b546226.zip
new render system and add SC fluid power system and XHE base, no recipe yet
Diffstat (limited to 'src/main/java/goodgenerator/blocks/regularBlock/TurbineCasing.java')
-rw-r--r--src/main/java/goodgenerator/blocks/regularBlock/TurbineCasing.java106
1 files changed, 106 insertions, 0 deletions
diff --git a/src/main/java/goodgenerator/blocks/regularBlock/TurbineCasing.java b/src/main/java/goodgenerator/blocks/regularBlock/TurbineCasing.java
new file mode 100644
index 0000000000..8387662298
--- /dev/null
+++ b/src/main/java/goodgenerator/blocks/regularBlock/TurbineCasing.java
@@ -0,0 +1,106 @@
+package goodgenerator.blocks.regularBlock;
+
+import goodgenerator.client.render.BlockRenderHandler;
+import goodgenerator.blocks.tileEntity.base.GT_MetaTileEntity_LargeTurbineBase;
+import goodgenerator.main.GoodGenerator;
+import gregtech.api.enums.Textures;
+import gregtech.api.interfaces.IIconContainer;
+import gregtech.api.interfaces.ITexture;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.render.TextureFactory;
+import net.minecraft.block.Block;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.world.IBlockAccess;
+
+public class TurbineCasing extends Casing {
+
+ public static IIconContainer[][] turbineShape = new IIconContainer[3][9];
+ public IIconContainer base;
+
+ static {
+ for (int i = 0; i < 3; i ++)
+ for (int j = 1; j <= 9; j ++)
+ turbineShape[i][j - 1] = new Textures.BlockIcons.CustomIcon("icons/turbines/TURBINE_" + i + "" + j);
+ }
+
+ public TurbineCasing(String name, String texture) {
+ super(name, new String[]{GoodGenerator.MOD_ID + ":" + texture});
+ base = new Textures.BlockIcons.CustomIcon("icons/" + texture);
+ }
+
+ 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_LargeTurbineBase && tTile.getFrontFacing() == aSide) {
+ if (tTile.isActive()) return 1;
+ return ((GT_MetaTileEntity_LargeTurbineBase) tTile.getMetaTileEntity()).hasTurbine() ? 2 : 3;
+ }
+ return 0;
+ }
+
+ public ITexture[] getTurbineCasing(int iconIndex, boolean active, boolean hasTurbine) {
+ int states = active ? 0 : hasTurbine ? 1 : 2;
+ return new ITexture[] {
+ TextureFactory.of(base),
+ TextureFactory.of(turbineShape[states][iconIndex])
+ };
+ }
+
+ public ITexture[] getTexture(Block aBlock, byte aSide) {
+ return new ITexture[] {
+ TextureFactory.of(base)
+ };
+ }
+
+ public ITexture[] getTexture(Block aBlock, byte aSide, IBlockAccess aWorld, int xCoord, int yCoord, int zCoord) {
+ 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(4 - i * 3 - j, tState == 1, tState == 2);
+ }
+ }
+ }
+ 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(4 + i * 3 - j * tInvertLeftRightMod, tState == 1, tState == 2);
+ }
+ }
+ }
+ 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(4 + i * 3 + j * tInvertLeftRightMod, tState == 1, tState == 2);
+ }
+ }
+ }
+ break;
+ }
+ return getTexture(aBlock, aSide);
+ }
+
+ @Override
+ public int getRenderType() {
+ if (BlockRenderHandler.INSTANCE == null) {
+ return super.getRenderType();
+ }
+ return BlockRenderHandler.INSTANCE.mRenderID;
+ }
+}