From 3f8d6f1ba4f5835db60e69928b844a22f39c85c1 Mon Sep 17 00:00:00 2001 From: Ghzdude <44148655+ghzdude@users.noreply.github.com> Date: Wed, 6 Dec 2023 19:53:37 -0700 Subject: [PATCH] =?UTF-8?q?Rework=20Generators=202.0=20=E2=84=A2=EF=B8=8F?= =?UTF-8?q?=20=20(#2255)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/capability/impl/FuelRecipeLogic.java | 5 ++ .../SimpleGeneratorMetaTileEntity.java | 6 -- .../MetaTileEntityLargeCombustionEngine.java | 75 +++++++++++-------- 3 files changed, 48 insertions(+), 38 deletions(-) diff --git a/src/main/java/gregtech/api/capability/impl/FuelRecipeLogic.java b/src/main/java/gregtech/api/capability/impl/FuelRecipeLogic.java index 1222349e113..64e305fb20a 100644 --- a/src/main/java/gregtech/api/capability/impl/FuelRecipeLogic.java +++ b/src/main/java/gregtech/api/capability/impl/FuelRecipeLogic.java @@ -46,4 +46,9 @@ public int getParallelLimit() { // parallel is limited by voltage return Integer.MAX_VALUE; } + + @Override + public boolean isAllowOverclocking() { + return false; + } } diff --git a/src/main/java/gregtech/api/metatileentity/SimpleGeneratorMetaTileEntity.java b/src/main/java/gregtech/api/metatileentity/SimpleGeneratorMetaTileEntity.java index 3cac1149fcb..ee42074ecaa 100644 --- a/src/main/java/gregtech/api/metatileentity/SimpleGeneratorMetaTileEntity.java +++ b/src/main/java/gregtech/api/metatileentity/SimpleGeneratorMetaTileEntity.java @@ -8,7 +8,6 @@ import gregtech.api.capability.impl.RecipeLogicEnergy; import gregtech.api.gui.GuiTextures; import gregtech.api.gui.ModularUI; -import gregtech.api.gui.widgets.CycleButtonWidget; import gregtech.api.gui.widgets.LabelWidget; import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; import gregtech.api.recipes.RecipeMap; @@ -111,11 +110,6 @@ protected ModularUI.Builder createGuiTemplate(EntityPlayer player) { builder.widget(new LabelWidget(6, 6, getMetaFullName())) .bindPlayerInventory(player.inventory, GuiTextures.SLOT, yOffset); - builder.widget(new CycleButtonWidget(7, 62 + yOffset, 18, 18, - workable.getAvailableOverclockingTiers(), workable::getOverclockTier, workable::setOverclockTier) - .setTooltipHoverString("gregtech.gui.overclock.description") - .setButtonTexture(GuiTextures.BUTTON_OVERCLOCK)); - return builder; } diff --git a/src/main/java/gregtech/common/metatileentities/multi/electric/generator/MetaTileEntityLargeCombustionEngine.java b/src/main/java/gregtech/common/metatileentities/multi/electric/generator/MetaTileEntityLargeCombustionEngine.java index 64f7bedd107..4b298f25cd0 100644 --- a/src/main/java/gregtech/common/metatileentities/multi/electric/generator/MetaTileEntityLargeCombustionEngine.java +++ b/src/main/java/gregtech/common/metatileentities/multi/electric/generator/MetaTileEntityLargeCombustionEngine.java @@ -344,7 +344,8 @@ public LargeCombustionEngineWorkableHandler(RecipeMapMultiblockController tileEn @Override protected void updateRecipeProgress() { if (canRecipeProgress && drawEnergy(recipeEUt, true)) { - + drainLubricant(); + drainOxygen(); drawEnergy(recipeEUt, false); // as recipe starts with progress on 1 this has to be > only not => to compensate for it @@ -354,11 +355,49 @@ protected void updateRecipeProgress() { } } + protected void checkOxygen() { + // check oxygen if present to boost production, and if the dynamo hatch supports it + if (combustionEngine.isBoostAllowed()) { + IMultipleTankHandler inputTank = combustionEngine.getInputFluidInventory(); + FluidStack boosterStack = isExtreme ? LIQUID_OXYGEN_STACK : OXYGEN_STACK; + isOxygenBoosted = boosterStack.isFluidStackIdentical(inputTank.drain(boosterStack, false)); + } + } + + protected void drainOxygen() { + if (isOxygenBoosted && totalContinuousRunningTime % 20 == 0) { + FluidStack boosterStack = isExtreme ? LIQUID_OXYGEN_STACK : OXYGEN_STACK; + combustionEngine.getInputFluidInventory().drain(boosterStack, true); + } + } + + protected boolean checkLubricant() { + // check lubricant and invalidate if it fails + IMultipleTankHandler inputTank = combustionEngine.getInputFluidInventory(); + if (LUBRICANT_STACK.isFluidStackIdentical(inputTank.drain(LUBRICANT_STACK, false))) { + return true; + } else { + invalidate(); + return false; + } + } + + protected void drainLubricant() { + if (totalContinuousRunningTime == 1 || totalContinuousRunningTime % 72 == 0) { + IMultipleTankHandler inputTank = combustionEngine.getInputFluidInventory(); + inputTank.drain(LUBRICANT_STACK, true); + } + } + @Override protected boolean shouldSearchForRecipes() { - return super.shouldSearchForRecipes() && - LUBRICANT_STACK.isFluidStackIdentical(((RecipeMapMultiblockController) metaTileEntity) - .getInputFluidInventory().drain(LUBRICANT_STACK, false)); + checkOxygen(); + return super.shouldSearchForRecipes() && checkLubricant(); + } + + @Override + protected boolean canProgressRecipe() { + return super.canProgressRecipe() && checkLubricant(); } @Override @@ -388,33 +427,5 @@ public void invalidate() { isOxygenBoosted = false; super.invalidate(); } - - @Override - protected boolean canProgressRecipe() { - // drain lubricant and invalidate if it fails - if (totalContinuousRunningTime == 1 || totalContinuousRunningTime % 72 == 0) { - IMultipleTankHandler inputTank = combustionEngine.getInputFluidInventory(); - if (LUBRICANT_STACK.isFluidStackIdentical(inputTank.drain(LUBRICANT_STACK, false))) { - inputTank.drain(LUBRICANT_STACK, true); - } else { - invalidate(); - return false; - } - } - - // drain oxygen if present to boost production, and if the dynamo hatch supports it - if (combustionEngine.isBoostAllowed() && - (totalContinuousRunningTime == 1 || totalContinuousRunningTime % 20 == 0)) { - IMultipleTankHandler inputTank = combustionEngine.getInputFluidInventory(); - FluidStack boosterStack = isExtreme ? LIQUID_OXYGEN_STACK : OXYGEN_STACK; - if (boosterStack.isFluidStackIdentical(inputTank.drain(boosterStack, false))) { - isOxygenBoosted = true; - inputTank.drain(boosterStack, true); - } else { - isOxygenBoosted = false; - } - } - return super.canProgressRecipe(); - } } }