From f43dc35212634c1252df038ed2b7e122e639668e Mon Sep 17 00:00:00 2001 From: Buuz135 Date: Sun, 7 Apr 2019 13:40:49 +0200 Subject: [PATCH] Updated most of JEI deprecated methods --- gradle.properties | 2 +- .../thaumicjei/ThaumcraftJEIPlugin.java | 6 +++-- .../com/buuz135/thaumicjei/ThaumicJEI.java | 4 ++-- .../category/ArcaneWorkbenchCategory.java | 13 ++++++----- .../category/AspectCompoundCategory.java | 17 +++++++------- .../category/AspectFromItemStackCategory.java | 12 +++++----- .../thaumicjei/category/CrucibleCategory.java | 15 +++++++------ .../thaumicjei/category/InfusionCategory.java | 22 ++++++++++--------- 8 files changed, 50 insertions(+), 41 deletions(-) diff --git a/gradle.properties b/gradle.properties index 7d49519..84db717 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/src/main/java/com/buuz135/thaumicjei/ThaumcraftJEIPlugin.java b/src/main/java/com/buuz135/thaumicjei/ThaumcraftJEIPlugin.java index ac278a3..5604c94 100644 --- a/src/main/java/com/buuz135/thaumicjei/ThaumcraftJEIPlugin.java +++ b/src/main/java/com/buuz135/thaumicjei/ThaumcraftJEIPlugin.java @@ -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; @@ -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 ASPECT_LIST = () -> AspectList.class; public static ArcaneWorkbenchCategory arcaneWorkbenchCategory; public static CrucibleCategory crucibleCategory; @@ -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 diff --git a/src/main/java/com/buuz135/thaumicjei/ThaumicJEI.java b/src/main/java/com/buuz135/thaumicjei/ThaumicJEI.java index cfbaba8..61655ef 100644 --- a/src/main/java/com/buuz135/thaumicjei/ThaumicJEI.java +++ b/src/main/java/com/buuz135/thaumicjei/ThaumicJEI.java @@ -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; /** diff --git a/src/main/java/com/buuz135/thaumicjei/category/ArcaneWorkbenchCategory.java b/src/main/java/com/buuz135/thaumicjei/category/ArcaneWorkbenchCategory.java index 37e04b9..0a0ec53 100644 --- a/src/main/java/com/buuz135/thaumicjei/category/ArcaneWorkbenchCategory.java +++ b/src/main/java/com/buuz135/thaumicjei/category/ArcaneWorkbenchCategory.java @@ -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; @@ -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; } @@ -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 @@ -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 diff --git a/src/main/java/com/buuz135/thaumicjei/category/AspectCompoundCategory.java b/src/main/java/com/buuz135/thaumicjei/category/AspectCompoundCategory.java index e3a904b..40724b7 100644 --- a/src/main/java/com/buuz135/thaumicjei/category/AspectCompoundCategory.java +++ b/src/main/java/com/buuz135/thaumicjei/category/AspectCompoundCategory.java @@ -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; @@ -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)); } @@ -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 diff --git a/src/main/java/com/buuz135/thaumicjei/category/AspectFromItemStackCategory.java b/src/main/java/com/buuz135/thaumicjei/category/AspectFromItemStackCategory.java index dd6c37e..98bccd2 100644 --- a/src/main/java/com/buuz135/thaumicjei/category/AspectFromItemStackCategory.java +++ b/src/main/java/com/buuz135/thaumicjei/category/AspectFromItemStackCategory.java @@ -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; @@ -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 stacks : ingredients.getInputs(ItemStack.class)) { + for (List 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; @@ -97,8 +99,8 @@ public AspectFromItemStackWrapper(AspectList aspect, List 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); } } diff --git a/src/main/java/com/buuz135/thaumicjei/category/CrucibleCategory.java b/src/main/java/com/buuz135/thaumicjei/category/CrucibleCategory.java index f6f78c0..2291dcc 100644 --- a/src/main/java/com/buuz135/thaumicjei/category/CrucibleCategory.java +++ b/src/main/java/com/buuz135/thaumicjei/category/CrucibleCategory.java @@ -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; @@ -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 : 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 : 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; } } @@ -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()); } diff --git a/src/main/java/com/buuz135/thaumicjei/category/InfusionCategory.java b/src/main/java/com/buuz135/thaumicjei/category/InfusionCategory.java index ba9a5b7..2553aa1 100644 --- a/src/main/java/com/buuz135/thaumicjei/category/InfusionCategory.java +++ b/src/main/java/com/buuz135/thaumicjei/category/InfusionCategory.java @@ -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; @@ -28,6 +29,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; @@ -96,10 +98,10 @@ 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 stacks : ingredients.getInputs(ItemStack.class)) { + for (List 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); @@ -107,11 +109,11 @@ public void setRecipe(IRecipeLayout recipeLayout, InfusionWrapper recipeWrapper, 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 : 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 : 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; } } @@ -129,22 +131,22 @@ public void getIngredients(IIngredients ingredients) { List> 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