|
| 1 | +package com.Nxer.TwistSpaceTechnology.common.machine; |
| 2 | + |
| 3 | +import static com.Nxer.TwistSpaceTechnology.common.init.TstBlocks.MetaBlockCasing02; |
| 4 | +import static com.Nxer.TwistSpaceTechnology.util.TextEnums.tr; |
| 5 | +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; |
| 6 | +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlocksTiered; |
| 7 | +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; |
| 8 | +import static com.gtnewhorizon.structurelib.structure.StructureUtility.withChannel; |
| 9 | +import static gregtech.api.enums.HatchElement.Energy; |
| 10 | +import static gregtech.api.enums.HatchElement.ExoticEnergy; |
| 11 | +import static gregtech.api.enums.HatchElement.InputBus; |
| 12 | +import static gregtech.api.enums.HatchElement.InputHatch; |
| 13 | +import static gregtech.api.enums.HatchElement.OutputBus; |
| 14 | +import static gregtech.api.enums.HatchElement.OutputHatch; |
| 15 | +import static gregtech.api.util.GTStructureUtility.chainAllGlasses; |
| 16 | +import static java.lang.Integer.MAX_VALUE; |
| 17 | +import static tectech.thing.casing.TTCasingsContainer.GodforgeCasings; |
| 18 | +import static tectech.thing.casing.TTCasingsContainer.sBlockCasingsTT; |
| 19 | + |
| 20 | +import java.util.stream.Collectors; |
| 21 | +import java.util.stream.IntStream; |
| 22 | + |
| 23 | +import javax.annotation.Nonnull; |
| 24 | + |
| 25 | +import net.minecraft.entity.player.EntityPlayer; |
| 26 | +import net.minecraft.item.ItemStack; |
| 27 | +import net.minecraft.nbt.NBTTagCompound; |
| 28 | +import net.minecraft.util.StatCollector; |
| 29 | +import net.minecraftforge.common.util.ForgeDirection; |
| 30 | + |
| 31 | +import org.apache.commons.lang3.tuple.Pair; |
| 32 | +import org.jetbrains.annotations.NotNull; |
| 33 | + |
| 34 | +import com.Nxer.TwistSpaceTechnology.common.init.TstBlocks; |
| 35 | +import com.Nxer.TwistSpaceTechnology.common.machine.multiMachineClasses.GTCM_MultiMachineBase; |
| 36 | +import com.Nxer.TwistSpaceTechnology.util.TextLocalization; |
| 37 | +import com.Nxer.TwistSpaceTechnology.util.TstSharedLocalization; |
| 38 | +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; |
| 39 | +import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; |
| 40 | +import com.gtnewhorizon.structurelib.structure.StructureDefinition; |
| 41 | + |
| 42 | +import goodgenerator.loader.Loaders; |
| 43 | +import gregtech.api.GregTechAPI; |
| 44 | +import gregtech.api.enums.Textures; |
| 45 | +import gregtech.api.interfaces.ITexture; |
| 46 | +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; |
| 47 | +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; |
| 48 | +import gregtech.api.logic.ProcessingLogic; |
| 49 | +import gregtech.api.recipe.RecipeMap; |
| 50 | +import gregtech.api.recipe.RecipeMaps; |
| 51 | +import gregtech.api.render.TextureFactory; |
| 52 | +import gregtech.api.util.GTRecipe; |
| 53 | +import gregtech.api.util.GTUtility; |
| 54 | +import gregtech.api.util.HatchElementBuilder; |
| 55 | +import gregtech.api.util.MultiblockTooltipBuilder; |
| 56 | +import gregtech.api.util.OverclockCalculator; |
| 57 | + |
| 58 | +public class TST_MegaSolarPanelFactory extends GTCM_MultiMachineBase<TST_MegaSolarPanelFactory> { |
| 59 | + |
| 60 | + // region Class Constructor |
| 61 | + |
| 62 | + public TST_MegaSolarPanelFactory(int aID, String aName, String aNameRegional) { |
| 63 | + super(aID, aName, aNameRegional); |
| 64 | + } |
| 65 | + |
| 66 | + public TST_MegaSolarPanelFactory(String aName) { |
| 67 | + super(aName); |
| 68 | + } |
| 69 | + |
| 70 | + @Override |
| 71 | + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { |
| 72 | + return new TST_MegaSolarPanelFactory(mName); |
| 73 | + } |
| 74 | + |
| 75 | + // endregion |
| 76 | + |
| 77 | + // region Processing Logic |
| 78 | + private int casingTier = 0; |
| 79 | + private double speedBonus; |
| 80 | + |
| 81 | + @Override |
| 82 | + protected ProcessingLogic createProcessingLogic() { |
| 83 | + return new ProcessingLogic() { |
| 84 | + |
| 85 | + @NotNull |
| 86 | + @Override |
| 87 | + protected OverclockCalculator createOverclockCalculator(@Nonnull GTRecipe recipe) { |
| 88 | + speedBonus = 1D / (casingTier + 1); |
| 89 | + return super.createOverclockCalculator(recipe).setDurationModifier(speedBonus); |
| 90 | + } |
| 91 | + }; |
| 92 | + } |
| 93 | + |
| 94 | + @Override |
| 95 | + public RecipeMap<?> getRecipeMap() { |
| 96 | + return RecipeMaps.solarFactoryRecipes; |
| 97 | + } |
| 98 | + |
| 99 | + @Override |
| 100 | + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { |
| 101 | + super.onFirstTick(aBaseMetaTileEntity); |
| 102 | + } |
| 103 | + |
| 104 | + @Override |
| 105 | + public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, |
| 106 | + float aX, float aY, float aZ, ItemStack aTool) { |
| 107 | + if (aPlayer.isSneaking()) { |
| 108 | + batchMode = !batchMode; |
| 109 | + if (batchMode) { |
| 110 | + GTUtility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOn")); |
| 111 | + } else { |
| 112 | + GTUtility.sendChatToPlayer(aPlayer, StatCollector.translateToLocal("misc.BatchModeTextOff")); |
| 113 | + } |
| 114 | + return true; |
| 115 | + } |
| 116 | + return false; |
| 117 | + } |
| 118 | + |
| 119 | + @Override |
| 120 | + public boolean supportsBatchMode() { |
| 121 | + return true; |
| 122 | + } |
| 123 | + |
| 124 | + @Override |
| 125 | + protected boolean isEnablePerfectOverclock() { |
| 126 | + return true; |
| 127 | + } |
| 128 | + |
| 129 | + @Override |
| 130 | + public int getMaxParallelRecipes() { |
| 131 | + return MAX_VALUE; |
| 132 | + } |
| 133 | + |
| 134 | + @Override |
| 135 | + public String[] getInfoData() { |
| 136 | + String[] origin = super.getInfoData(); |
| 137 | + String[] ret = new String[origin.length + 1]; |
| 138 | + System.arraycopy(origin, 0, ret, 0, origin.length); |
| 139 | + ret[origin.length] = TstSharedLocalization.MachineInfo.componentTier(this.casingTier + 1); |
| 140 | + |
| 141 | + return ret; |
| 142 | + } |
| 143 | + |
| 144 | + @Override |
| 145 | + public void saveNBTData(NBTTagCompound aNBT) { |
| 146 | + super.saveNBTData(aNBT); |
| 147 | + aNBT.setInteger("casingTier", casingTier); |
| 148 | + } |
| 149 | + |
| 150 | + @Override |
| 151 | + public void loadNBTData(NBTTagCompound aNBT) { |
| 152 | + super.loadNBTData(aNBT); |
| 153 | + } |
| 154 | + // endregion |
| 155 | + |
| 156 | + // region Structure |
| 157 | + |
| 158 | + protected static final int horizontalOffSet = 6; |
| 159 | + protected static final int verticalOffSet = 14; |
| 160 | + protected static final int depthOffSet = 0; |
| 161 | + protected static final String STRUCTURE_PIECE_MAIN = "main"; |
| 162 | + protected static IStructureDefinition<TST_MegaSolarPanelFactory> STRUCTURE_DEFINITION; |
| 163 | + |
| 164 | + @Override |
| 165 | + public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { |
| 166 | + repairMachine(); |
| 167 | + casingTier = 0; |
| 168 | + return checkPiece(STRUCTURE_PIECE_MAIN, horizontalOffSet, verticalOffSet, depthOffSet); |
| 169 | + } |
| 170 | + |
| 171 | + @Override |
| 172 | + public void construct(ItemStack stackSize, boolean hintsOnly) { |
| 173 | + buildPiece(STRUCTURE_PIECE_MAIN, stackSize, hintsOnly, horizontalOffSet, verticalOffSet, depthOffSet); |
| 174 | + } |
| 175 | + |
| 176 | + @Override |
| 177 | + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { |
| 178 | + if (this.mMachine) return -1; |
| 179 | + return this.survivalBuildPiece( |
| 180 | + STRUCTURE_PIECE_MAIN, |
| 181 | + stackSize, |
| 182 | + horizontalOffSet, |
| 183 | + verticalOffSet, |
| 184 | + depthOffSet, |
| 185 | + elementBudget, |
| 186 | + env, |
| 187 | + false, |
| 188 | + true); |
| 189 | + } |
| 190 | + |
| 191 | + @Override |
| 192 | + public IStructureDefinition<TST_MegaSolarPanelFactory> getStructureDefinition() { |
| 193 | + if (null == STRUCTURE_DEFINITION) { |
| 194 | + STRUCTURE_DEFINITION = StructureDefinition.<TST_MegaSolarPanelFactory>builder() |
| 195 | + .addShape(STRUCTURE_PIECE_MAIN, transpose(shape)) |
| 196 | + // A -> ofBlock...(BW_GlasBlocks, 0, ...); |
| 197 | + // B -> ofBlock...(componentAssemblyLineCasing, 0, ...); |
| 198 | + // C -> ofBlock...(gt.blockcasings10, 11, ...); |
| 199 | + // D -> ofBlock...(gt.blockcasingsTT, 9, ...); |
| 200 | + // E -> ofBlock...(gt.godforgecasing, 0, ...); |
| 201 | + // F -> ofBlock...(tile.MetaBlockCasing02, 2, ...); |
| 202 | + |
| 203 | + .addElement('A', chainAllGlasses()) |
| 204 | + .addElement( |
| 205 | + 'B', |
| 206 | + withChannel( |
| 207 | + "component", |
| 208 | + ofBlocksTiered( |
| 209 | + (block, meta) -> block == Loaders.componentAssemblylineCasing ? meta : 0, |
| 210 | + IntStream.range(0, 14) |
| 211 | + .mapToObj(i -> Pair.of(Loaders.componentAssemblylineCasing, i)) |
| 212 | + .collect(Collectors.toList()), |
| 213 | + 0, |
| 214 | + (t, meta) -> t.casingTier = meta, |
| 215 | + t -> t.casingTier))) |
| 216 | + .addElement('C', ofBlock(GregTechAPI.sBlockCasings10, 11)) |
| 217 | + .addElement('D', ofBlock(sBlockCasingsTT, 9)) |
| 218 | + .addElement('E', ofBlock(GodforgeCasings, 0)) |
| 219 | + .addElement( |
| 220 | + 'F', |
| 221 | + HatchElementBuilder.<TST_MegaSolarPanelFactory>builder() |
| 222 | + .atLeast(InputBus, OutputBus, InputHatch, OutputHatch, Energy.or(ExoticEnergy)) |
| 223 | + .adder(TST_MegaSolarPanelFactory::addToMachineList) |
| 224 | + .dot(1) |
| 225 | + .casingIndex(TstBlocks.MetaBlockCasing02.getTextureIndex(2)) |
| 226 | + .buildAndChain(MetaBlockCasing02, 2)) |
| 227 | + .build(); |
| 228 | + } |
| 229 | + return STRUCTURE_DEFINITION; |
| 230 | + } |
| 231 | + |
| 232 | + // spotless:off |
| 233 | + protected static final String[][] shape = new String[][]{ |
| 234 | + {" CFC "," CCCCCCCCC "," CCCCCCCCCCC "," CCCCCCCCCCC "," CCCCCCCCCCC ","CCCCCEEECCCCC","FCCCCEEECCCCF","CCCCCEEECCCCC"," CCCCCCCCCCC "," CCCCCCCCCCC "," CCCCCCCCCCC "," CCCCCCCCC "," CFC "}, |
| 235 | + {" CCCFCCC "," CBBC CBBC "," CB BC ","CB F F BC","CB ACA BC","CC A A CC","F C D C F","CC A A CC","CB ACA BC","CB F F BC"," CB BC "," CBBC CBBC "," CCCFCCC "}, |
| 236 | + {" CFC "," C C "," C C "," F F "," ACA ","C A A C","F C D C F","C A A C"," ACA "," F F "," C C "," C C "," CFC "}, |
| 237 | + {" C C "," "," "," F F "," ACA ","C A A C"," C D C ","C A A C"," ACA "," F F "," "," "," C C "}, |
| 238 | + {" "," "," "," F F "," ACA "," A A "," C D C "," A A "," ACA "," F F "," "," "," "}, |
| 239 | + {" "," "," "," "," CCC "," C C "," C D C "," C C "," CCC "," "," "," "," "}, |
| 240 | + {" "," "," "," "," "," "," D "," "," "," "," "," "," "}, |
| 241 | + {" "," "," "," "," FFF "," F F "," F F "," F F "," FFF "," "," "," "," "}, |
| 242 | + {" "," "," "," "," FFF "," F F "," F F "," F F "," FFF "," "," "," "," "}, |
| 243 | + {" "," "," "," "," "," "," D "," "," "," "," "," "," "}, |
| 244 | + {" "," "," "," "," CCC "," C C "," C D C "," C C "," CCC "," "," "," "," "}, |
| 245 | + {" "," "," "," F F "," ACA "," A A "," C D C "," A A "," ACA "," F F "," "," "," "}, |
| 246 | + {" C C "," "," "," F F "," ACA ","C A A C"," C D C ","C A A C"," ACA "," F F "," "," "," C C "}, |
| 247 | + {" CFC "," C C "," C C "," F F "," ACA ","C A A C","F C D C F","C A A C"," ACA "," F F "," C C "," C C "," CFC "}, |
| 248 | + {" CCC~CCC "," CBBC CBBC "," CB BC ","CB F F BC","CB ACA BC","CC A A CC","F C D C F","CC A A CC","CB ACA BC","CB F F BC"," CB BC "," CBBC CBBC "," CCCFCCC "}, |
| 249 | + {" CFC "," CCCCCCCCC "," CCCCCCCCCCC "," CCCCCCCCCCC "," CCCCCCCCCCC ","CCCCCEEECCCCC","FCCCCEEECCCCF","CCCCCEEECCCCC"," CCCCCCCCCCC "," CCCCCCCCCCC "," CCCCCCCCCCC "," CCCCCCCCC "," CFC "} |
| 250 | + }; |
| 251 | + |
| 252 | + |
| 253 | + // spotless:on |
| 254 | + |
| 255 | + // region General |
| 256 | + |
| 257 | + @Override |
| 258 | + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, |
| 259 | + ForgeDirection forgeDirection, int aColorIndex, boolean aActive, boolean aRedstone) { |
| 260 | + if (side == forgeDirection) { |
| 261 | + if (aActive) return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(181), |
| 262 | + TextureFactory.builder() |
| 263 | + .addIcon(Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER_ACTIVE) |
| 264 | + .extFacing() |
| 265 | + .build(), |
| 266 | + TextureFactory.builder() |
| 267 | + .addIcon(Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER_ACTIVE_GLOW) |
| 268 | + .extFacing() |
| 269 | + .glow() |
| 270 | + .build() }; |
| 271 | + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(181), TextureFactory.builder() |
| 272 | + .addIcon(Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER) |
| 273 | + .extFacing() |
| 274 | + .build(), |
| 275 | + TextureFactory.builder() |
| 276 | + .addIcon(Textures.BlockIcons.OVERLAY_FRONT_HEAT_EXCHANGER_GLOW) |
| 277 | + .extFacing() |
| 278 | + .glow() |
| 279 | + .build() }; |
| 280 | + } |
| 281 | + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(181) }; |
| 282 | + } |
| 283 | + |
| 284 | + @Override |
| 285 | + protected MultiblockTooltipBuilder createTooltip() { |
| 286 | + final MultiblockTooltipBuilder tttt = new MultiblockTooltipBuilder(); |
| 287 | + // spotless:off |
| 288 | + // #tr Tooltip_MegaSolarPanelFactory |
| 289 | + // # Solar Factory |
| 290 | + // #zh_CN 太阳能板制造厂 |
| 291 | + tttt.addMachineType(tr("Tooltip_MegaSolarPanelFactory_MachineType")) |
| 292 | + // #tr Tooltip_MegaSolarPanelFactory_1_00 |
| 293 | + // # {\BOLD}bigger is better! |
| 294 | + // #zh_CN {\BOLD}大就是好! |
| 295 | + .addInfo(tr("Tooltip_MegaSolarPanelFactory_1_00")) |
| 296 | + // #tr Tooltip_MegaSolarPanelFactory_1_01 |
| 297 | + // # {\LIGHT_PURPLE}Perfect overclocking{\GRAY}. |
| 298 | + // #zh_CN 执行{\LIGHT_PURPLE}无损超频{\GRAY}. |
| 299 | + .addInfo(tr("Tooltip_MegaSolarPanelFactory_1_01")) |
| 300 | + // #tr Tooltip_MegaSolarPanelFactory_1_02 |
| 301 | + // # Recipe Time Multiplier = 100% / Component Assembly Line Casing Tier. |
| 302 | + // #zh_CN 耗时倍率 = 100% / 部件装配线外壳等级. |
| 303 | + .addInfo(tr("Tooltip_MegaSolarPanelFactory_1_02")) |
| 304 | + .addSeparator() |
| 305 | + .addInfo(TextLocalization.StructureTooComplex) |
| 306 | + .addInfo(TextLocalization.BLUE_PRINT_INFO) |
| 307 | + .beginStructureBlock(13, 16, 13, false) |
| 308 | + .addInputHatch(TextLocalization.textUseBlueprint, 1) |
| 309 | + .addOutputHatch(TextLocalization.textUseBlueprint, 1) |
| 310 | + .addInputBus(TextLocalization.textUseBlueprint, 1) |
| 311 | + .addOutputBus(TextLocalization.textUseBlueprint, 1) |
| 312 | + .addEnergyHatch(TextLocalization.textUseBlueprint, 1) |
| 313 | + .toolTipFinisher(TextLocalization.ModName); |
| 314 | + // spotless:on |
| 315 | + return tttt; |
| 316 | + } |
| 317 | + |
| 318 | + // endregion |
| 319 | + |
| 320 | +} |
0 commit comments