Skip to content

Commit

Permalink
Mass JEI deprecation cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
thiakil committed Mar 12, 2019
1 parent b2f8a3a commit 3d99b60
Show file tree
Hide file tree
Showing 31 changed files with 125 additions and 74 deletions.
14 changes: 13 additions & 1 deletion src/main/java/mekanism/client/jei/BaseRecipeCategory.java
Expand Up @@ -160,6 +160,18 @@ protected void initGas(IGuiIngredientGroup<GasStack> group, int slot, boolean in
GasStackRenderer renderer = new GasStackRenderer(stack.amount, false, width, height, 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));
//group.addTooltipCallback((index, isInput, ingredient, tooltip) -> tooltip.remove(1));
}

protected void initGasPerTick(IGuiIngredientGroup<GasStack> group, int slot, boolean input, int x, int y, int width, int height, @Nullable GasStack stack, boolean overlay)
{
if(stack == null) return;

IDrawable fluidOverlay = height > 50 ? fluidOverlayLarge : fluidOverlaySmall;

GasStackRenderer renderer = new GasStackRenderer(stack.amount, GasStackRenderer.TooltipMode.AMOUNT_PER_TICK, width, height, 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));
}
}
7 changes: 0 additions & 7 deletions src/main/java/mekanism/client/jei/GasStackHelper.java
Expand Up @@ -70,13 +70,6 @@ public String getResourceId(GasStack ingredient)
return ingredient.getGas().getUnlocalizedName();
}

@Deprecated
@Override
public ItemStack cheatIngredient(GasStack ingredient, boolean fullStack)
{
return ItemStack.EMPTY;
}

@Override
public GasStack copyIngredient(GasStack ingredient) {
return ingredient.copy();
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/mekanism/client/jei/MekanismJEI.java
Expand Up @@ -113,6 +113,7 @@
import mezz.jei.api.ISubtypeRegistry.ISubtypeInterpreter;
import mezz.jei.api.JEIPlugin;
import mezz.jei.api.ingredients.IModIngredientRegistration;
import mezz.jei.api.recipe.IIngredientType;
import mezz.jei.api.recipe.IRecipeCategoryRegistration;
import mezz.jei.api.recipe.IRecipeWrapper;
import mezz.jei.api.recipe.VanillaRecipeCategoryUid;
Expand All @@ -126,6 +127,7 @@
public class MekanismJEI implements IModPlugin
{
private static final GasStackRenderer GAS_RENDERER = new GasStackRenderer();
public static final IIngredientType<GasStack> GAS_INGREDIENT_TYPE = ()->GasStack.class;

private static final boolean CRAFTTWEAKER_LOADED = Loader.isModLoaded("crafttweaker");

Expand Down Expand Up @@ -157,7 +159,7 @@ public class MekanismJEI implements IModPlugin
ret += ":" + (((ItemBlockEnergyCube)itemStack.getItem()).getEnergy(itemStack) > 0 ? "filled" : "empty");
}

return ret.isEmpty() ? null : ret.toLowerCase(Locale.ROOT);
return ret.isEmpty() ? ISubtypeInterpreter.NONE : ret.toLowerCase(Locale.ROOT);
};

@Override
Expand All @@ -178,7 +180,7 @@ public void registerItemSubtypes(ISubtypeRegistry registry)
public void registerIngredients(IModIngredientRegistration registry)
{
List<GasStack> list = GasRegistry.getRegisteredGasses().stream().filter(Gas::isVisible).map(g -> new GasStack(g, Fluid.BUCKET_VOLUME)).collect(Collectors.toList());
registry.register(GasStack.class, list, new GasStackHelper(), GAS_RENDERER);
registry.register(GAS_INGREDIENT_TYPE, list, new GasStackHelper(), GAS_RENDERER);
}

@Override
Expand Down Expand Up @@ -302,7 +304,7 @@ public void register(IModRegistry registry)
else if (CRAFTTWEAKER_LOADED && EnergizedSmelter.hasAddedRecipe()) // Added but not removed
{
// Only add added recipes
HashMap<ItemStackInput, SmeltingRecipe> smeltingRecipes = Recipe.ENERGIZED_SMELTER.get();
@SuppressWarnings("unchecked") HashMap<ItemStackInput, SmeltingRecipe> smeltingRecipes = Recipe.ENERGIZED_SMELTER.get();
Collection<SmeltingRecipe> recipes = smeltingRecipes.entrySet().stream()
.filter(entry -> !FurnaceRecipes.instance().getSmeltingList().keySet().contains(entry.getKey().ingredient))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)).values();
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/mekanism/client/jei/gas/GasStackRenderer.java
Expand Up @@ -35,11 +35,11 @@ public class GasStackRenderer implements IIngredientRenderer<GasStack>
@Nullable
private final IDrawable overlay;

