1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
package gtPlusPlus.xmod.gregtech.common.blocks.textures;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gtPlusPlus.xmod.gregtech.common.blocks.GregtechMetaCasingBlocks;
import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.processing.MTEIndustrialCentrifuge;
public class TexturesCentrifugeMultiblock {
public IIcon handleCasingsGT(final IBlockAccess aWorld, final int xCoord, final int yCoord, final int zCoord,
final ForgeDirection side, final GregtechMetaCasingBlocks thisBlock) {
return this.handleCasingsGT58(aWorld, xCoord, yCoord, zCoord, side, thisBlock);
}
private static int isCentrifugeControllerWithSide(IBlockAccess aWorld, int aX, int aY, int aZ,
ForgeDirection side) {
TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
if (!(tTileEntity instanceof IGregTechTileEntity tTile)) return 0;
if (tTile.getMetaTileEntity() instanceof MTEIndustrialCentrifuge && tTile.getFrontFacing() == side)
return tTile.isActive() ? 1 : 2;
return 0;
}
public IIcon handleCasingsGT58(final IBlockAccess aWorld, final int xCoord, final int yCoord, final int zCoord,
final ForgeDirection side, final GregtechMetaCasingBlocks thisBlock) {
final int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord);
final int ordinalSide = side.ordinal();
if (tMeta != 0) {
return CasingTextureHandler.getIcon(ordinalSide, tMeta);
}
int tInvertLeftRightMod = ordinalSide % 2 * 2 - 1;
switch (ordinalSide / 2) {
case 0 -> {
for (int i = -1; i < 2; i++) {
for (int j = -1; j < 2; j++) {
if (i == 0 && j == 0) continue;
if (isCentrifugeControllerWithSide(aWorld, xCoord + j, yCoord, zCoord + i, side) != 0) {
IMetaTileEntity tMetaTileEntity = ((IGregTechTileEntity) aWorld
.getTileEntity(xCoord + j, yCoord, zCoord + i)).getMetaTileEntity();
return getIconByIndex(tMetaTileEntity, 4 - i * 3 - j);
}
}
}
}
case 1 -> {
for (int i = -1; i < 2; i++) {
for (int j = -1; j < 2; j++) {
if (i == 0 && j == 0) continue;
if (isCentrifugeControllerWithSide(aWorld, xCoord + j, yCoord + i, zCoord, side) != 0) {
IMetaTileEntity tMetaTileEntity = ((IGregTechTileEntity) aWorld
.getTileEntity(xCoord + j, yCoord + i, zCoord)).getMetaTileEntity();
return getIconByIndex(tMetaTileEntity, 4 + i * 3 - j * tInvertLeftRightMod);
}
}
}
}
case 2 -> {
for (int i = -1; i < 2; i++) {
for (int j = -1; j < 2; j++) {
if (i == 0 && j == 0) continue;
if (isCentrifugeControllerWithSide(aWorld, xCoord, yCoord + i, zCoord + j, side) != 0) {
IMetaTileEntity tMetaTileEntity = ((IGregTechTileEntity) aWorld
.getTileEntity(xCoord, yCoord + i, zCoord + j)).getMetaTileEntity();
return getIconByIndex(tMetaTileEntity, 4 + i * 3 + j * tInvertLeftRightMod);
}
}
}
}
}
return TexturesGtBlock.Casing_Material_Centrifuge.getIcon();
}
public boolean isCentrifugeRunning(IMetaTileEntity aTile) {
if (aTile == null) {
return false;
} else {
return aTile.getBaseMetaTileEntity()
.isActive();
}
}
public boolean isUsingAnimatedTexture(IMetaTileEntity aMetaTileEntity) {
if (aMetaTileEntity != null) {
if (aMetaTileEntity instanceof MTEIndustrialCentrifuge) {
return ((MTEIndustrialCentrifuge) aMetaTileEntity).usingAnimations();
}
}
return false;
}
public IIcon getIconByIndex(IMetaTileEntity aMetaTileEntity, int aIndex) {
if (isUsingAnimatedTexture(aMetaTileEntity)) {
if (isCentrifugeRunning(aMetaTileEntity)) {
return TexturesGtBlock.CENTRIFUGEACTIVE[aIndex].getIcon();
}
}
return TexturesGtBlock.CENTRIFUGE[aIndex].getIcon();
}
}
|