Jei tooltips (#33)

* JEI now shows how much of each type of resource is used in the machines
This commit is contained in:
Richard Freimer authored and Dave Smith committed 2019-03-14 12:35:33 -06:00
1 parent 6ad9a4d23c
commit 8c79baccf6
19 files changed
+52 -33

No files matched your search

@@ -150,7 +150,6 @@ public abstract class BaseRecipeCategory implements IRecipeCategory<IRecipeWrapp
overlay ? fluidOverlay : null);
group.init(slot, input, renderer, x, y, width, height, 0, 0);
group.set(slot, stack);
group.addTooltipCallback((index, isInput, ingredient, tooltip) -> tooltip.remove(1));
}
public static class GuiDummy extends Gui {
@@ -1,6 +1,5 @@
package mekanism.client.jei.machine;
import javax.annotation.Nullable;
import mekanism.api.gas.GasStack;
import mekanism.client.gui.element.GuiPowerBar;
import mekanism.client.gui.element.GuiPowerBar.IPowerInfoHandler;
@@ -14,6 +13,7 @@ import mekanism.client.jei.BaseRecipeCategory;
import mekanism.common.recipe.inputs.AdvancedMachineInput;
import mekanism.common.recipe.machines.AdvancedMachineRecipe;
import mekanism.common.recipe.outputs.ItemStackOutput;
import mekanism.common.tile.prefab.TileEntityAdvancedElectricMachine;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import mezz.jei.api.IGuiHelper;
@@ -29,9 +29,6 @@ public class AdvancedMachineRecipeCategory extends BaseRecipeCategory {
private final IDrawable background;
@Nullable
private AdvancedMachineRecipe tempRecipe;
public AdvancedMachineRecipeCategory(IGuiHelper helper, String name, String unlocalized, ProgressBar progress) {
super(helper, "mekanism:gui/GuiAdvancedMachine.png", name, unlocalized, progress);
@@ -78,7 +75,7 @@ public class AdvancedMachineRecipeCategory extends BaseRecipeCategory {
return;
}
tempRecipe = ((AdvancedMachineRecipeWrapper) recipeWrapper).getRecipe();
AdvancedMachineRecipe tempRecipe = ((AdvancedMachineRecipeWrapper) recipeWrapper).getRecipe();
AdvancedMachineInput input = (AdvancedMachineInput) tempRecipe.recipeInput;
@@ -94,6 +91,8 @@ public class AdvancedMachineRecipeCategory extends BaseRecipeCategory {
IGuiIngredientGroup<GasStack> gasStacks = recipeLayout.getIngredientsGroup(GasStack.class);
initGas(gasStacks, 0, true, 33, 21, 6, 12, new GasStack(input.gasType, 1), false);
initGas(gasStacks, 0, true, 33, 21, 6, 12,
new GasStack(input.gasType, TileEntityAdvancedElectricMachine.BASE_TICKS_REQUIRED
* TileEntityAdvancedElectricMachine.BASE_GAS_PER_TICK), false);
}
}
@@ -6,6 +6,7 @@ import mekanism.api.gas.GasStack;
import mekanism.common.recipe.inputs.AdvancedMachineInput;
import mekanism.common.recipe.machines.AdvancedMachineRecipe;
import mekanism.common.recipe.outputs.ItemStackOutput;
import mekanism.common.tile.prefab.TileEntityAdvancedElectricMachine;
import mekanism.common.util.GasUtils;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.IRecipeWrapper;
@@ -22,7 +23,9 @@ public class AdvancedMachineRecipeWrapper implements IRecipeWrapper {
@Override
public void getIngredients(IIngredients ingredients) {
ingredients.setInput(ItemStack.class, ((AdvancedMachineInput) recipe.getInput()).itemStack);
ingredients.setInput(GasStack.class, new GasStack(((AdvancedMachineInput) recipe.getInput()).gasType, 1));
ingredients.setInput(GasStack.class, new GasStack(((AdvancedMachineInput) recipe.getInput()).gasType,
TileEntityAdvancedElectricMachine.BASE_TICKS_REQUIRED
* TileEntityAdvancedElectricMachine.BASE_GAS_PER_TICK));
ingredients.setOutput(ItemStack.class, ((ItemStackOutput) recipe.getOutput()).output);
}
@@ -5,6 +5,7 @@ import mekanism.api.gas.GasStack;
import mekanism.client.jei.BaseRecipeCategory;
import mekanism.common.MekanismFluids;
import mekanism.common.recipe.machines.DissolutionRecipe;
import mekanism.common.tile.TileEntityChemicalDissolutionChamber;
import mezz.jei.api.IGuiHelper;
import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.gui.IGuiIngredientGroup;
@@ -60,7 +61,9 @@ public class ChemicalDissolutionChamberRecipeCategory extends BaseRecipeCategory
IGuiIngredientGroup<GasStack> gasStacks = recipeLayout.getIngredientsGroup(GasStack.class);
initGas(gasStacks, 0, true, 6 - xOffset, 5 - yOffset, 16, 58, new GasStack(MekanismFluids.SulfuricAcid, 1),
initGas(gasStacks, 0, true, 6 - xOffset, 5 - yOffset, 16, 58,
new GasStack(MekanismFluids.SulfuricAcid, TileEntityChemicalDissolutionChamber.BASE_INJECT_USAGE
* TileEntityChemicalDissolutionChamber.BASE_TICKS_REQUIRED),
true);
initGas(gasStacks, 1, false, 134 - xOffset, 14 - yOffset, 16, 58, tempRecipe.getOutput().output, true);
}
@@ -3,6 +3,7 @@ package mekanism.client.jei.machine.chemical;
import mekanism.api.gas.GasStack;
import mekanism.common.MekanismFluids;
import mekanism.common.recipe.machines.DissolutionRecipe;
import mekanism.common.tile.TileEntityChemicalDissolutionChamber;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.item.ItemStack;
@@ -17,7 +18,9 @@ public class ChemicalDissolutionChamberRecipeWrapper implements IRecipeWrapper {
@Override
public void getIngredients(IIngredients ingredients) {
ingredients.setInput(GasStack.class, new GasStack(MekanismFluids.SulfuricAcid, 1000));
ingredients.setInput(GasStack.class, new GasStack(MekanismFluids.SulfuricAcid,
TileEntityChemicalDissolutionChamber.BASE_INJECT_USAGE
* TileEntityChemicalDissolutionChamber.BASE_TICKS_REQUIRED));
ingredients.setInput(ItemStack.class, recipe.recipeInput.ingredient);
ingredients.setOutput(GasStack.class, recipe.recipeOutput.output);
}
@@ -4,6 +4,7 @@ import javax.annotation.Nullable;
import mekanism.api.gas.GasStack;
import mekanism.client.jei.BaseRecipeCategory;
import mekanism.common.recipe.machines.WasherRecipe;
import mekanism.common.tile.TileEntityChemicalWasher;
import mezz.jei.api.IGuiHelper;
import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.gui.IGuiFluidStackGroup;
@@ -54,9 +55,9 @@ public class ChemicalWasherRecipeCategory extends BaseRecipeCategory {
IGuiFluidStackGroup fluidStacks = recipeLayout.getFluidStacks();
fluidStacks.init(0, true, 6 - xOffset, 5 - yOffset, 16, 58, 1000, false, fluidOverlayLarge);
fluidStacks.init(0, true, 6 - xOffset, 5 - yOffset, 16, 58, TileEntityChemicalWasher.WATER_USAGE, false,
fluidOverlayLarge);
fluidStacks.set(0, ingredients.getInputs(FluidStack.class).get(0));
fluidStacks.addTooltipCallback((index, input, ingredient, tooltip) -> tooltip.remove(1));
IGuiIngredientGroup<GasStack> gasStacks = recipeLayout.getIngredientsGroup(GasStack.class);
@@ -2,6 +2,7 @@ package mekanism.client.jei.machine.chemical;
import mekanism.api.gas.GasStack;
import mekanism.common.recipe.machines.WasherRecipe;
import mekanism.common.tile.TileEntityChemicalWasher;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraftforge.fluids.FluidRegistry;
@@ -17,7 +18,7 @@ public class ChemicalWasherRecipeWrapper implements IRecipeWrapper {
@Override
public void getIngredients(IIngredients ingredients) {
ingredients.setInput(FluidStack.class, new FluidStack(FluidRegistry.WATER, 1000));
ingredients.setInput(FluidStack.class, new FluidStack(FluidRegistry.WATER, TileEntityChemicalWasher.WATER_USAGE));
ingredients.setInput(GasStack.class, recipe.recipeInput.ingredient);
ingredients.setOutput(GasStack.class, recipe.recipeOutput.output);
}
@@ -94,7 +94,6 @@ public class ElectrolyticSeparatorRecipeCategory extends BaseRecipeCategory {
fluidStacks.init(0, true, 2, 2, 16, 58, tempRecipe.getInput().ingredient.amount, false, fluidOverlayLarge);
fluidStacks.set(0, ingredients.getInputs(FluidStack.class).get(0));
fluidStacks.addTooltipCallback((index, input, ingredient, tooltip) -> tooltip.remove(1));
IGuiIngredientGroup<GasStack> gasStacks = recipeLayout.getIngredientsGroup(GasStack.class);
@@ -4,6 +4,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import mekanism.client.render.MekanismRenderer;
import mekanism.common.InfuseStorage;
import mekanism.common.recipe.machines.MetallurgicInfuserRecipe;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.IRecipeWrapper;
@@ -39,4 +40,13 @@ public class MetallurgicInfuserRecipeWrapper implements IRecipeWrapper {
mc.currentScreen.drawTexturedModalRect(2, 2, recipe.getInput().infuse.type.sprite, 4, 52);
}
}
}
@Override
public List<String> getTooltipStrings(int mouseX, int mouseY) {
if (mouseX >= 2 && mouseX < 6 && mouseY >= 2 && mouseY < 54) {
InfuseStorage infuse = recipe.getInput().infuse;
return Collections.singletonList(infuse.type.getLocalizedName() + ": " + infuse.amount);
}
return Collections.emptyList();
}
}
@@ -91,7 +91,6 @@ public class PRCRecipeCategory extends BaseRecipeCategory {
fluidStacks.init(0, true, 3, 0, 16, 58, tempRecipe.getInput().getFluid().amount, false, fluidOverlayLarge);
fluidStacks.set(0, tempRecipe.recipeInput.getFluid());
fluidStacks.addTooltipCallback((index, input, ingredient, tooltip) -> tooltip.remove(1));
IGuiIngredientGroup<GasStack> gasStacks = recipeLayout.getIngredientsGroup(GasStack.class);
@@ -69,14 +69,14 @@ public class RotaryCondensentratorRecipeCategory extends BaseRecipeCategory {
IGuiFluidStackGroup fluidStacks = recipeLayout.getFluidStacks();
IGuiIngredientGroup<GasStack> gasStacks = recipeLayout.getIngredientsGroup(GasStack.class);
fluidStacks.init(0, !tempRecipe.condensentrating, 134 - xOffset, 14 - yOffset, 16, 58, 1000, false,
fluidStacks.init(0, !tempRecipe.condensentrating, 134 - xOffset, 14 - yOffset, 16, 58, tempRecipe.fluidAmount, false,
fluidOverlayLarge);
if (tempRecipe.condensentrating) {
initGas(gasStacks, 0, true, 26 - xOffset, 14 - yOffset, 16, 58, new GasStack(tempRecipe.gasType, 1), true);
initGas(gasStacks, 0, true, 26 - xOffset, 14 - yOffset, 16, 58, new GasStack(tempRecipe.gasType, tempRecipe.gasAmount), true);
fluidStacks.set(0, ingredients.getOutputs(FluidStack.class).get(0));
} else {
initGas(gasStacks, 0, false, 26 - xOffset, 14 - yOffset, 16, 58, new GasStack(tempRecipe.gasType, 1), true);
initGas(gasStacks, 0, false, 26 - xOffset, 14 - yOffset, 16, 58, new GasStack(tempRecipe.gasType, tempRecipe.gasAmount), true);
fluidStacks.set(0, ingredients.getInputs(FluidStack.class).get(0));
}
}
@@ -14,6 +14,8 @@ public class RotaryCondensentratorRecipeWrapper implements IRecipeWrapper {
public Fluid fluidType;
public Gas gasType;
public int gasAmount = 1;
public int fluidAmount = 1;
public boolean condensentrating;
@@ -27,11 +29,11 @@ public class RotaryCondensentratorRecipeWrapper implements IRecipeWrapper {
@Override
public void getIngredients(IIngredients ingredients) {
if (condensentrating) {
ingredients.setInput(GasStack.class, new GasStack(gasType, 1000));
ingredients.setOutput(FluidStack.class, new FluidStack(fluidType, 1000));
ingredients.setInput(GasStack.class, new GasStack(gasType, gasAmount));
ingredients.setOutput(FluidStack.class, new FluidStack(fluidType, fluidAmount));
} else {
ingredients.setInput(FluidStack.class, new FluidStack(fluidType, 1000));
ingredients.setOutput(GasStack.class, new GasStack(gasType, 1000));
ingredients.setInput(FluidStack.class, new FluidStack(fluidType, fluidAmount));
ingredients.setOutput(GasStack.class, new GasStack(gasType, gasAmount));
}
}
@@ -58,6 +58,5 @@ public class ThermalEvaporationRecipeCategory extends BaseRecipeCategory {
fluidStacks.set(0, tempRecipe.recipeInput.ingredient);
fluidStacks.set(1, tempRecipe.recipeOutput.output);
fluidStacks.addTooltipCallback((index, input, ingredient, tooltip) -> tooltip.remove(1));
}
}
@@ -18,7 +18,6 @@ import mekanism.common.block.states.BlockStateMachine;
import mekanism.common.capabilities.Capabilities;
import mekanism.common.config.MekanismConfig.usage;
import mekanism.common.recipe.RecipeHandler;
import mekanism.common.recipe.RecipeHandler.Recipe;
import mekanism.common.recipe.inputs.ItemStackInput;
import mekanism.common.recipe.machines.DissolutionRecipe;
import mekanism.common.tile.component.TileComponentUpgrade;
@@ -42,15 +41,15 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityMachine impl
public static final int MAX_GAS = 10000;
public static final int BASE_INJECT_USAGE = 1;
public static final int BASE_TICKS_REQUIRED = 100;
public final double BASE_ENERGY_USAGE = usage.chemicalDissolutionChamberUsage;
public GasTank injectTank = new GasTank(MAX_GAS);
public GasTank outputTank = new GasTank(MAX_GAS);
public double injectUsage = 1;
public double injectUsage = BASE_INJECT_USAGE;
public int injectUsageThisTick;
public int gasOutput = 256;
public int operatingTicks = 0;
public int BASE_TICKS_REQUIRED = 100;
public int ticksRequired = 100;
public int ticksRequired = BASE_TICKS_REQUIRED;
public DissolutionRecipe cachedRecipe;
public TileEntityChemicalDissolutionChamber() {
@@ -59,6 +58,7 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityMachine impl
usage.chemicalDissolutionChamberUsage, 4);
inventory = NonNullList.withSize(5, ItemStack.EMPTY);
upgradeComponent.setSupported(Upgrade.GAS);
}
@Override
@@ -86,7 +86,7 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityMachine impl
DissolutionRecipe recipe = getRecipe();
injectUsageThisTick = Math.max(1, StatUtils.inversePoisson(injectUsage));
injectUsageThisTick = Math.max(BASE_INJECT_USAGE, StatUtils.inversePoisson(injectUsage));
if (canOperate(recipe) && getEnergy() >= energyPerTick && injectTank.getStored() >= injectUsageThisTick
&& MekanismUtils.canFunction(this)) {
@@ -22,7 +22,7 @@ public class TileEntityChemicalInjectionChamber extends TileEntityAdvancedElectr
public TileEntityChemicalInjectionChamber() {
super("injection", "ChemicalInjectionChamber",
BlockStateMachine.MachineType.CHEMICAL_INJECTION_CHAMBER.baseEnergy, usage.chemicalInjectionChamberUsage,
200, 1);
BASE_TICKS_REQUIRED, BASE_GAS_PER_TICK);
configComponent.addSupported(TransmissionType.GAS);
configComponent.addOutput(TransmissionType.GAS, new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY));
@@ -65,7 +65,6 @@ public class TileEntityChemicalWasher extends TileEntityMachine implements IGasH
public TileEntityChemicalWasher() {
super("machine.washer", "ChemicalWasher", BlockStateMachine.MachineType.CHEMICAL_WASHER.baseEnergy,
usage.chemicalWasherUsage, 4);
inventory = NonNullList.withSize(5, ItemStack.EMPTY);
}
@@ -15,7 +15,7 @@ public class TileEntityOsmiumCompressor extends TileEntityAdvancedElectricMachin
public TileEntityOsmiumCompressor() {
super("compressor", "OsmiumCompressor", BlockStateMachine.MachineType.OSMIUM_COMPRESSOR.baseEnergy,
usage.osmiumCompressorUsage, 200, 1);
usage.osmiumCompressorUsage, BASE_TICKS_REQUIRED, BASE_GAS_PER_TICK);
}
@Override
@@ -18,7 +18,7 @@ public class TileEntityPurificationChamber extends TileEntityAdvancedElectricMac
public TileEntityPurificationChamber() {
super("purification", "PurificationChamber", BlockStateMachine.MachineType.PURIFICATION_CHAMBER.baseEnergy,
usage.purificationChamberUsage, 200, 1);
usage.purificationChamberUsage, BASE_TICKS_REQUIRED, BASE_GAS_PER_TICK);
}
@Override
@@ -43,6 +43,8 @@ public abstract class TileEntityAdvancedElectricMachine<RECIPE extends AdvancedM
private static final String[] methods = new String[]{"getEnergy", "getSecondaryStored", "getProgress", "isActive",
"facing", "canOperate", "getMaxEnergy", "getEnergyNeeded"};
public static final int BASE_TICKS_REQUIRED = 200;
public static final int BASE_GAS_PER_TICK = 1;
public static int MAX_GAS = 210;
/**
* How much secondary energy (fuel) this machine uses per tick, not including upgrades.