Skip to content

Commit

Permalink
Updated most of JEI deprecated methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Buuz135 committed Apr 7, 2019
1 parent cbf83a6 commit f43dc35
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 41 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
modGroup=com.buuz135.thaumicjei.ThaumicJEI
modVersion=1.5.7
modVersion=1.5.8
minecraftVersion=1.12.2
modBaseName=ThaumicJEI
forgeVersion=1.12.2-14.23.5.2768
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/com/buuz135/thaumicjei/ThaumcraftJEIPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@
import com.buuz135.thaumicjei.ingredient.AspectListIngredientHelper;
import com.google.common.collect.Maps;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonSyntaxException;
import mezz.jei.api.*;
import mezz.jei.api.ingredients.IModIngredientRegistration;
import mezz.jei.api.ingredients.VanillaTypes;
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 Down Expand Up @@ -64,6 +65,7 @@
public class ThaumcraftJEIPlugin implements IModPlugin {

private static final String ASPECT_PATH = "." + File.separator + "config" + File.separator + "thaumicjei_itemstack_aspects.json";
public static final IIngredientType<AspectList> ASPECT_LIST = () -> AspectList.class;

public static ArcaneWorkbenchCategory arcaneWorkbenchCategory;
public static CrucibleCategory crucibleCategory;
Expand All @@ -81,7 +83,7 @@ public void registerItemSubtypes(ISubtypeRegistry subtypeRegistry) {

@Override
public void registerIngredients(IModIngredientRegistration registry) {
registry.register(AspectList.class, AspectIngredientFactory.create(), new AspectListIngredientHelper(), new AspectIngredientRender());
registry.register(ASPECT_LIST, AspectIngredientFactory.create(), new AspectListIngredientHelper(), new AspectIngredientRender());
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/buuz135/thaumicjei/ThaumicJEI.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@
modid = ThaumicJEI.MOD_ID,
name = ThaumicJEI.MOD_NAME,
version = ThaumicJEI.VERSION,
dependencies = "required-after:jei@[1.12.2-4.10.0.198,);required-after:thaumcraft@[6.1.BETA20,);",
dependencies = "required-after:jei@[1.12.2-4.15.0.275,);required-after:thaumcraft@[6.1.BETA20,);",
clientSideOnly = true
)
public class ThaumicJEI {

public static final String MOD_ID = "thaumicjei";
public static final String MOD_NAME = "ThaumicJEI";
public static final String VERSION = "1.2.1";
public static final String VERSION = "1.5.8";
public static Logger LOGGER;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.ingredients.VanillaTypes;
import mezz.jei.api.recipe.IRecipeCategory;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.block.Block;
Expand Down Expand Up @@ -111,10 +112,10 @@ public void setRecipe(IRecipeLayout recipeLayout, ArcaneWorkbenchWrapper recipeW
int slot = 1;
for (int y = 0; y < sizeY; ++y) {
for (int x = 0; x < sizeX; ++x) {
if (ingredients.getInputs(ItemStack.class).size() >= slot) {
if (ingredients.getInputs(VanillaTypes.ITEM).size() >= slot) {
recipeLayout.getItemStacks().init(slot, true, 12 + (x * 30) + 30, 36 + 12 + (y) * 30);
if (ingredients.getInputs(ItemStack.class).get(slot - 1) != null) {
recipeLayout.getItemStacks().set(slot, ingredients.getInputs(ItemStack.class).get(slot - 1));
if (ingredients.getInputs(VanillaTypes.ITEM).get(slot - 1) != null) {
recipeLayout.getItemStacks().set(slot, ingredients.getInputs(VanillaTypes.ITEM).get(slot - 1));
}
++slot;
}
Expand All @@ -132,7 +133,7 @@ public void setRecipe(IRecipeLayout recipeLayout, ArcaneWorkbenchWrapper recipeW
}
}

recipeLayout.getItemStacks().set(0, ingredients.getOutputs(ItemStack.class).get(0));
recipeLayout.getItemStacks().set(0, ingredients.getOutputs(VanillaTypes.ITEM).get(0));
}

@Override
Expand Down Expand Up @@ -160,8 +161,8 @@ public void getIngredients(IIngredients ingredients) {
for (Ingredient ingredient : input) {
lists.add(Arrays.asList(ingredient.getMatchingStacks()));
}
ingredients.setInputLists(ItemStack.class, lists);
ingredients.setOutput(ItemStack.class, output);
ingredients.setInputLists(VanillaTypes.ITEM, lists);
ingredients.setOutput(VanillaTypes.ITEM, output);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*/
package com.buuz135.thaumicjei.category;

import com.buuz135.thaumicjei.ThaumcraftJEIPlugin;
import com.buuz135.thaumicjei.ThaumicJEI;
import com.buuz135.thaumicjei.ingredient.AspectIngredientRender;
import mezz.jei.api.IGuiHelper;
Expand Down Expand Up @@ -77,12 +78,12 @@ public void drawExtras(Minecraft minecraft) {

@Override
public void setRecipe(IRecipeLayout recipeLayout, AspectCompoundWrapper recipeWrapper, IIngredients ingredients) {
recipeLayout.getIngredientsGroup(AspectList.class).init(0, false, new AspectIngredientRender(), 82, 2, 16, 16, 0, 0);
recipeLayout.getIngredientsGroup(AspectList.class).set(0, ingredients.getOutputs(AspectList.class).get(0));
recipeLayout.getIngredientsGroup(AspectList.class).init(1, true, new AspectIngredientRender(), 8, 2, 16, 16, 0, 0);
recipeLayout.getIngredientsGroup(AspectList.class).init(2, true, new AspectIngredientRender(), 46, 2, 16, 16, 0, 0);
recipeLayout.getIngredientsGroup(AspectList.class).set(1, ingredients.getInputs(AspectList.class).get(0));
recipeLayout.getIngredientsGroup(AspectList.class).set(2, ingredients.getInputs(AspectList.class).get(1));
recipeLayout.getIngredientsGroup(ThaumcraftJEIPlugin.ASPECT_LIST).init(0, false, new AspectIngredientRender(), 82, 2, 16, 16, 0, 0);
recipeLayout.getIngredientsGroup(ThaumcraftJEIPlugin.ASPECT_LIST).set(0, ingredients.getOutputs(ThaumcraftJEIPlugin.ASPECT_LIST).get(0));
recipeLayout.getIngredientsGroup(ThaumcraftJEIPlugin.ASPECT_LIST).init(1, true, new AspectIngredientRender(), 8, 2, 16, 16, 0, 0);
recipeLayout.getIngredientsGroup(ThaumcraftJEIPlugin.ASPECT_LIST).init(2, true, new AspectIngredientRender(), 46, 2, 16, 16, 0, 0);
recipeLayout.getIngredientsGroup(ThaumcraftJEIPlugin.ASPECT_LIST).set(1, ingredients.getInputs(ThaumcraftJEIPlugin.ASPECT_LIST).get(0));
recipeLayout.getIngredientsGroup(ThaumcraftJEIPlugin.ASPECT_LIST).set(2, ingredients.getInputs(ThaumcraftJEIPlugin.ASPECT_LIST).get(1));
}


Expand All @@ -96,8 +97,8 @@ public AspectCompoundWrapper(Aspect aspect) {

@Override
public void getIngredients(IIngredients ingredients) {
ingredients.setOutput(AspectList.class, new AspectList().add(aspect, 1));
ingredients.setInputs(AspectList.class, Arrays.stream(aspect.getComponents()).map(aspect1 -> new AspectList().add(aspect1, 1)).collect(Collectors.toList()));
ingredients.setOutput(ThaumcraftJEIPlugin.ASPECT_LIST, new AspectList().add(aspect, 1));
ingredients.setInputs(ThaumcraftJEIPlugin.ASPECT_LIST, Arrays.stream(aspect.getComponents()).map(aspect1 -> new AspectList().add(aspect1, 1)).collect(Collectors.toList()));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@
*/
package com.buuz135.thaumicjei.category;

import com.buuz135.thaumicjei.ThaumcraftJEIPlugin;
import com.buuz135.thaumicjei.ThaumicJEI;
import com.buuz135.thaumicjei.drawable.AlphaDrawable;
import com.buuz135.thaumicjei.ingredient.AspectIngredientRender;
import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.ingredients.VanillaTypes;
import mezz.jei.api.recipe.IRecipeCategory;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.client.Minecraft;
Expand Down Expand Up @@ -73,11 +75,11 @@ public void drawExtras(Minecraft minecraft) {

@Override
public void setRecipe(IRecipeLayout recipeLayout, AspectFromItemStackWrapper recipeWrapper, IIngredients ingredients) {
recipeLayout.getIngredientsGroup(AspectList.class).init(0, false, new AspectIngredientRender(), 8 + 81 - 9, 8, 16, 16, 0, 0);
recipeLayout.getIngredientsGroup(AspectList.class).set(0, ingredients.getOutputs(AspectList.class).get(0));
recipeLayout.getIngredientsGroup(ThaumcraftJEIPlugin.ASPECT_LIST).init(0, false, new AspectIngredientRender(), 8 + 81 - 9, 8, 16, 16, 0, 0);
recipeLayout.getIngredientsGroup(ThaumcraftJEIPlugin.ASPECT_LIST).set(0, ingredients.getOutputs(ThaumcraftJEIPlugin.ASPECT_LIST).get(0));
int slot = 0;
int row = 9;
for (List<ItemStack> stacks : ingredients.getInputs(ItemStack.class)) {
for (List<ItemStack> stacks : ingredients.getInputs(VanillaTypes.ITEM)) {
recipeLayout.getItemStacks().init(slot + 1, true, (slot % row) * 18 - 18 * 3 - 21 + 81, (slot / row) * 18 + 32);
recipeLayout.getItemStacks().set(slot + 1, stacks);
++slot;
Expand All @@ -97,8 +99,8 @@ public AspectFromItemStackWrapper(AspectList aspect, List<ItemStack> stacks) {

@Override
public void getIngredients(IIngredients ingredients) {
ingredients.setOutput(AspectList.class, aspect);
ingredients.setInputs(ItemStack.class, stacks);
ingredients.setOutput(ThaumcraftJEIPlugin.ASPECT_LIST, aspect);
ingredients.setInputs(VanillaTypes.ITEM, stacks);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*/
package com.buuz135.thaumicjei.category;

import com.buuz135.thaumicjei.ThaumcraftJEIPlugin;
import com.buuz135.thaumicjei.ThaumicJEI;
import com.buuz135.thaumicjei.drawable.AlphaDrawable;
import com.buuz135.thaumicjei.drawable.ItemStackDrawable;
Expand Down Expand Up @@ -88,16 +89,16 @@ public IDrawable getIcon() {
@Override
public void setRecipe(IRecipeLayout recipeLayout, CrucibleWrapper recipeWrapper, IIngredients ingredients) {
recipeLayout.getItemStacks().init(0, false, 61 - 6, 8);
recipeLayout.getItemStacks().set(0, ingredients.getOutputs(ItemStack.class).get(0));
recipeLayout.getItemStacks().set(0, ingredients.getOutputs(VanillaTypes.ITEM).get(0));

recipeLayout.getItemStacks().init(1, true, 2, 2);
recipeLayout.getItemStacks().set(1, ingredients.getInputs(ItemStack.class).get(0));
recipeLayout.getItemStacks().set(1, ingredients.getInputs(VanillaTypes.ITEM).get(0));

int center = (ingredients.getInputs(AspectList.class).size() * SPACE) / 2;
int center = (ingredients.getInputs(ThaumcraftJEIPlugin.ASPECT_LIST).size() * SPACE) / 2;
int x = 0;
for (List<AspectList> aspectList : ingredients.getInputs(AspectList.class)) {
recipeLayout.getIngredientsGroup(AspectList.class).init(x + 1, true, new AspectIngredientRender(), ASPECT_X - center + x * SPACE, ASPECT_Y, 16, 16, 0, 0);
recipeLayout.getIngredientsGroup(AspectList.class).set(x + 1, aspectList);
for (List<AspectList> aspectList : ingredients.getInputs(ThaumcraftJEIPlugin.ASPECT_LIST)) {
recipeLayout.getIngredientsGroup(ThaumcraftJEIPlugin.ASPECT_LIST).init(x + 1, true, new AspectIngredientRender(), ASPECT_X - center + x * SPACE, ASPECT_Y, 16, 16, 0, 0);
recipeLayout.getIngredientsGroup(ThaumcraftJEIPlugin.ASPECT_LIST).set(x + 1, aspectList);
++x;
}
}
Expand All @@ -122,7 +123,7 @@ public CrucibleWrapper(CrucibleRecipe recipe) {
@Override
public void getIngredients(IIngredients ingredients) {
ingredients.setInputs(VanillaTypes.ITEM, Arrays.asList(recipe.getCatalyst().getMatchingStacks()));
ingredients.setInputs(AspectList.class, Arrays.stream(recipe.getAspects().getAspectsSortedByAmount()).map(aspect -> new AspectList().add(aspect, recipe.getAspects().getAmount(aspect))).collect(Collectors.toList()));
ingredients.setInputs(ThaumcraftJEIPlugin.ASPECT_LIST, Arrays.stream(recipe.getAspects().getAspectsSortedByAmount()).map(aspect -> new AspectList().add(aspect, recipe.getAspects().getAmount(aspect))).collect(Collectors.toList()));
ingredients.setOutput(VanillaTypes.ITEM, recipe.getRecipeOutput());
}

Expand Down
22 changes: 12 additions & 10 deletions src/main/java/com/buuz135/thaumicjei/category/InfusionCategory.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@
*/
package com.buuz135.thaumicjei.category;

import com.buuz135.thaumicjei.ThaumcraftJEIPlugin;
import com.buuz135.thaumicjei.ThaumicJEI;
import com.buuz135.thaumicjei.drawable.AlphaDrawable;
import com.buuz135.thaumicjei.drawable.ItemStackDrawable;
import com.buuz135.thaumicjei.ingredient.AspectIngredientRender;
import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.ingredients.VanillaTypes;
import mezz.jei.api.recipe.IRecipeCategory;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.block.Block;
Expand Down Expand Up @@ -96,22 +98,22 @@ public IDrawable getIcon() {
@Override
public void setRecipe(IRecipeLayout recipeLayout, InfusionWrapper recipeWrapper, IIngredients ingredients) {
recipeLayout.getItemStacks().init(0, false, 34 + 30, 7);
recipeLayout.getItemStacks().set(0, ingredients.getOutputs(ItemStack.class).get(0));
recipeLayout.getItemStacks().set(0, ingredients.getOutputs(VanillaTypes.ITEM).get(0));
int slot = 1;
float currentRotation = -90.0F;
for (List<ItemStack> stacks : ingredients.getInputs(ItemStack.class)) {
for (List<ItemStack> stacks : ingredients.getInputs(VanillaTypes.ITEM)) {
if (slot == 1) recipeLayout.getItemStacks().init(slot, true, 34 + 30, 75);
else
recipeLayout.getItemStacks().init(slot, true, 30 + (int) (MathHelper.cos((float) (currentRotation / 180.0F * Math.PI)) * 40.0F) + 34, (int) (MathHelper.sin(currentRotation / 180.0F * 3.1415927F) * 40.0F) + 75);
recipeLayout.getItemStacks().set(slot, stacks);
currentRotation += (360f / recipeWrapper.recipe.getComponents().size());
++slot;
}
int center = (ingredients.getInputs(AspectList.class).size() * SPACE) / 2;
int center = (ingredients.getInputs(ThaumcraftJEIPlugin.ASPECT_LIST).size() * SPACE) / 2;
int x = 0;
for (List<AspectList> aspectList : ingredients.getInputs(AspectList.class)) {
recipeLayout.getIngredientsGroup(AspectList.class).init(x + slot, true, new AspectIngredientRender(), 30 + ASPECT_X - center + x * SPACE, ASPECT_Y, 16, 16, 0, 0);
recipeLayout.getIngredientsGroup(AspectList.class).set(x + slot, aspectList);
for (List<AspectList> aspectList : ingredients.getInputs(ThaumcraftJEIPlugin.ASPECT_LIST)) {
recipeLayout.getIngredientsGroup(ThaumcraftJEIPlugin.ASPECT_LIST).init(x + slot, true, new AspectIngredientRender(), 30 + ASPECT_X - center + x * SPACE, ASPECT_Y, 16, 16, 0, 0);
recipeLayout.getIngredientsGroup(ThaumcraftJEIPlugin.ASPECT_LIST).set(x + slot, aspectList);
++x;
}
}
Expand All @@ -129,22 +131,22 @@ public void getIngredients(IIngredients ingredients) {
List<List<ItemStack>> inputs = new ArrayList<>();
inputs.add(Arrays.asList(recipe.getRecipeInput().getMatchingStacks()));
if (recipe.recipeOutput instanceof ItemStack) {
ingredients.setOutput(ItemStack.class, ((ItemStack) recipe.recipeOutput).copy());
ingredients.setOutput(VanillaTypes.ITEM, ((ItemStack) recipe.recipeOutput).copy());
} else if (recipe.recipeOutput != null) {
for (ItemStack stack : inputs.get(0)) {
if (stack != null) {
Object[] objects = (Object[]) recipe.recipeOutput;
ItemStack copied = stack.copy();
copied.setTagInfo((String) objects[0], (NBTBase) objects[1]);
ingredients.setOutput(ItemStack.class, copied);
ingredients.setOutput(VanillaTypes.ITEM, copied);
}
}
}
for (Ingredient comp : recipe.getComponents()) {
inputs.add(Arrays.asList(comp.getMatchingStacks()));
}
ingredients.setInputLists(ItemStack.class, inputs);
ingredients.setInputs(AspectList.class, Arrays.stream(recipe.aspects.getAspectsSortedByAmount()).map(aspect -> new AspectList().add(aspect, recipe.aspects.getAmount(aspect))).collect(Collectors.toList()));
ingredients.setInputLists(VanillaTypes.ITEM, inputs);
ingredients.setInputs(ThaumcraftJEIPlugin.ASPECT_LIST, Arrays.stream(recipe.aspects.getAspectsSortedByAmount()).map(aspect -> new AspectList().add(aspect, recipe.aspects.getAmount(aspect))).collect(Collectors.toList()));
}

@Override
Expand Down

0 comments on commit f43dc35

Please sign in to comment.