enum TooltipMode
public enum TooltipMode
{
SHOW_AMOUNT,
SHOW_AMOUNT_AND_CAPACITY,
ITEM_LIST
ITEM_LIST, AMOUNT_PER_TICK
}

public GasStackRenderer()
Expand Down Expand Up @@ -219,6 +219,11 @@ else if (tooltipMode == TooltipMode.SHOW_AMOUNT)
String amount = LangUtils.localizeWithFormat("jei.tooltip.liquid.amount", gasStack.amount);
tooltip.add(TextFormatting.GRAY + amount);
}
else if (tooltipMode == TooltipMode.AMOUNT_PER_TICK)
{
String amount = LangUtils.localizeWithFormat("mekanism.jei.amount.per.tick", LangUtils.localizeWithFormat("jei.tooltip.liquid.amount", gasStack.amount));
tooltip.add(TextFormatting.GRAY + amount);
}

return tooltip;
}
Expand Down
Expand Up @@ -10,6 +10,7 @@
import mekanism.client.gui.element.GuiSlot.SlotOverlay;
import mekanism.client.gui.element.GuiSlot.SlotType;
import mekanism.client.jei.BaseRecipeCategory;
import mekanism.client.jei.MekanismJEI;
import mekanism.common.recipe.inputs.AdvancedMachineInput;
import mekanism.common.recipe.machines.AdvancedMachineRecipe;
import mekanism.common.recipe.outputs.ItemStackOutput;
Expand Down Expand Up @@ -93,7 +94,7 @@ public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper,
itemStacks.set(1, ((ItemStackOutput)tempRecipe.recipeOutput).output);
itemStacks.set(2, ((AdvancedMachineRecipeWrapper)recipeWrapper).getFuelStacks(input.gasType));

IGuiIngredientGroup<GasStack> gasStacks = recipeLayout.getIngredientsGroup(GasStack.class);
IGuiIngredientGroup<GasStack> gasStacks = recipeLayout.getIngredientsGroup(MekanismJEI.GAS_INGREDIENT_TYPE);

initGas(gasStacks, 0, true, 33, 21, 6, 12, new GasStack(input.gasType, 1), false);
}
Expand Down
Expand Up @@ -4,10 +4,12 @@

import mekanism.api.gas.Gas;
import mekanism.api.gas.GasStack;
import mekanism.client.jei.MekanismJEI;
import mekanism.common.recipe.inputs.AdvancedMachineInput;
import mekanism.common.recipe.machines.AdvancedMachineRecipe;
import mekanism.common.recipe.outputs.ItemStackOutput;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.ingredients.VanillaTypes;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.item.ItemStack;

Expand All @@ -23,9 +25,9 @@ public AdvancedMachineRecipeWrapper(AdvancedMachineRecipe r)
@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.setOutput(ItemStack.class, ((ItemStackOutput)recipe.getOutput()).output);
ingredients.setInput(VanillaTypes.ITEM, ((AdvancedMachineInput)recipe.getInput()).itemStack);
ingredients.setInput(MekanismJEI.GAS_INGREDIENT_TYPE, new GasStack(((AdvancedMachineInput)recipe.getInput()).gasType, 1));
ingredients.setOutput(VanillaTypes.ITEM, ((ItemStackOutput)recipe.getOutput()).output);
}

public abstract List<ItemStack> getFuelStacks(Gas gasType);
Expand Down
Expand Up @@ -4,6 +4,7 @@
import mekanism.common.recipe.machines.ChanceMachineRecipe;
import mekanism.common.recipe.outputs.ChanceOutput;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.ingredients.VanillaTypes;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
Expand All @@ -25,8 +26,8 @@ public ChanceMachineRecipeWrapper(ChanceMachineRecipe r)
public void getIngredients(IIngredients ingredients)
{
ChanceOutput output = (ChanceOutput)recipe.getOutput();
ingredients.setInput(ItemStack.class, ((ItemStackInput)recipe.getInput()).ingredient);
ingredients.setOutputs(ItemStack.class, Arrays.asList(output.primaryOutput, output.secondaryOutput));
ingredients.setInput(VanillaTypes.ITEM, ((ItemStackInput)recipe.getInput()).ingredient);
ingredients.setOutputs(VanillaTypes.ITEM, Arrays.asList(output.primaryOutput, output.secondaryOutput));
}

