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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
package gregtech.common.tileentities.machines.multi.purification;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import gregtech.api.enums.Textures;
import gregtech.api.interfaces.IIconContainer;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.implementations.MTEHatch;
import gregtech.api.render.TextureFactory;
public class MTEHatchDegasifierControl extends MTEHatch {
private byte outputStrength = 0;
private static final IIconContainer textureFont = Textures.BlockIcons.OVERLAY_HATCH_PH_SENSOR;
private static final IIconContainer textureFont_Glow = Textures.BlockIcons.OVERLAY_HATCH_PH_SENSOR_GLOW;
public MTEHatchDegasifierControl(int aID, String aName, String aNameRegional, int aTier) {
super(aID, aName, aNameRegional, aTier, 0, "Outputs a control signal for the Degasser Purification Unit");
}
public MTEHatchDegasifierControl(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) {
super(aName, aTier, 0, aDescription, aTextures);
}
@Override
public boolean isValidSlot(int aIndex) {
return false;
}
@Override
public boolean isSimpleMachine() {
return true;
}
@Override
public boolean allowGeneralRedstoneOutput() {
return true;
}
@Override
public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection Side,
ItemStack aStack) {
return false;
}
@Override
public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side,
ItemStack aStack) {
return false;
}
@Override
public boolean isFacingValid(ForgeDirection facing) {
return true;
}
@Override
public void initDefaultModes(NBTTagCompound aNBT) {
getBaseMetaTileEntity().setActive(true);
}
@Override
public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
return new MTEHatchDegasifierControl(mName, mTier, mDescriptionArray, mTextures);
}
@Override
public String[] getDescription() {
return new String[] { "Can be installed in the Degasser Purification Unit.",
"Outputs Redstone Signal Strength based on the current control signal." };
}
@Override
public void loadNBTData(NBTTagCompound aNBT) {
outputStrength = aNBT.getByte("mOutputStrength");
super.loadNBTData(aNBT);
}
@Override
public void saveNBTData(NBTTagCompound aNBT) {
aNBT.setByte("mOutputStrength", outputStrength);
super.saveNBTData(aNBT);
}
// Pass zero signal to disable output
public void updateOutputSignal(byte signal) {
outputStrength = signal;
}
@Override
public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
if (outputStrength > 0) {
for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) {
aBaseMetaTileEntity.setStrongOutputRedstoneSignal(side, outputStrength);
}
} else {
for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) {
aBaseMetaTileEntity.setStrongOutputRedstoneSignal(side, (byte) 0);
}
}
super.onPostTick(aBaseMetaTileEntity, aTick);
}
@Override
public ITexture[] getTexturesActive(ITexture aBaseTexture) {
return new ITexture[] { aBaseTexture, TextureFactory.of(textureFont), TextureFactory.builder()
.addIcon(textureFont_Glow)
.glow()
.build() };
}
@Override
public ITexture[] getTexturesInactive(ITexture aBaseTexture) {
return new ITexture[] { aBaseTexture, TextureFactory.of(textureFont) };
}
}
|