package gregtech.common.tileentities.machines.multi; import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; import static gregtech.api.enums.GTValues.AuthorFourIsTheNumber; import static gregtech.api.enums.HatchElement.Energy; import static gregtech.api.enums.HatchElement.InputBus; import static gregtech.api.enums.HatchElement.InputHatch; import static gregtech.api.enums.HatchElement.Maintenance; import static gregtech.api.enums.HatchElement.OutputBus; import static gregtech.api.enums.HatchElement.OutputHatch; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_MULTI_BREWERY; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_MULTI_BREWERY_ACTIVE; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_MULTI_BREWERY_ACTIVE_GLOW; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_MULTI_BREWERY_GLOW; import static gregtech.api.util.GTStructureUtility.buildHatchAdder; import static gregtech.api.util.GTStructureUtility.ofFrame; 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.Materials; 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.multitileentity.multiblock.casing.Glasses; import gregtech.api.recipe.RecipeMap; import gregtech.api.recipe.RecipeMaps; import gregtech.api.render.TextureFactory; import gregtech.api.util.GTUtility; import gregtech.api.util.MultiblockTooltipBuilder; import gregtech.common.blocks.BlockCasings10; public class MTEIndustrialBrewery extends MTEExtendedPowerMultiBlockBase implements ISurvivalConstructable { private static final String STRUCTURE_PIECE_MAIN = "main"; private static final IStructureDefinition STRUCTURE_DEFINITION = StructureDefinition .builder() .addShape( STRUCTURE_PIECE_MAIN, // spotless:off new String[][]{{ "BBB", "BBB", "B~B", "BBB", "C C" },{ "BBB", "A A", "A A", "BBB", " " },{ "BBB", "BAB", "BAB", "BBB", "C C" }}) //spotless:on .addElement( 'B', buildHatchAdder(MTEIndustrialBrewery.class) .atLeast(InputBus, OutputBus, InputHatch, OutputHatch, Maintenance, Energy) .casingIndex(((BlockCasings10) GregTechAPI.sBlockCasings10).getTextureIndex(15)) .dot(1) .buildAndChain( onElementPass(MTEIndustrialBrewery::onCasingAdded, ofBlock(GregTechAPI.sBlockCasings10, 15)))) .addElement('A', Glasses.chainAllGlasses()) .addElement('C', ofFrame(Materials.Steel)) .build(); public MTEIndustrialBrewery(final int aID, final String aName, final String aNameRegional) { super(aID, aName, aNameRegional); } public MTEIndustrialBrewery(String aName) { super(aName); } @Override public IStructureDefinition getStructureDefinition() { return STRUCTURE_DEFINITION; } @Override public boolean isCorrectMachinePart(ItemStack aStack) { return true; } @Override public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { return new MTEIndustrialBrewery(this.mName); } @Override public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection side, ForgeDirection aFacing, int colorIndex, boolean aActive, boolean redstoneLevel) { ITexture[] rTexture; if (side == aFacing) { if (aActive) { rTexture = new ITexture[] { Textures.BlockIcons .getCasingTextureForId(GTUtility.getCasingTextureIndex(GregTechAPI.sBlockCasings10, 15)), TextureFactory.builder() .addIcon(OVERLAY_FRONT_MULTI_BREWERY_ACTIVE) .extFacing() .build(), TextureFactory.builder() .addIcon(OVERLAY_FRONT_MULTI_BREWERY_ACTIVE_GLOW) .extFacing() .glow() .build() }; } else { rTexture = new ITexture[] { Textures.BlockIcons .getCasingTextureForId(GTUtility.getCasingTextureIndex(GregTechAPI.sBlockCasings10, 15)), TextureFactory.builder() .addIcon(OVERLAY_FRONT_MULTI_BREWERY) .extFacing() .build(), TextureFactory.builder() .addIcon(OVERLAY_FRONT_MULTI_BREWERY_GLOW) .extFacing() .glow() .build() }; } } else { rTexture = new ITexture[] { Textures.BlockIcons .getCasingTextureForId(GTUtility.getCasingTextureIndex(GregTechAPI.sBlockCasings10, 15)) }; } return rTexture; } @Override protected MultiblockTooltipBuilder createTooltip() { MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); tt.addMachineType("Brewery") .addInfo("50% faster than singleblock machines of the same voltage") .addInfo("Gains 4 parallels per voltage tier") .beginStructureBlock(3, 5, 3, true) .addController("Front Center") .addCasingInfoMin("Reinforced Wooden Casing", 14, false) .addCasingInfoExactly("Any Glass", 6, false) .addCasingInfoExactly("Steel Frame Box", 4, false) .addInputBus("Any Wooden Casing", 1) .addOutputBus("Any Wooden Casing", 1) .addInputHatch("Any Wooden Casing", 1) .addOutputHatch("Any Wooden Casing", 1) .addEnergyHatch("Any Wooden Casing", 1) .addMaintenanceHatch("Any Wooden Casing", 1) .toolTipFinisher(AuthorFourIsTheNumber); return tt; } @Override public void construct(ItemStack stackSize, boolean hintsOnly) { buildPiece(STRUCTURE_PIECE_MAIN, stackSize, hintsOnly, 1, 2, 0); } @Override public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { if (mMachine) return -1; return survivialBuildPiece(STRUCTURE_PIECE_MAIN, stackSize, 1, 2, 0, elementBudget, env, false, true); } private int mCasingAmount; private void onCasingAdded() { mCasingAmount++; } @Override public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { mCasingAmount = 0; return checkPiece(STRUCTURE_PIECE_MAIN, 1, 2, 0) && mCasingAmount >= 14; } @Override protected void setProcessingLogicPower(ProcessingLogic logic) { logic.setAvailableVoltage(GTUtility.roundUpVoltage(this.getMaxInputVoltage())); logic.setAvailableAmperage(1L); } @Override protected ProcessingLogic createProcessingLogic() { return new ProcessingLogic().setSpeedBonus(1F / 1.5F) .setMaxParallelSupplier(this::getMaxParallelRecipes); } public int getMaxParallelRecipes() { return (4 * GTUtility.getTier(this.getMaxInputVoltage())); } @Override public RecipeMap getRecipeMap() { return RecipeMaps.brewingRecipes; } @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; } }