@Override
Expand Down
Expand Up @@ -6,6 +6,7 @@
import mekanism.common.recipe.machines.DoubleMachineRecipe;
import mekanism.common.recipe.outputs.ItemStackOutput;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.ingredients.VanillaTypes;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.item.ItemStack;

Expand All @@ -22,8 +23,8 @@ public DoubleMachineRecipeWrapper(DoubleMachineRecipe r)
public void getIngredients(IIngredients ingredients)
{
DoubleMachineInput input = (DoubleMachineInput)recipe.getInput();
ingredients.setInputs(ItemStack.class, Arrays.asList(input.itemStack, input.extraStack));
ingredients.setOutput(ItemStack.class, ((ItemStackOutput)recipe.getOutput()).output);
ingredients.setInputs(VanillaTypes.ITEM, Arrays.asList(input.itemStack, input.extraStack));
ingredients.setOutput(VanillaTypes.ITEM, ((ItemStackOutput)recipe.getOutput()).output);
}

public DoubleMachineRecipe getRecipe()
Expand Down
Expand Up @@ -4,6 +4,7 @@
import mekanism.common.recipe.machines.BasicMachineRecipe;
import mekanism.common.recipe.outputs.ItemStackOutput;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.ingredients.VanillaTypes;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.item.ItemStack;

Expand All @@ -19,8 +20,8 @@ public MachineRecipeWrapper(BasicMachineRecipe r)
@Override
public void getIngredients(IIngredients ingredients)
{
ingredients.setInput(ItemStack.class, ((ItemStackInput)recipe.getInput()).ingredient);
ingredients.setOutput(ItemStack.class, ((ItemStackOutput)recipe.getOutput()).output);
ingredients.setInput(VanillaTypes.ITEM, ((ItemStackInput)recipe.getInput()).ingredient);
ingredients.setOutput(VanillaTypes.ITEM, ((ItemStackOutput)recipe.getOutput()).output);
}

public BasicMachineRecipe getRecipe()
Expand Down
Expand Up @@ -2,6 +2,7 @@

import mekanism.api.gas.GasStack;
import mekanism.client.jei.BaseRecipeCategory;
import mekanism.client.jei.MekanismJEI;
import mekanism.common.recipe.machines.CrystallizerRecipe;
import mezz.jei.api.IGuiHelper;
import mezz.jei.api.gui.IDrawable;
Expand Down Expand Up @@ -62,7 +63,7 @@ public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper,
itemStacks.init(0, false, 130-xOffset, 56-yOffset);
itemStacks.set(0, tempRecipe.getOutput().output);

IGuiIngredientGroup<GasStack> gasStacks = recipeLayout.getIngredientsGroup(GasStack.class);
IGuiIngredientGroup<GasStack> gasStacks = recipeLayout.getIngredientsGroup(MekanismJEI.GAS_INGREDIENT_TYPE);

initGas(gasStacks, 0, true, 6-xOffset, 5-yOffset, 16, 58, tempRecipe.getInput().ingredient, true);
}
Expand Down
@@ -1,8 +1,10 @@
package mekanism.client.jei.machine.chemical;

import mekanism.api.gas.GasStack;
import mekanism.client.jei.MekanismJEI;
import mekanism.common.recipe.machines.CrystallizerRecipe;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.ingredients.VanillaTypes;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.item.ItemStack;

Expand All @@ -18,8 +20,8 @@ public ChemicalCrystallizerRecipeWrapper(CrystallizerRecipe r)
@Override
public void getIngredients(IIngredients ingredients)
{
ingredients.setInput(GasStack.class, recipe.recipeInput.ingredient);
ingredients.setOutput(ItemStack.class, recipe.recipeOutput.output);
ingredients.setInput(MekanismJEI.GAS_INGREDIENT_TYPE, recipe.recipeInput.ingredient);
ingredients.setOutput(VanillaTypes.ITEM, recipe.recipeOutput.output);
}

public CrystallizerRecipe getRecipe()
Expand Down
Expand Up @@ -2,6 +2,7 @@

