Skip to content

Commit

Permalink
Refactor Sparge Tower (#3693)
Browse files Browse the repository at this point in the history
Co-authored-by: Martin Robertz <dream-master@gmx.net>
Co-authored-by: Maya <10861407+serenibyss@users.noreply.github.com>
  • Loading branch information
3 people authored Dec 23, 2024
1 parent 3858cce commit 968e58c
Show file tree
Hide file tree
Showing 10 changed files with 154 additions and 783 deletions.
6 changes: 6 additions & 0 deletions src/main/java/gregtech/api/util/GTRecipeConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,12 @@ public class GTRecipeConstants {
public static final RecipeMetadataKey<Integer> LFTR_OUTPUT_POWER = SimpleRecipeMetadataKey
.create(Integer.class, "lftr_output_power");

/**
* Sparge Tower maximum byproduct outputs.
*/
public static final RecipeMetadataKey<Integer> SPARGE_MAX_BYPRODUCT = SimpleRecipeMetadataKey
.create(Integer.class, "sparge_max_byproduct");

/**
* Research Station data.
*/
Expand Down
90 changes: 0 additions & 90 deletions src/main/java/gregtech/api/util/GasSpargingRecipe.java

This file was deleted.

44 changes: 0 additions & 44 deletions src/main/java/gregtech/api/util/GasSpargingRecipeMap.java

This file was deleted.

7 changes: 4 additions & 3 deletions src/main/java/gtPlusPlus/api/recipe/GTPPRecipeMaps.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,11 @@ public class GTPPRecipeMaps {
(index, isFluid, isOutput, isSpecial) -> !isFluid && !isOutput ? GTUITextures.OVERLAY_SLOT_CAULDRON : null)
.progressBar(GTUITextures.PROGRESSBAR_ARROW_MULTIPLE)
.build();
public static final RecipeMap<RecipeMapBackend> spargeTowerFakeRecipes = RecipeMapBuilder
.of("gtpp.recipe.spargetower")
public static final RecipeMap<RecipeMapBackend> spargeTowerRecipes = RecipeMapBuilder
.of("gtpp.recipe.lftr.sparging")
.frontend(SpargeTowerFrontend::new)
.disableOptimize()
.maxIO(0, 0, 9, 9)
.disableRegisterNEI()
.build();
public static final RecipeMap<RecipeMapBackend> advancedFreezerRecipes = RecipeMapBuilder
.of("gtpp.recipe.cryogenicfreezer")
Expand Down
66 changes: 66 additions & 0 deletions src/main/java/gtPlusPlus/api/recipe/SpargeTowerFrontend.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package gtPlusPlus.api.recipe;

import static gregtech.api.util.GTRecipeConstants.SPARGE_MAX_BYPRODUCT;

import java.util.List;

import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;

import codechicken.nei.PositionedStack;
import gregtech.api.recipe.BasicUIPropertiesBuilder;
import gregtech.api.recipe.NEIRecipePropertiesBuilder;
import gregtech.api.recipe.maps.FluidOnlyFrontend;
import gregtech.api.util.GTRecipe;
import gregtech.api.util.GTUtility;
import gregtech.nei.GTNEIDefaultHandler;

public class SpargeTowerFrontend extends FluidOnlyFrontend {

public SpargeTowerFrontend(BasicUIPropertiesBuilder uiPropertiesBuilder,
NEIRecipePropertiesBuilder neiPropertiesBuilder) {
super(uiPropertiesBuilder, neiPropertiesBuilder);
}

protected List<String> handleNEIByproductTooltip(ItemStack stack, List<String> currentTip, GTRecipe recipe) {
int maximumByproducts = recipe.getMetadataOrDefault(SPARGE_MAX_BYPRODUCT, 0);
FluidStack spargeGas = recipe.mFluidInputs[0];
if (stack.isItemEqual(GTUtility.getFluidDisplayStack(spargeGas.getFluid()))) {
currentTip.add("The amount returned is the remainder after all other outputs.");
currentTip.add("Maximum Output: " + spargeGas.amount + "L");
return currentTip;
}
for (int i = 2; i < recipe.mFluidOutputs.length; i++) {
if (stack.isItemEqual(GTUtility.getFluidDisplayStack(recipe.mFluidOutputs[i].getFluid()))) {
currentTip.add("Maximum Output: " + maximumByproducts + "L");
}
}
return currentTip;
}

@Override
public List<String> handleNEIItemTooltip(ItemStack stack, List<String> currentTip,
GTNEIDefaultHandler.CachedDefaultRecipe neiCachedRecipe) {
GTRecipe recipe = neiCachedRecipe.mRecipe;
for (PositionedStack pStack : neiCachedRecipe.mInputs) {
if (stack == pStack.item) {
if (pStack instanceof GTNEIDefaultHandler.FixedPositionedStack) {
currentTip = handleNEIItemInputTooltip(
currentTip,
(GTNEIDefaultHandler.FixedPositionedStack) pStack);
}
break;
}
}
for (PositionedStack pStack : neiCachedRecipe.mOutputs) {
if (stack == pStack.item) {
if (pStack instanceof GTNEIDefaultHandler.FixedPositionedStack) {
currentTip = handleNEIByproductTooltip(stack, currentTip, recipe);
}
break;
}
}
return currentTip;
}

}
Loading

0 comments on commit 968e58c

Please sign in to comment.