Skip to content

Commit

Permalink
Add a tooltip callback to the mix recipe to state fluid amounts are p…
Browse files Browse the repository at this point in the history
…er second
  • Loading branch information
KnightMiner committed Jun 16, 2019
1 parent c92c3e0 commit 29bc777
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package knightminer.tcomplement.plugin.jei.highoven.heat;

import javax.annotation.Nonnull;

import knightminer.tcomplement.TinkersComplement;
import knightminer.tcomplement.library.Util;
import mezz.jei.api.IGuiHelper;
Expand All @@ -12,6 +10,10 @@
import mezz.jei.api.recipe.IRecipeCategory;
import net.minecraft.client.Minecraft;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.FluidStack;

import javax.annotation.Nonnull;
import java.util.List;

public class HighOvenHeatCategory implements IRecipeCategory<HighOvenHeatWrapper> {

Expand Down Expand Up @@ -51,6 +53,7 @@ public void drawExtras(@Nonnull Minecraft minecraft) {
@Override
public void setRecipe(IRecipeLayout recipeLayout, HighOvenHeatWrapper recipe, IIngredients ingredients) {
IGuiFluidStackGroup fluids = recipeLayout.getFluidStacks();
fluids.addTooltipCallback(HighOvenHeatCategory::onFluidTooltip);

// fluids
fluids.init(0, true, 20, 22, 18, 18, 1, false, null);
Expand All @@ -62,4 +65,15 @@ public void setRecipe(IRecipeLayout recipeLayout, HighOvenHeatWrapper recipe, II
public String getModName() {
return TinkersComplement.modName;
}


public static void onFluidTooltip(int slotIndex, boolean input, FluidStack fluid, List<String> text) {
// replace the tooltip with one showing fluid size as a rate
String ingredientName = text.get(0);
String modName = text.get(text.size() - 1);
text.clear();
text.add(ingredientName);
text.add(Util.translateFormatted("gui.jei.high_oven.heat.rate", fluid.amount));
text.add(modName);
}
}
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
package knightminer.tcomplement.plugin.jei.highoven.heat;

import javax.annotation.Nonnull;

import knightminer.tcomplement.library.Util;
import knightminer.tcomplement.library.steelworks.HeatRecipe;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.client.Minecraft;
import net.minecraftforge.fluids.FluidStack;

import javax.annotation.Nonnull;

public class HighOvenHeatWrapper implements IRecipeWrapper {

private FluidStack inputFluid;
private FluidStack outputFluid;
private int temp;
public HighOvenHeatWrapper(HeatRecipe recipe) {
// fluids
// fluids, multiply by 40 to make per second
this.inputFluid = recipe.getInput();
this.inputFluid = new FluidStack(this.inputFluid, this.inputFluid.amount * 40);
this.outputFluid = recipe.getOutput();
this.outputFluid = new FluidStack(this.outputFluid, this.outputFluid.amount * 40);
this.temp = recipe.getTemperature();
}

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/tcomplement/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ gui.jei.high_oven.mix.title=High Oven Mixing
gui.jei.high_oven.mix.consume=%s%% chance to consume
gui.jei.high_oven.mix.represenative=Accepts: melts into %s
gui.jei.high_oven.heat.title=High Oven Heat
gui.jei.high_oven.heat.rate=%s mb/s
gui.jei.high_oven.fuel.title=High Oven Fuel
gui.jei.high_oven.fuel.rate=+%s°c/s
gui.jei.high_oven.fuel.time=Burn time: %ss
Expand Down

0 comments on commit 29bc777

Please sign in to comment.