import mekanism.api.gas.GasStack;
import mekanism.client.jei.BaseRecipeCategory;
import mekanism.client.jei.MekanismJEI;
import mekanism.common.MekanismFluids;
import mekanism.common.recipe.machines.DissolutionRecipe;
import mezz.jei.api.IGuiHelper;
Expand Down Expand Up @@ -63,9 +64,9 @@ public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper,
itemStacks.init(0, true, 25-xOffset, 35-yOffset);
itemStacks.set(0, tempRecipe.getInput().ingredient);

IGuiIngredientGroup<GasStack> gasStacks = recipeLayout.getIngredientsGroup(GasStack.class);
initGas(gasStacks, 0, true, 6-xOffset, 5-yOffset, 16, 58, new GasStack(MekanismFluids.SulfuricAcid, 1), true);
IGuiIngredientGroup<GasStack> gasStacks = recipeLayout.getIngredientsGroup(MekanismJEI.GAS_INGREDIENT_TYPE);

initGasPerTick(gasStacks, 0, true, 6-xOffset, 5-yOffset, 16, 58, new GasStack(MekanismFluids.SulfuricAcid, 1), true);
initGas(gasStacks, 1, false, 134-xOffset, 14-yOffset, 16, 58, tempRecipe.getOutput().output, true);
}
}
@@ -1,9 +1,11 @@
package mekanism.client.jei.machine.chemical;

import mekanism.api.gas.GasStack;
import mekanism.client.jei.MekanismJEI;
import mekanism.common.MekanismFluids;
import mekanism.common.recipe.machines.DissolutionRecipe;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.ingredients.VanillaTypes;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.item.ItemStack;

Expand All @@ -19,9 +21,9 @@ public ChemicalDissolutionChamberRecipeWrapper(DissolutionRecipe r)
@Override
public void getIngredients(IIngredients ingredients)
{
ingredients.setInput(GasStack.class, new GasStack(MekanismFluids.SulfuricAcid, 1000));
ingredients.setInput(ItemStack.class, recipe.recipeInput.ingredient);
ingredients.setOutput(GasStack.class, recipe.recipeOutput.output);
ingredients.setInput(MekanismJEI.GAS_INGREDIENT_TYPE, new GasStack(MekanismFluids.SulfuricAcid, 1000));
ingredients.setInput(VanillaTypes.ITEM, recipe.recipeInput.ingredient);
ingredients.setOutput(MekanismJEI.GAS_INGREDIENT_TYPE, recipe.recipeOutput.output);
}

public DissolutionRecipe getRecipe()
Expand Down
Expand Up @@ -2,6 +2,7 @@

import mekanism.api.gas.GasStack;
import mekanism.client.jei.BaseRecipeCategory;
import mekanism.client.jei.MekanismJEI;
import mekanism.common.recipe.machines.ChemicalInfuserRecipe;
import mezz.jei.api.IGuiHelper;
import mezz.jei.api.gui.IDrawable;
Expand Down Expand Up @@ -56,7 +57,7 @@ public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper,

tempRecipe = ((ChemicalInfuserRecipeWrapper)recipeWrapper).getRecipe();

IGuiIngredientGroup<GasStack> gasStacks = recipeLayout.getIngredientsGroup(GasStack.class);
IGuiIngredientGroup<GasStack> gasStacks = recipeLayout.getIngredientsGroup(MekanismJEI.GAS_INGREDIENT_TYPE);

initGas(gasStacks, 0, true, 26-xOffset, 14-yOffset, 16, 58, tempRecipe.getInput().leftGas, true);
initGas(gasStacks, 1, true, 134-xOffset, 14-yOffset, 16, 58, tempRecipe.getInput().rightGas, true);
Expand Down
Expand Up @@ -3,6 +3,7 @@
import java.util.Arrays;

import mekanism.api.gas.GasStack;
import mekanism.client.jei.MekanismJEI;
import mekanism.common.recipe.machines.ChemicalInfuserRecipe;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.IRecipeWrapper;
Expand All @@ -19,8 +20,8 @@ public ChemicalInfuserRecipeWrapper(ChemicalInfuserRecipe r)
@Override
public void getIngredients(IIngredients ingredients)
{
ingredients.setInputs(GasStack.class, Arrays.asList(recipe.recipeInput.leftGas, recipe.recipeInput.rightGas));
ingredients.setOutput(GasStack.class, recipe.recipeOutput.output);
ingredients.setInputs(MekanismJEI.GAS_INGREDIENT_TYPE, Arrays.asList(recipe.recipeInput.leftGas, recipe.recipeInput.rightGas));
ingredients.setOutput(MekanismJEI.GAS_INGREDIENT_TYPE, recipe.recipeOutput.output);
}

