From 2b424e8295b7071b85a2960a87da91bf0dd3df02 Mon Sep 17 00:00:00 2001 From: Maxim Date: Sat, 22 Jul 2023 16:12:12 +0200 Subject: Implement generic processing logic (#697) * Migrated extruder * Migrated alloy smelter * Migrated arc furnace * Migrated centrifuge * Migrated ICO * Migrated cutter * Migrated dehydrator * Migrated electrolyzer * Migrated fluid heater * Migrated forge hammer * Forgot gtpp machines are cursed * Migrated mac * Migrated mixer * Migrated molecular transformer * Migrated bender * Migrated sifter * Migrated thermal centrifuge * Migrated VF * Migrated washer * Migrated wiremill * Migrated Volcanus * Migrated adv implo compressor * Migrated XL turbines * Migrated chemplant * Migrated MABS * Migrated ABS * Migrated cyclotron * Migrated Zhuhai * Migrated rock breaker * Migrated rocketdyne * Migrated semifluid generator * Migrated QFT * Minor optimization * Migrate refinery * Migrated solar tower * Migrated TGS * Migrated duplicator * Migrated PSS * Migrated algae pond * Migrated froth flotation cell * Migrated LTFR * Migrated LPF * Migrated sparge tower * Migrated salt * Migrated isamill * Migrate DT * Migrated HE * Migrated mass fab * Migrated chisel * Migrated boiler * Migrated steam machines * Migrated amazon * Disable batch mode button on XL turbines * Update dependencies.gradle * Updated dep * Addressed first batch of reviews * Migrated assembler * Removed unused checkRecipe methods * Forgot these * Fix and cleanup chemplant * Removed getAmounfOfOutputs * Removed special multi behavior * Migrated sound mostly * Addressed new reviews * Fix build fail and chisel sound * Derp * More reviews addressed * Oversight on chemplant batchmode * Fix DT speed bonus * Removed iron blast furnace * Removed generator array * Removed * Simplify rocket engine logic * Removed left over artifacts * Minor fixes * Removed nerf chips * Removed tesla tower * Revert and fix chemplant recipe map * Fix chemplant catalyst damaging * Addressed reviews * Derp --------- Co-authored-by: Martin Robertz --- .../machines/multi/misc/GMTE_AmazonPackager.java | 157 +------ .../multi/misc/GregtechMTE_TeslaTower.java | 503 -------------------- ...gtechMetaTileEntity_IndustrialAlloySmelter.java | 111 +---- ...regtechMetaTileEntity_IndustrialArcFurnace.java | 45 +- ...regtechMetaTileEntity_IndustrialCentrifuge.java | 16 +- .../GregtechMetaTileEntity_IndustrialChisel.java | 102 ++--- .../GregtechMetaTileEntity_IndustrialCokeOven.java | 23 +- ...echMetaTileEntity_IndustrialCuttingMachine.java | 16 +- ...regtechMetaTileEntity_IndustrialDehydrator.java | 93 +--- ...gtechMetaTileEntity_IndustrialElectrolyzer.java | 15 +- .../GregtechMetaTileEntity_IndustrialExtruder.java | 51 +-- ...egtechMetaTileEntity_IndustrialFluidHeater.java | 16 +- ...egtechMetaTileEntity_IndustrialForgeHammer.java | 34 +- ...GregtechMetaTileEntity_IndustrialMacerator.java | 26 +- .../GregtechMetaTileEntity_IndustrialMixer.java | 62 +-- ...aTileEntity_IndustrialMolecularTransformer.java | 10 +- ...gtechMetaTileEntity_IndustrialMultiMachine.java | 167 +------ ...regtechMetaTileEntity_IndustrialPlatePress.java | 47 +- .../GregtechMetaTileEntity_IndustrialSifter.java | 21 +- ...MetaTileEntity_IndustrialThermalCentrifuge.java | 16 +- ...techMetaTileEntity_IndustrialVacuumFreezer.java | 10 +- ...GregtechMetaTileEntity_IndustrialWashPlant.java | 33 +- .../GregtechMetaTileEntity_IndustrialWireMill.java | 51 +-- .../GregtechMetaTileEntity_IronBlastFurnace.java | 510 --------------------- .../processing/GregtechMetaTileEntity_IsaMill.java | 86 ++-- ...hMetaTileEntity_NuclearSaltProcessingPlant.java | 48 +- .../GregtechMetaTileEntity_SpargeTower.java | 48 +- ...egtechMetaTileEntity_Adv_DistillationTower.java | 41 +- .../advanced/GregtechMetaTileEntity_Adv_EBF.java | 113 +---- .../GregtechMetaTileEntity_Adv_HeatExchanger.java | 17 +- .../GregtechMetaTileEntity_Adv_Implosion.java | 22 +- .../multi/production/GT4Entity_AutoCrafter.java | 50 +- .../multi/production/GT4Entity_ThermalBoiler.java | 31 +- .../GregtechMTE_ElementalDuplicator.java | 136 ++---- .../production/GregtechMTE_FrothFlotationCell.java | 122 ++--- .../production/GregtechMTE_NuclearReactor.java | 123 ++--- .../GregtechMetaTileEntityGeneratorArray.java | 452 ------------------ .../production/GregtechMetaTileEntityTreeFarm.java | 26 +- .../GregtechMetaTileEntity_AlloyBlastSmelter.java | 128 +----- .../GregtechMetaTileEntity_Cyclotron.java | 116 ++--- ...egtechMetaTileEntity_IndustrialFishingPond.java | 181 +++----- ...egtechMetaTileEntity_IndustrialRockBreaker.java | 89 ++-- .../GregtechMetaTileEntity_LargeRocketEngine.java | 70 +-- ...techMetaTileEntity_LargeSemifluidGenerator.java | 21 +- .../GregtechMetaTileEntity_MassFabricator.java | 297 ++---------- ...techMetaTileEntity_QuantumForceTransformer.java | 446 ++++++++---------- .../GregtechMetaTileEntity_Refinery.java | 22 +- .../GregtechMetaTileEntity_SolarTower.java | 46 +- .../algae/GregtechMTE_AlgaePondBase.java | 97 ++-- .../chemplant/GregtechMTE_ChemicalPlant.java | 298 ++++-------- ...egTechMetaTileEntity_MegaAlloyBlastSmelter.java | 89 ++-- .../turbines/GT_MTE_LargeTurbine_Gas.java | 18 +- .../turbines/GT_MTE_LargeTurbine_Plasma.java | 27 +- .../GregtechMetaTileEntity_LargerTurbineBase.java | 53 +-- ...chMetaTileEntity_PowerSubStationController.java | 13 +- 55 files changed, 1049 insertions(+), 4412 deletions(-) delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GregtechMTE_TeslaTower.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IronBlastFurnace.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntityGeneratorArray.java (limited to 'src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities') diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GMTE_AmazonPackager.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GMTE_AmazonPackager.java index c8e947fbb5..d8c46e11ce 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GMTE_AmazonPackager.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/misc/GMTE_AmazonPackager.java @@ -10,29 +10,21 @@ import static gregtech.api.enums.GT_HatchElement.Muffler; import static gregtech.api.enums.GT_HatchElement.OutputBus; import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import java.util.ArrayList; - import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; 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.enums.GT_Values; -import gregtech.api.enums.ItemList; import gregtech.api.enums.TAE; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.interfaces.tileentity.IHasWorldObjectAndCoords; -import gregtech.api.util.GT_ModHandler; +import gregtech.api.logic.ProcessingLogic; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; -import gtPlusPlus.api.objects.data.AutoMap; -import gtPlusPlus.api.objects.minecraft.ItemStackData; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; @@ -41,8 +33,6 @@ import gtPlusPlus.xmod.gregtech.common.blocks.textures.TexturesGtBlock; public class GMTE_AmazonPackager extends GregtechMeta_MultiBlockBase implements ISurvivalConstructable { - private long mVoltage; - private byte mTier; private int mCasing; private static IStructureDefinition STRUCTURE_DEFINITION = null; @@ -102,11 +92,6 @@ public class GMTE_AmazonPackager extends GregtechMeta_MultiBlockBase tItems = getStoredInputs(); - if (this.getGUIItemStack() != null) { - tItems.add(this.getGUIItemStack()); - } - ItemStack[] tItemInputs = tItems.toArray(new ItemStack[tItems.size()]); - boolean state = checkRecipeGeneric(tItemInputs, sNoFluids, getMaxParallelRecipes(), 75, 500, 10000); - - if (state) { - return true; - } else { - tItems = getStoredInputs(); - AutoMap mCompleted = new AutoMap(); - AutoMap mSchematics = new AutoMap(); - for (ItemStack tInputItem : tItems) { - if (tInputItem != null) { - if (ItemList.Schematic_1by1.isStackEqual((Object) tInputItem) - || ItemList.Schematic_2by2.isStackEqual((Object) tInputItem) - || ItemList.Schematic_3by3.isStackEqual((Object) tInputItem)) { - mSchematics.put(new ItemStackData(tInputItem)); - } - } - } - if (mSchematics.size() > 0) { - for (ItemStackData g : mSchematics) { - for (ItemStack tInputItem : tItems) { - if (tInputItem != null) { - mCompleted.put(new ItemStackData(tInputItem)); - checkRecipe(tInputItem, g.getStack()); - } - } - } - } - - return mCompleted != null && mCompleted.size() > 0; - } - } - - public boolean checkRecipe(ItemStack inputStack, ItemStack schematicStack) { - if (GT_Utility.isStackValid((Object) inputStack) && GT_Utility.isStackValid((Object) schematicStack) - && GT_Utility.getContainerItem(inputStack, true) == null) { - ItemStack tOutputStack; - if (ItemList.Schematic_1by1.isStackEqual((Object) schematicStack) && inputStack.stackSize >= 1) { - tOutputStack = GT_ModHandler.getRecipeOutput(new ItemStack[] { inputStack }); - if (tOutputStack != null && this.allowPutStack(tOutputStack, schematicStack)) { - final ItemStack input = inputStack; - --input.stackSize; - this.lEUt = 32 * (1L << this.mTier - 1) * (1L << this.mTier - 1); - // this.mMaxProgresstime = 16 / (1 << this.mTier - 1); - this.mMaxProgresstime = 2; - this.addOutput(tOutputStack); - updateSlots(); - return true; - } - return false; - } else if (ItemList.Schematic_2by2.isStackEqual((Object) schematicStack) && inputStack.stackSize >= 4) { - tOutputStack = GT_ModHandler - .getRecipeOutput(new ItemStack[] { inputStack, inputStack, null, inputStack, inputStack }); - if (tOutputStack != null && this.allowPutStack(tOutputStack, schematicStack)) { - final ItemStack input2 = inputStack; - input2.stackSize -= 4; - this.lEUt = 32 * (1L << this.mTier - 1) * (1L << this.mTier - 1); - // this.mMaxProgresstime = 32 / (1 << this.mTier - 1); - this.mMaxProgresstime = 4; - this.addOutput(tOutputStack); - updateSlots(); - return true; - } - return false; - } else if (ItemList.Schematic_3by3.isStackEqual((Object) schematicStack) && inputStack.stackSize >= 9) { - tOutputStack = GT_ModHandler.getRecipeOutput( - new ItemStack[] { inputStack, inputStack, inputStack, inputStack, inputStack, inputStack, - inputStack, inputStack, inputStack }); - if (tOutputStack != null && this.allowPutStack(tOutputStack, schematicStack)) { - final ItemStack input3 = inputStack; - input3.stackSize -= 9; - this.lEUt = 32 * (1L << this.mTier - 1) * (1L << this.mTier - 1); - // this.mMaxProgresstime = 64 / (1 << this.mTier - 1); - this.mMaxProgresstime = 6; - this.addOutput(tOutputStack); - updateSlots(); - return true; - } - return false; - } - } - return false; - } - - public boolean allowPutStack(final ItemStack aStack, ItemStack schematicStack) { - // If Schematic Static is not 1x1, 2x2, 3x3 - if (!ItemList.Schematic_1by1.isStackEqual((Object) schematicStack) - && !ItemList.Schematic_2by2.isStackEqual((Object) schematicStack) - && !ItemList.Schematic_3by3.isStackEqual((Object) schematicStack)) { - return GT_Recipe.GT_Recipe_Map.sBoxinatorRecipes.containsInput(aStack); - } - // Something - if (GT_Recipe.GT_Recipe_Map.sBoxinatorRecipes.findRecipe( - (IHasWorldObjectAndCoords) this.getBaseMetaTileEntity(), - true, - GT_Values.V[this.mTier], - (FluidStack[]) null, - new ItemStack[] { GT_Utility.copyAmount(64L, new Object[] { aStack }), schematicStack }) != null) { - return true; - } - // 1x1 - if (ItemList.Schematic_1by1.isStackEqual((Object) schematicStack) - && GT_ModHandler.getRecipeOutput(new ItemStack[] { aStack }) != null) { - return true; - } - // 2x2 - if (ItemList.Schematic_2by2.isStackEqual((Object) schematicStack) - && GT_ModHandler.getRecipeOutput(new ItemStack[] { aStack, aStack, null, aStack, aStack }) != null) { - return true; - } - // 3x3 - if (ItemList.Schematic_3by3.isStackEqual((Object) schematicStack) && GT_ModHandler.getRecipeOutput( - new ItemStack[] { aStack, aStack, aStack, aStack, aStack, aStack, aStack, aStack, aStack }) != null) { - return true; - } - return false; + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setSpeedBonus(1F / 6F).setEuModifier(0.75F) + .setMaxParallelSupplier(this::getMaxParallelRecipes); } @Override @@ -278,11 +139,6 @@ public class GMTE_AmazonPackager extends GregtechMeta_MultiBlockBase { - - private Block casingBlock; - private int casingMeta; - private int frameMeta; - private int casingTextureIndex; - - private ForgeDirection back; - - private int xLoc, yLoc, zLoc; - - protected int mRange; - - /** - * Machine Mode, {@value false} Attacks all entities, {@value true} Only attacks players. - */ - protected volatile boolean mMode = false; - - @Override - public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { - return new GregtechMTE_TeslaTower(mName); - } - - public GregtechMTE_TeslaTower(int aID, String aName, String aNameRegional) { - super(aID, aName, aNameRegional); - initFields(); - } - - public GregtechMTE_TeslaTower(String aName) { - super(aName); - initFields(); - } - - @Override - public String getMachineType() { - return "Weaponized Lighting Rod"; - } - - /* - * @Override public String[] getTooltip() { String casings = getCasingBlockItem().get(0).getDisplayName(); return - * new String[]{ "Controller Block for the Tesla Defence Tower Mk3200", - * "Enemies within "+this.mRange+"m are blasted with a high energy plasma.", "This uses 5,000,000EU per blast.", - * "Can screwdriver to toggle mode between Players and all Entities.", "Size(WxHxD): 3x7x3", - * "Controller (Front middle at bottom)", "3x1x3 Base of " + casings, "1x3x1 " + casings + - * " pillar (Center of base)", "1x3x1 " + MaterialUtils.getMaterialName(getFrameMaterial()) + - * " Frame Boxes (Each pillar side and on top)", "1x Maintenance Hatch (One of base casings)", "1x " + - * VN[getMinTier()] + "+ Energy Hatch (Any bottom layer casing)"}; } - */ - - @Override - protected final GT_Multiblock_Tooltip_Builder createTooltip() { - GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder(); - tt.addMachineType(getMachineType()).addInfo("Controller Block for the Tesla Defence Tower Mk3200") - .addInfo("Enemies within " + this.mRange + "m are blasted with a high energy plasma.") - .addInfo("This uses 5,000,000EU per blast.") - .addInfo("Can screwdriver to toggle mode between Players and all Entities.").addSeparator() - .beginStructureBlock(1, 7, 1, false).addController("Top Middle").addCasingInfoMin("Casing", 360, false) - .addOtherStructurePart("Rotor Assembly", "Any 1 dot hint", 1).addInputBus("Any 4 dot hint (min 1)", 4) - .addInputHatch("Any 4 dot hint(min 1)", 4).addOutputHatch("Any 4 dot hint(min 1)", 4) - .addEnergyHatch("Any 4 dot hint(min 1)", 4).addMaintenanceHatch("Any 4 dot hint(min 1)", 4) - .toolTipFinisher(CORE.GT_Tooltip_Builder.get()); - return tt; - } - - private final void initFields() { - casingBlock = ModBlocks.blockCasings2Misc; - casingMeta = getCasingBlockItem().get(0).getItemDamage(); - casingTextureIndex = getCasingTextureIndex(); - mRange = 50; - } - - @Override - protected IIconContainer getActiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced_Active; - } - - @Override - protected IIconContainer getInactiveOverlay() { - return TexturesGtBlock.Overlay_Machine_Controller_Advanced; - } - - @Override - protected int getCasingTextureId() { - return getCasingTextureIndex(); - } - - @Override - public void saveNBTData(NBTTagCompound aNBT) { - aNBT.setBoolean("mMode", this.mMode); - aNBT.setInteger("mRange", this.mRange); - super.saveNBTData(aNBT); - } - - @Override - public void loadNBTData(NBTTagCompound aNBT) { - this.mMode = aNBT.getBoolean("mMode"); - this.mRange = aNBT.getInteger("mRange"); - super.loadNBTData(aNBT); - } - - private boolean isEnergyEnough() { - if (this.getEUVar() >= 5000000) { - return true; - } - return false; - } - - @Override - public boolean checkRecipe(ItemStack aStack) { - - if (!isEnergyEnough()) { - this.mProgresstime = 0; - this.mMaxProgresstime = 20; - this.getBaseMetaTileEntity().setActive(false); - stopMachine(); - } else { - this.mProgresstime = 1; - this.mMaxProgresstime = 100; - this.getBaseMetaTileEntity().setActive(true); - } - return false; - } - - @Override - public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { - updateCoordinates(); - // check base layer - for (int xOff = -1 + back.offsetX; xOff <= 1 + back.offsetX; xOff++) { - for (int zOff = -1 + back.offsetZ; zOff <= 1 + back.offsetZ; zOff++) { - if (xOff == 0 && zOff == 0) continue; - - IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xOff, 0, zOff); - if (!checkCasingBlock(xOff, 0, zOff) && !addMaintenanceToMachineList(tTileEntity, casingTextureIndex) - && !addEnergyInputToMachineList(tTileEntity, casingTextureIndex)) { - Logger.INFO("bad block"); - return false; - } - } - } - if (!checkHatches()) { - Logger.INFO("bad Hatches"); - return false; - } - if (GT_Utility.getTier(getMaxInputVoltage()) < getMinTier()) { - Logger.INFO("bad Voltage"); - return false; - } - // check tower - for (int yOff = 1; yOff < 4; yOff++) { - if (!checkCasingBlock(back.offsetX, yOff, back.offsetZ) - || !checkFrameBlock(back.offsetX + 1, yOff, back.offsetZ) - || !checkFrameBlock(back.offsetX - 1, yOff, back.offsetZ) - || !checkFrameBlock(back.offsetX, yOff, back.offsetZ + 1) - || !checkFrameBlock(back.offsetX, yOff, back.offsetZ - 1) - || !checkFrameBlock(back.offsetX, yOff + 3, back.offsetZ)) { - Logger.INFO("bad frame?"); - return false; - } - } - Logger.INFO("good"); - return true; - } - - private void updateCoordinates() { - casingTextureIndex = getCasingTextureIndex(); - mRange = 50; - xLoc = getBaseMetaTileEntity().getXCoord(); - yLoc = getBaseMetaTileEntity().getYCoord(); - zLoc = getBaseMetaTileEntity().getZCoord(); - back = getBaseMetaTileEntity().getBackFacing(); - } - - protected boolean checkCasingBlock(int xOff, int yOff, int zOff) { - Logger.INFO("Looking For Casing."); - return checkBlockAndMetaOffset(xOff, yOff, zOff, casingBlock, casingMeta); - } - - // meta of frame is getTileEntityBaseType; frame should be checked using its drops (possible a high weight - // operation) - protected boolean checkFrameBlock(int xOff, int yOff, int zOff) { - Logger.INFO("Looking For Frame."); - return checkBlockAndMetaOffset(xOff, yOff, zOff, GregTech_API.sBlockMachines, frameMeta); - } - - protected boolean checkBlockAndMetaOffset(int xOff, int yOff, int zOff, Block block, int meta) { - return checkBlockAndMeta(xLoc + xOff, yLoc + yOff, zLoc + zOff, block, meta); - } - - private boolean checkBlockAndMeta(int x, int y, int z, Block block, int meta) { - Logger.INFO( - "Found: " + getBaseMetaTileEntity().getBlock(x, y, z).getLocalizedName() - + " | Meta: " - + getBaseMetaTileEntity().getMetaID(x, y, z)); - Logger.INFO("Expected: " + block.getLocalizedName() + " | Meta: " + meta); - return (meta == W || getBaseMetaTileEntity().getMetaID(x, y, z) == meta) - && getBaseMetaTileEntity().getBlock(x, y, z) == block; - } - - @Override - public boolean isCorrectMachinePart(ItemStack aStack) { - return true; - } - - @Override - public int getMaxEfficiency(ItemStack aStack) { - return 10000; - } - - @Override - public int getPollutionPerTick(ItemStack aStack) { - return 0; - } - - @Override - public int getDamageToComponent(ItemStack aStack) { - return 0; - } - - @Override - public boolean explodesOnComponentBreak(ItemStack aStack) { - return false; - } - - protected int getMinTier() { - return 7; - } - - protected boolean checkHatches() { - return !mMaintenanceHatches.isEmpty() && !mEnergyHatches.isEmpty(); - } - - private Map, Entity> mInRange = new HashMap, Entity>(); - - @SuppressWarnings("unchecked") - @Override - public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - try { - if (this.getBaseMetaTileEntity().isServerSide()) { - if (this.mEnergyHatches.size() > 0) { - for (final GT_MetaTileEntity_Hatch_Energy tHatch : this.mEnergyHatches) { - if (isValidMetaTileEntity(tHatch)) { - long mHT = tHatch.getBaseMetaTileEntity().getInputVoltage(); - if (tHatch.getEUVar() >= mHT) { - for (int o = 0; o < (tHatch.getEUVar() / mHT); o++) { - // 1A - if (this.getEUVar() < (this.maxEUStore() - mHT)) { - tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(mHT, false); - this.setEUVar(this.getEUVar() + mHT); - } - // 2A - if (this.getEUVar() < (this.maxEUStore() - mHT)) { - tHatch.getBaseMetaTileEntity().decreaseStoredEnergyUnits(mHT, false); - this.setEUVar(this.getEUVar() + mHT); - } - } - } - } - } - } - - if (aTick % 10 == 0) { - if (this.getEUVar() >= 5000000) { - // Logger.INFO("Can Zap."); - this.getBaseMetaTileEntity().enableWorking(); - this.getBaseMetaTileEntity().setActive(true); - if (this.mProgresstime <= 0) { - this.mProgresstime++; - } else if (this.mProgresstime >= 100) { - this.mProgresstime = 0; - } - this.mMaxProgresstime = 10000; - } - // Logger.INFO("Allowed to be Working? "+this.getBaseMetaTileEntity().isAllowedToWork()); - // Logger.INFO("Working? "+this.getBaseMetaTileEntity().isActive()); - // Logger.INFO("Has Working just been enabled? - // "+this.getBaseMetaTileEntity().hasWorkJustBeenEnabled()); - } - - if (aTick % 20 == 0) { - List o = aBaseMetaTileEntity.getWorld().loadedEntityList; - // Clean up old entities first - if (this.mInRange.size() > 0) { - for (Entity j : this.mInRange.values()) { - if (((Entity) j).getDistance(this.xLoc, this.yLoc, this.zLoc) > this.mRange) { - mInRange.remove( - new Pair( - ((Entity) j).getUniqueID().getMostSignificantBits(), - ((Entity) j).getUniqueID().getLeastSignificantBits()), - (Entity) j); - } - } - } - // Add new entities - if (o.size() > 0) { - for (Object r : o) { - if (r instanceof Entity) { - if (!((Entity) r).getUniqueID().equals(getOwner())) { - if (((Entity) r).isEntityAlive() || r instanceof EntityLiving) { - if (((Entity) r).getDistance(this.xLoc, this.yLoc, this.zLoc) <= this.mRange) { - if (r instanceof EntityItem) { - // Do nothing - } else { - if (!this.mMode) { - mInRange.put( - new Pair( - ((Entity) r).getUniqueID().getMostSignificantBits(), - ((Entity) r).getUniqueID() - .getLeastSignificantBits()), - (Entity) r); - } else { - if (r instanceof EntityPlayer) { - mInRange.put( - new Pair( - ((Entity) r).getUniqueID() - .getMostSignificantBits(), - ((Entity) r).getUniqueID() - .getLeastSignificantBits()), - (Entity) r); - } - } - } - } - } - } - } - } - } - } - } - } catch (Throwable r) { - - } - super.onPreTick(aBaseMetaTileEntity, aTick); - } - - @Override - public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { - try { - if (this.getBaseMetaTileEntity().isServerSide()) { - // Handle Progress Time - if (this.getEUVar() >= 0 && !this.getBaseMetaTileEntity().isAllowedToWork()) { - this.mProgresstime = 20; - this.mMaxProgresstime = 40; - } else if (this.getEUVar() >= 0 && this.getBaseMetaTileEntity().isAllowedToWork()) { - this.mProgresstime = 20; - this.mMaxProgresstime = 40; - } - - if (aTick % 10 == 0) { - if (this.mInRange.size() > 0) { - if (this.getEUVar() >= 5000000) { - - for (Entity f : mInRange.values()) { - if (f instanceof EntityLiving) { - int j1 = (int) f.posX; - int l1 = (int) f.posY; - int k1 = (int) f.posZ; - World world = aBaseMetaTileEntity.getWorld(); - - if (f.isEntityAlive() && !f.getUniqueID().equals(getOwner())) { - // if (world.canLightningStrikeAt(j1, l1+1, k1)){ - // if (isEnergyEnough() && world.addWeatherEffect(new - // EntityTeslaTowerLightning(world, (double)j1, (double)l1, (double)k1))){ - if (isEnergyEnough() && world.addWeatherEffect( - new EntityTeslaTowerLightning( - world, - (double) j1, - (double) l1, - (double) k1, - f, - getOwner()))) { - if (f == null || f.isDead || !f.isEntityAlive()) { - this.mInRange.remove( - new Pair( - f.getUniqueID().getMostSignificantBits(), - f.getUniqueID().getLeastSignificantBits())); - } - this.setEUVar(this.getEUVar() - 5000000); - } - // } - } - } - } - } - } - } - } - } catch (Throwable r) { - - } - super.onPostTick(aBaseMetaTileEntity, aTick); - } - - protected GregtechItemList getCasingBlockItem() { - return GregtechItemList.Casing_TeslaTower; - } - - protected int getCasingTextureIndex() { - return TAE.GTPP_INDEX(30); - } - - public UUID getOwner() { - return PlayerUtils.getPlayersUUIDByName(this.getBaseMetaTileEntity().getOwnerName()); - } - - @Override - public boolean isEnetInput() { - return false; - } - - @Override - public long maxAmperesIn() { - return 32; - } - - @Override - public long maxEUInput() { - return 131072; - } - - @Override - public long maxEUStore() { - return Integer.MAX_VALUE; - } - - @Override - public void onModeChangeByScrewdriver(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { - mMode = Utils.invertBoolean(mMode); - this.mInRange.clear(); - if (mMode) { - PlayerUtils.messagePlayer(aPlayer, "[Tesla Tower] Now only targetting players."); - } else { - PlayerUtils.messagePlayer(aPlayer, "[Tesla Tower] Targetting all types of entities."); - } - } - - @Override - public int getMaxParallelRecipes() { - return 0; - } - - @Override - public int getEuDiscountForParallelism() { - return 0; - } - - @Override - public void construct(ItemStack stackSize, boolean hintsOnly) { - // TODO Auto-generated method stub - - } - - @Override - public IStructureDefinition getStructureDefinition() { - // TODO Auto-generated method stub - return null; - } - - @Override - public boolean doesBindPlayerInventory() { - return false; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialAlloySmelter.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialAlloySmelter.java index d2ec846d8f..0a8df0f104 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialAlloySmelter.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialAlloySmelter.java @@ -11,10 +11,9 @@ import static gregtech.api.enums.GT_HatchElement.OutputBus; import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; import static gregtech.api.util.GT_StructureUtility.ofCoil; -import java.util.ArrayList; - import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.NotNull; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; @@ -27,13 +26,12 @@ import gregtech.api.enums.Textures; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; +import gregtech.api.logic.ProcessingLogic; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_OverclockCalculator; import gregtech.api.util.GT_ParallelHelper; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; -import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; @@ -183,98 +181,21 @@ public class GregtechMetaTileEntity_IndustrialAlloySmelter extends } @Override - public int getEuDiscountForParallelism() { - return 100; - } + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { - @Override - public boolean checkRecipe(ItemStack aStack) { - FluidStack[] tFluids = getStoredFluids().toArray(new FluidStack[0]); - for (GT_MetaTileEntity_Hatch_InputBus tBus : mInputBusses) { - ArrayList tInputs = new ArrayList<>(); - if (isValidMetaTileEntity(tBus)) { - for (int i = tBus.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { - if (tBus.getBaseMetaTileEntity().getStackInSlot(i) != null) { - tInputs.add(tBus.getBaseMetaTileEntity().getStackInSlot(i)); - } - } + @NotNull + @Override + protected GT_OverclockCalculator createOverclockCalculator(@NotNull GT_Recipe recipe, + @NotNull GT_ParallelHelper helper) { + return super.createOverclockCalculator(recipe, helper).setSpeedBoost(100F / (100F + 5F * mLevel)) + .enableHeatOC().setRecipeHeat(0) + // Need to multiply by 2 because heat OC is done only once every 1800 and this one does it once + // every + // 900 + .setMultiHeat((int) (getCoilLevel().getHeat() * 2)); } - if (tInputs.size() > 1) { - ItemStack[] tItems = tInputs.toArray(new ItemStack[0]); - if (checkRecipeGeneric(tItems, tFluids, getMaxParallelRecipes(), 100, 5 * this.mLevel, 10000)) { - return true; - } - } - } - return false; - } - - @Override - public boolean checkRecipeGeneric(ItemStack[] aItemInputs, FluidStack[] aFluidInputs, int aMaxParallelRecipes, - long aEUPercent, int aSpeedBonusPercent, int aOutputChanceRoll) { - // Based on the Processing Array. A bit overkill, but very flexible. - - // Reset outputs and progress stats - this.lEUt = 0; - this.mMaxProgresstime = 0; - this.mOutputItems = new ItemStack[] {}; - this.mOutputFluids = new FluidStack[] {}; - - long tVoltage = getMaxInputVoltage(); - byte tTier = (byte) Math.max(1, GT_Utility.getTier(tVoltage)); - long tEnergy = getMaxInputEnergy(); - - GT_Recipe tRecipe = this.getRecipeMap().findRecipe( - getBaseMetaTileEntity(), - mLastRecipe, - false, - gregtech.api.enums.GT_Values.V[tTier], - aFluidInputs, - aItemInputs); - - // Remember last recipe - an optimization for findRecipe() - this.mLastRecipe = tRecipe; - - if (tRecipe == null) { - Logger.WARNING("BAD RETURN - 1"); - return false; - } - - GT_ParallelHelper helper = new GT_ParallelHelper().setRecipe(tRecipe).setItemInputs(aItemInputs) - .setFluidInputs(aFluidInputs).setAvailableEUt(tEnergy).setMaxParallel(aMaxParallelRecipes) - .enableConsumption().enableOutputCalculation().setEUtModifier(aEUPercent / 100.0f).setController(this); - - if (batchMode) { - helper.enableBatchMode(128); - } - - helper.build(); - - if (helper.getCurrentParallel() == 0) { - return false; - } - - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - GT_OverclockCalculator calculator = new GT_OverclockCalculator().setRecipeEUt(tRecipe.mEUt).setEUt(tEnergy) - .setDuration(tRecipe.mDuration).setEUtDiscount(aEUPercent / 100.0f) - .setSpeedBoost(100.0f / (100.0f + aSpeedBonusPercent)) - .setParallel((int) Math.floor(helper.getCurrentParallel() / helper.getDurationMultiplier())) - .enableHeatOC().setRecipeHeat(0) - // Need to multiple by 2 because heat OC is done only once every 1800 and this one does it once every - // 900 - .setMultiHeat((int) getCoilLevel().getHeat() * 2).calculate(); - lEUt = -calculator.getConsumption(); - mMaxProgresstime = (int) Math.ceil(calculator.getDuration() * helper.getDurationMultiplier()); - - mOutputItems = helper.getItemOutputs(); - mOutputFluids = helper.getFluidOutputs(); - updateSlots(); - - // Play sounds (GT++ addition - GT multiblocks play no sounds) - startProcess(); - return true; + }.setMaxParallelSupplier(this::getMaxParallelRecipes); } public HeatingCoilLevel getCoilLevel() { diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialArcFurnace.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialArcFurnace.java index 8b7ced1103..1b3822ca3f 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialArcFurnace.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialArcFurnace.java @@ -28,6 +28,7 @@ import gregtech.api.enums.TAE; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; @@ -112,14 +113,11 @@ public class GregtechMetaTileEntity_IndustrialArcFurnace extends } private int getSizeFromHint(ItemStack stackSize) { - switch (stackSize.stackSize) { - case 1: - return 3; - case 2: - return 5; - default: - return 7; - } + return switch (stackSize.stackSize) { + case 1 -> 3; + case 2 -> 5; + default -> 7; + }; } @Override @@ -166,8 +164,8 @@ public class GregtechMetaTileEntity_IndustrialArcFurnace extends } @Override - public String getSound() { - return SoundResource.IC2_MACHINES_ELECTROFURNACE_LOOP.toString(); + protected SoundResource getProcessStartSound() { + return SoundResource.IC2_MACHINES_ELECTROFURNACE_LOOP; } @Override @@ -192,8 +190,8 @@ public class GregtechMetaTileEntity_IndustrialArcFurnace extends } @Override - public boolean checkRecipe(final ItemStack aStack) { - return this.checkRecipeGeneric(getMaxParallelRecipes(), 100, 250); + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setSpeedBonus(1F / 3.5F).setMaxParallelSupplier(this::getMaxParallelRecipes); } @Override @@ -201,16 +199,6 @@ public class GregtechMetaTileEntity_IndustrialArcFurnace extends return (this.mSize * 8 * GT_Utility.getTier(this.getMaxInputVoltage())); } - @Override - public int getEuDiscountForParallelism() { - return 100; - } - - @Override - public void startProcess() { - this.sendLoopStart((byte) 1); - } - @Override public int getMaxEfficiency(final ItemStack aStack) { return 10000; @@ -221,11 +209,6 @@ public class GregtechMetaTileEntity_IndustrialArcFurnace extends return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialArcFurnace; } - @Override - public int getAmountOfOutputs() { - return 1; - } - @Override public boolean explodesOnComponentBreak(final ItemStack aStack) { return false; @@ -239,14 +222,6 @@ public class GregtechMetaTileEntity_IndustrialArcFurnace extends return 3; } - public Block getCasingBlock2() { - return ModBlocks.blockCasings3Misc; - } - - public byte getCasingMeta2() { - return 15; - } - public byte getCasingTextureIndex() { return (byte) mCasingTextureID; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCentrifuge.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCentrifuge.java index 4e9fdacca0..44a69fd78f 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCentrifuge.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCentrifuge.java @@ -27,6 +27,7 @@ import gregtech.api.enums.TAE; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; import gregtech.api.util.GTPP_Recipe; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; @@ -145,8 +146,9 @@ public class GregtechMetaTileEntity_IndustrialCentrifuge extends } @Override - public boolean checkRecipe(final ItemStack aStack) { - return checkRecipeGeneric(6 * GT_Utility.getTier(this.getMaxInputVoltage()), 90, 125); + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setEuModifier(0.9F).setSpeedBonus(1F / 2.25F) + .setMaxParallelSupplier(this::getMaxParallelRecipes); } @Override @@ -154,11 +156,6 @@ public class GregtechMetaTileEntity_IndustrialCentrifuge extends return (6 * GT_Utility.getTier(this.getMaxInputVoltage())); } - @Override - public int getEuDiscountForParallelism() { - return 90; - } - public Block getCasingBlock() { return ModBlocks.blockCasingsMisc; } @@ -181,11 +178,6 @@ public class GregtechMetaTileEntity_IndustrialCentrifuge extends return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialCentrifuge; } - @Override - public int getAmountOfOutputs() { - return 1; - } - @Override public boolean explodesOnComponentBreak(final ItemStack aStack) { return false; diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialChisel.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialChisel.java index e78aa4d250..19976c8c6b 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialChisel.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialChisel.java @@ -10,26 +10,29 @@ import static gregtech.api.enums.GT_HatchElement.Muffler; import static gregtech.api.enums.GT_HatchElement.OutputBus; import static gregtech.api.util.GT_StructureUtility.buildHatchAdder; -import java.util.ArrayList; import java.util.List; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; import net.minecraftforge.fluids.FluidStack; +import org.jetbrains.annotations.NotNull; + 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.enums.SoundResource; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; +import gregtech.api.recipe.check.FindRecipeResult; import gregtech.api.util.GTPP_Recipe; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; -import gregtech.api.util.GT_OverclockCalculator; -import gregtech.api.util.GT_ParallelHelper; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import gtPlusPlus.core.block.ModBlocks; @@ -253,7 +256,7 @@ public class GregtechMetaTileEntity_IndustrialChisel } } } else { - target = this.getGUIItemStack(); // Common buses + target = this.getControllerSlot(); // Common buses for (int i = bus.getSizeInventory() - 1; i >= 0; i--) { ItemStack itemsInSlot = bus.mInventory[i]; if (itemsInSlot != null) { @@ -270,85 +273,48 @@ public class GregtechMetaTileEntity_IndustrialChisel } @Override - public boolean checkRecipe(final ItemStack aStack) { - GT_Recipe tRecipe = getRecipe(); - if (tRecipe == null) return false; - - ArrayList aItems = this.getStoredInputs(); - - // Based on the Processing Array. A bit overkill, but very flexible. - ItemStack[] aItemInputs = aItems.toArray(new ItemStack[aItems.size()]); - - // Reset outputs and progress stats - this.lEUt = 0; - this.mMaxProgresstime = 0; - this.mOutputItems = new ItemStack[] {}; - this.mOutputFluids = new FluidStack[] {}; - long tEnergy = getMaxInputEnergy(); - - // Remember last recipe - an optimization for findRecipe() - this.mLastRecipe = tRecipe; - - int aMaxParallelRecipes = getMaxParallelRecipes(); - int aEUPercent = getEuDiscountForParallelism(); - int aSpeedBonusPercent = 200; - - GT_ParallelHelper helper = new GT_ParallelHelper().setRecipe(tRecipe).setItemInputs(aItemInputs) - .setAvailableEUt(tEnergy).setMaxParallel(aMaxParallelRecipes).enableConsumption() - .enableOutputCalculation().setEUtModifier(aEUPercent / 100.0f).setController(this); - - if (batchMode) { - helper.enableBatchMode(128); - } - - helper.build(); - - if (helper.getCurrentParallel() == 0) { - return false; - } - - this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000); - this.mEfficiencyIncrease = 10000; - - GT_OverclockCalculator calculator = new GT_OverclockCalculator().setRecipeEUt(tRecipe.mEUt).setEUt(tEnergy) - .setDuration(tRecipe.mDuration).setEUtDiscount(aEUPercent / 100.0f) - .setSpeedBoost(100.0f / (100.0f + aSpeedBonusPercent)) - .setParallel((int) Math.floor(helper.getCurrentParallel() / helper.getDurationMultiplier())) - .calculate(); - lEUt = -calculator.getConsumption(); - mMaxProgresstime = (int) Math.ceil(calculator.getDuration() * helper.getDurationMultiplier()); - - mOutputItems = helper.getItemOutputs(); - - updateSlots(); - - // Play sounds (GT++ addition - GT multiblocks play no sounds) - startProcess(); - return true; + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @NotNull + @Override + protected FindRecipeResult findRecipe(GT_Recipe.GT_Recipe_Map map) { + GT_Recipe recipe = getRecipe(); + if (recipe == null) { + return FindRecipeResult.NOT_FOUND; + } + return FindRecipeResult.ofSuccess(recipe); + } + }.setSpeedBonus(1F / 3F).setEuModifier(0.75F).setMaxParallelSupplier(this::getMaxParallelRecipes); } @Override - public int getMaxParallelRecipes() { - return (16 * GT_Utility.getTier(this.getMaxInputVoltage())); + protected void sendStartMultiBlockSoundLoop() { + sendLoopStart(PROCESS_START_SOUND_INDEX); } @Override - public int getEuDiscountForParallelism() { - return 75; + public int getMaxParallelRecipes() { + return (16 * GT_Utility.getTier(this.getMaxInputVoltage())); } - private static String sChiselSound = null; + private static ResourceLocation sChiselSound = null; - private static String getChiselSound() { + private static ResourceLocation getChiselSound() { if (sChiselSound == null) { - sChiselSound = Carving.chisel.getVariationSound(Blocks.stone, 0); + sChiselSound = new ResourceLocation(Carving.chisel.getVariationSound(Blocks.stone, 0)); } return sChiselSound; } @Override - public String getSound() { - return getChiselSound(); + public void doSound(byte aIndex, double aX, double aY, double aZ) { + switch (aIndex) { + case PROCESS_START_SOUND_INDEX -> GT_Utility + .doSoundAtClient(getChiselSound(), getTimeBetweenProcessSounds(), 1.0F, 1.0F, aX, aY, aZ); + case INTERRUPT_SOUND_INDEX -> GT_Utility + .doSoundAtClient(SoundResource.IC2_MACHINES_INTERRUPT_ONE, 100, 1.0F, aX, aY, aZ); + } } @Override diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCokeOven.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCokeOven.java index d725a8a3a6..9307739bf8 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCokeOven.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCokeOven.java @@ -25,6 +25,7 @@ import gregtech.api.enums.TAE; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; import gregtech.api.util.GTPP_Recipe; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; @@ -146,8 +147,8 @@ public class GregtechMetaTileEntity_IndustrialCokeOven extends } @Override - public String getSound() { - return SoundResource.IC2_MACHINES_ELECTROFURNACE_LOOP.toString(); + protected SoundResource getProcessStartSound() { + return SoundResource.IC2_MACHINES_ELECTROFURNACE_LOOP; } @Override @@ -171,18 +172,19 @@ public class GregtechMetaTileEntity_IndustrialCokeOven extends } @Override - public boolean checkRecipe(final ItemStack aStack) { - return checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), 0); + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setMaxParallelSupplier(this::getMaxParallelRecipes); } @Override - public int getMaxParallelRecipes() { - return this.mLevel * 12; + protected void setupProcessingLogic(ProcessingLogic logic) { + super.setupProcessingLogic(logic); + logic.setEuModifier((100F - (GT_Utility.getTier(getMaxInputVoltage()) * 4)) / 100F); } @Override - public int getEuDiscountForParallelism() { - return (100 - (GT_Utility.getTier(this.getMaxInputVoltage()) * 4)); + public int getMaxParallelRecipes() { + return this.mLevel * 12; } @Override @@ -195,11 +197,6 @@ public class GregtechMetaTileEntity_IndustrialCokeOven extends return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialCokeOven; } - @Override - public int getAmountOfOutputs() { - return 24; - } - @Override public boolean explodesOnComponentBreak(final ItemStack aStack) { return false; diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCuttingMachine.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCuttingMachine.java index c45621414d..dfa6eb0130 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCuttingMachine.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialCuttingMachine.java @@ -26,6 +26,7 @@ import gregtech.api.enums.TAE; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; @@ -135,8 +136,9 @@ public class GregtechMetaTileEntity_IndustrialCuttingMachine extends } @Override - public boolean checkRecipe(final ItemStack aStack) { - return checkRecipeGeneric((4 * GT_Utility.getTier(this.getMaxInputVoltage())), 75, 200); + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic().setSpeedBonus(1F / 3F).setEuModifier(0.75F) + .setMaxParallelSupplier(this::getMaxParallelRecipes); } @Override @@ -144,11 +146,6 @@ public class GregtechMetaTileEntity_IndustrialCuttingMachine extends return (4 * GT_Utility.getTier(this.getMaxInputVoltage())); } - @Override - public int getEuDiscountForParallelism() { - return 75; - } - @Override public int getMaxEfficiency(final ItemStack aStack) { return 10000; @@ -159,11 +156,6 @@ public class GregtechMetaTileEntity_IndustrialCuttingMachine extends return CORE.ConfigSwitches.pollutionPerSecondMultiIndustrialCuttingMachine; } - @Override - public int getAmountOfOutputs() { - return 2; - } - @Override public boolean explodesOnComponentBreak(final ItemStack aStack) { return false; diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialDehydrator.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialDehydrator.java index 6a99ff8574..c435e87938 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialDehydrator.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialDehydrator.java @@ -17,7 +17,8 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.NotNull; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; @@ -29,12 +30,14 @@ import gregtech.api.enums.TAE; import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; import gregtech.api.util.GTPP_Recipe; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_OverclockCalculator; import gregtech.api.util.GT_ParallelHelper; import gregtech.api.util.GT_Recipe; -import gregtech.api.util.GT_Utility; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.util.Utils; @@ -174,78 +177,24 @@ public class GregtechMetaTileEntity_IndustrialDehydrator extends } @Override - public int getEuDiscountForParallelism() { - return 50; - } + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { - @Override - public boolean checkRecipe(ItemStack aStack) { - return checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), 120); - } + @NotNull + @Overrid