Skip to content

Commit

Permalink
Rework Generators 2.0 ™️ (#2255)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghzdude authored Dec 7, 2023
1 parent 09a4e64 commit 3f8d6f1
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,9 @@ public int getParallelLimit() {
// parallel is limited by voltage
return Integer.MAX_VALUE;
}

@Override
public boolean isAllowOverclocking() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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();
}
}
}

0 comments on commit 3f8d6f1

Please sign in to comment.