public ChemicalInfuserRecipe getRecipe()
Expand Down
Expand Up @@ -9,6 +9,7 @@
import mekanism.client.gui.element.GuiSlot;
import mekanism.client.gui.element.GuiSlot.SlotType;
import mekanism.client.jei.BaseRecipeCategory;
import mekanism.client.jei.MekanismJEI;
import mekanism.common.recipe.machines.OxidationRecipe;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
Expand Down Expand Up @@ -78,7 +79,7 @@ public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper,
itemStacks.init(0, true, 25-xOffset, 35-yOffset);
itemStacks.set(0, tempRecipe.getInput().ingredient);

IGuiIngredientGroup<GasStack> gasStacks = recipeLayout.getIngredientsGroup(GasStack.class);
IGuiIngredientGroup<GasStack> gasStacks = recipeLayout.getIngredientsGroup(MekanismJEI.GAS_INGREDIENT_TYPE);

initGas(gasStacks, 0, false, 134-xOffset, 14-yOffset, 16, 58, tempRecipe.recipeOutput.output, true);
}
Expand Down
@@ -1,8 +1,10 @@
package mekanism.client.jei.machine.chemical;

import mekanism.api.gas.GasStack;
import mekanism.client.jei.MekanismJEI;
import mekanism.common.recipe.machines.OxidationRecipe;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.ingredients.VanillaTypes;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.item.ItemStack;

Expand All @@ -18,8 +20,8 @@ public ChemicalOxidizerRecipeWrapper(OxidationRecipe r)
@Override
public void getIngredients(IIngredients ingredients)
{
ingredients.setInput(ItemStack.class, recipe.recipeInput.ingredient);
ingredients.setOutput(GasStack.class, recipe.recipeOutput.output);
ingredients.setInput(VanillaTypes.ITEM, recipe.recipeInput.ingredient);
ingredients.setOutput(MekanismJEI.GAS_INGREDIENT_TYPE, recipe.recipeOutput.output);
}

public OxidationRecipe getRecipe()
Expand Down
Expand Up @@ -2,13 +2,16 @@

import mekanism.api.gas.GasStack;
import mekanism.client.jei.BaseRecipeCategory;
import mekanism.client.jei.MekanismJEI;
import mekanism.common.recipe.machines.WasherRecipe;
import mekanism.common.util.LangUtils;
import mezz.jei.api.IGuiHelper;
import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.gui.IGuiFluidStackGroup;
import mezz.jei.api.gui.IGuiIngredientGroup;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.ingredients.VanillaTypes;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.client.Minecraft;
import net.minecraft.util.ResourceLocation;
Expand Down Expand Up @@ -59,11 +62,11 @@ public void setRecipe(IRecipeLayout recipeLayout, IRecipeWrapper recipeWrapper,

IGuiFluidStackGroup fluidStacks = recipeLayout.getFluidStacks();

fluidStacks.init(0, true, 6-xOffset, 5-yOffset, 16, 58, 1000, false, fluidOverlayLarge);
fluidStacks.set(0, ingredients.getInputs(FluidStack.class).get(0));
fluidStacks.addTooltipCallback((index, input, ingredient, tooltip) -> tooltip.remove(1));
fluidStacks.init(0, true, 6-xOffset, 5-yOffset, 16, 58, 1, false, fluidOverlayLarge);
fluidStacks.set(0, ingredients.getInputs(VanillaTypes.FLUID).get(0));
fluidStacks.addTooltipCallback((index, input, ingredient, tooltip) -> tooltip.set(1, LangUtils.localizeWithFormat("mekanism.jei.amount.per.tick", tooltip.get(1))));

IGuiIngredientGroup<GasStack> gasStacks = recipeLayout.getIngredientsGroup(GasStack.class);
IGuiIngredientGroup<GasStack> gasStacks = recipeLayout.getIngredientsGroup(MekanismJEI.GAS_INGREDIENT_TYPE);

initGas(gasStacks, 0, true, 27-xOffset, 14-yOffset, 16, 58, tempRecipe.getInput().ingredient, true);
initGas(gasStacks, 1, false, 134-xOffset, 14-yOffset, 16, 58, tempRecipe.getOutput().output, true);
Expand Down

0 comments on commit 3d99b60

Please sign in to comment.