-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMTETemplateMultiblock.java
175 lines (148 loc) · 5.91 KB
/
MTETemplateMultiblock.java
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
package gregtech.common.tileentities.machines.multi;
import static com.gtnewhorizon.structurelib.structure.StructureUtility.*;
import static gregtech.api.enums.HatchElement.*;
import static gregtech.api.enums.Textures.BlockIcons.*;
import static gregtech.api.util.GTStructureUtility.buildHatchAdder;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable;
import com.gtnewhorizon.structurelib.structure.IStructureDefinition;
import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment;
import com.gtnewhorizon.structurelib.structure.StructureDefinition;
import gregtech.api.GregTechAPI;
import gregtech.api.enums.Textures;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.logic.ProcessingLogic;
import gregtech.api.metatileentity.implementations.MTEExtendedPowerMultiBlockBase;
import gregtech.api.recipe.RecipeMap;
import gregtech.api.recipe.RecipeMaps;
import gregtech.api.render.TextureFactory;
import gregtech.api.util.MultiblockTooltipBuilder;
public class MTETemplateMultiblock extends MTEExtendedPowerMultiBlockBase<MTETemplateMultiblock>
implements ISurvivalConstructable {
// Steel casing
private static final int CASING_INDEX = 16;
private static final String STRUCTURE_PIECE_MAIN = "main";
private static final IStructureDefinition<MTETemplateMultiblock> STRUCTURE_DEFINITION = StructureDefinition
.<MTETemplateMultiblock>builder()
.addShape(
STRUCTURE_PIECE_MAIN,
new String[][] { { "BBB", "B~B", "BBB" }, { "BBB", "B B", "BBB" }, { "BBB", "BBB", "BBB" } })
.addElement(
'B',
buildHatchAdder(MTETemplateMultiblock.class)
.atLeast(InputHatch, InputBus, OutputBus, OutputHatch, Maintenance, Energy, ExoticEnergy)
.casingIndex(CASING_INDEX)
.dot(1)
.buildAndChain(
onElementPass(MTETemplateMultiblock::onCasingAdded, ofBlock(GregTechAPI.sBlockCasings2, 0))))
.build();
private int mCasingAmount;
private void onCasingAdded() {
mCasingAmount++;
}
public MTETemplateMultiblock(final int aID, final String aName, final String aNameRegional) {
super(aID, aName, aNameRegional);
}
public MTETemplateMultiblock(String aName) {
super(aName);
}
@Override
public IStructureDefinition<MTETemplateMultiblock> getStructureDefinition() {
return STRUCTURE_DEFINITION;
}
@Override
public boolean isCorrectMachinePart(ItemStack aStack) {
return true;
}
@Override
public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
return new MTETemplateMultiblock(this.mName);
}
@Override
public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection sideDirection,
ForgeDirection facingDirection, int colorIndex, boolean active, boolean redstoneLevel) {
if (sideDirection == facingDirection) {
if (active) return new ITexture[] { Textures.BlockIcons.casingTexturePages[0][16], TextureFactory.builder()
.addIcon(OVERLAY_FRONT_ASSEMBLY_LINE_ACTIVE)
.extFacing()
.build(),
TextureFactory.builder()
.addIcon(OVERLAY_FRONT_ASSEMBLY_LINE_ACTIVE_GLOW)
.extFacing()
.glow()
.build() };
return new ITexture[] { Textures.BlockIcons.casingTexturePages[0][16], TextureFactory.builder()
.addIcon(OVERLAY_FRONT_ASSEMBLY_LINE)
.extFacing()
.build(),
TextureFactory.builder()
.addIcon(OVERLAY_FRONT_ASSEMBLY_LINE_GLOW)
.extFacing()
.glow()
.build() };
}
return new ITexture[] { Textures.BlockIcons.casingTexturePages[0][16] };
}
@Override
protected MultiblockTooltipBuilder createTooltip() {
MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder();
tt.addMachineType("Template")
.addInfo("ponzu ponzu ponzu ponzu ponzu ponzu ponzu")
.beginStructureBlock(3, 3, 3, true)
.toolTipFinisher();
return tt;
}
@Override
public void construct(ItemStack stackSize, boolean hintsOnly) {
buildPiece(STRUCTURE_PIECE_MAIN, stackSize, hintsOnly, 1, 1, 0);
}
@Override
public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) {
if (mMachine) return -1;
return survivialBuildPiece(STRUCTURE_PIECE_MAIN, stackSize, 1, 1, 0, elementBudget, env, false, true);
}
@Override
public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
mCasingAmount = 0;
return checkPiece(STRUCTURE_PIECE_MAIN, 1, 1, 0) && mCasingAmount > 0;
}
@Override
protected ProcessingLogic createProcessingLogic() {
return new ProcessingLogic();
}
@Override
public RecipeMap<?> getRecipeMap() {
return RecipeMaps.compressorRecipes;
}
@Override
public int getMaxEfficiency(ItemStack aStack) {
return 10000;
}
@Override
public int getDamageToComponent(ItemStack aStack) {
return 0;
}
@Override
public boolean explodesOnComponentBreak(ItemStack aStack) {
return false;
}
@Override
public boolean supportsVoidProtection() {
return true;
}
@Override
public boolean supportsBatchMode() {
return true;
}
@Override
public boolean supportsInputSeparation() {
return true;
}
@Override
public boolean supportsSingleRecipeLocking() {
return true;
}
}