diff --git a/build.gradle b/build.gradle index dbe84334a..2cdd31794 100644 --- a/build.gradle +++ b/build.gradle @@ -114,7 +114,8 @@ jar { dependencies { //deobfCompile "com.mod-buildcraft:buildcraft-api:7.99.17" //deobfCompile "com.azanor.baubles:Baubles:1.12-1.5.2" - //deobfCompile "mezz.jei:jei_1.12.2:4.13.1.220" + compileOnly fg.deobf("mezz.jei:jei-1.13.2:5.0.0.20:api") + runtimeOnly fg.deobf("mezz.jei:jei-1.13.2:5.0.0.20") //deobfCompile "thaumcraft:Thaumcraft:1.12.2:6.1.BETA26" //and a bit more for SCP diff --git a/src_disabled/main/java/vazkii/botania/client/integration/jei/JEIBotaniaPlugin.java b/src/main/java/vazkii/botania/client/integration/jei/JEIBotaniaPlugin.java similarity index 66% rename from src_disabled/main/java/vazkii/botania/client/integration/jei/JEIBotaniaPlugin.java rename to src/main/java/vazkii/botania/client/integration/jei/JEIBotaniaPlugin.java index 316c47e9b..47cca1ce5 100644 --- a/src_disabled/main/java/vazkii/botania/client/integration/jei/JEIBotaniaPlugin.java +++ b/src/main/java/vazkii/botania/client/integration/jei/JEIBotaniaPlugin.java @@ -8,60 +8,53 @@ */ package vazkii.botania.client.integration.jei; -import mezz.jei.api.IJeiRuntime; import mezz.jei.api.IModPlugin; -import mezz.jei.api.IModRegistry; -import mezz.jei.api.IRecipeRegistry; -import mezz.jei.api.IRecipesGui; -import mezz.jei.api.ISubtypeRegistry; -import mezz.jei.api.JEIPlugin; -import mezz.jei.api.recipe.IRecipeCategoryRegistration; -import mezz.jei.api.recipe.IRecipeWrapper; -import mezz.jei.api.recipe.VanillaRecipeCategoryUid; +import mezz.jei.api.JeiPlugin; +import mezz.jei.api.constants.VanillaRecipeCategoryUid; +import mezz.jei.api.recipe.IRecipeManager; +import mezz.jei.api.registration.IRecipeCatalystRegistration; +import mezz.jei.api.registration.IRecipeCategoryRegistration; +import mezz.jei.api.registration.IRecipeRegistration; +import mezz.jei.api.registration.IRecipeTransferRegistration; +import mezz.jei.api.registration.ISubtypeRegistration; +import mezz.jei.api.registration.IVanillaCategoryExtensionRegistration; +import mezz.jei.api.runtime.IJeiRuntime; +import mezz.jei.api.runtime.IRecipesGui; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; -import net.minecraftforge.oredict.OreDictionary; +import net.minecraft.item.crafting.Ingredient; +import net.minecraft.tags.BlockTags; +import net.minecraft.util.ResourceLocation; import vazkii.botania.api.BotaniaAPI; -import vazkii.botania.api.recipe.RecipeBrew; import vazkii.botania.api.recipe.RecipeElvenTrade; -import vazkii.botania.api.recipe.RecipeManaInfusion; -import vazkii.botania.api.recipe.RecipePetals; -import vazkii.botania.api.recipe.RecipePureDaisy; -import vazkii.botania.api.recipe.RecipeRuneAltar; import vazkii.botania.client.core.handler.CorporeaInputHandler; import vazkii.botania.client.gui.crafting.ContainerCraftingHalo; import vazkii.botania.client.integration.jei.brewery.BreweryRecipeCategory; -import vazkii.botania.client.integration.jei.brewery.BreweryRecipeWrapper; import vazkii.botania.client.integration.jei.crafting.AncientWillRecipeWrapper; import vazkii.botania.client.integration.jei.crafting.CompositeLensRecipeWrapper; import vazkii.botania.client.integration.jei.crafting.SpecialFloatingFlowerWrapper; import vazkii.botania.client.integration.jei.crafting.TerraPickTippingRecipeWrapper; import vazkii.botania.client.integration.jei.elventrade.ElvenTradeRecipeCategory; -import vazkii.botania.client.integration.jei.elventrade.ElvenTradeRecipeWrapper; import vazkii.botania.client.integration.jei.manapool.ManaPoolRecipeCategory; -import vazkii.botania.client.integration.jei.manapool.ManaPoolRecipeWrapper; import vazkii.botania.client.integration.jei.orechid.OrechidIgnemRecipeCategory; import vazkii.botania.client.integration.jei.orechid.OrechidIgnemRecipeWrapper; import vazkii.botania.client.integration.jei.orechid.OrechidRecipeCategory; import vazkii.botania.client.integration.jei.orechid.OrechidRecipeWrapper; import vazkii.botania.client.integration.jei.petalapothecary.PetalApothecaryRecipeCategory; -import vazkii.botania.client.integration.jei.petalapothecary.PetalApothecaryRecipeWrapper; import vazkii.botania.client.integration.jei.puredaisy.PureDaisyRecipeCategory; -import vazkii.botania.client.integration.jei.puredaisy.PureDaisyRecipeWrapper; import vazkii.botania.client.integration.jei.runicaltar.RunicAltarRecipeCategory; -import vazkii.botania.client.integration.jei.runicaltar.RunicAltarRecipeWrapper; import vazkii.botania.common.block.ModBlocks; +import vazkii.botania.common.block.ModSubtiles; import vazkii.botania.common.crafting.recipe.AncientWillRecipe; import vazkii.botania.common.crafting.recipe.CompositeLensRecipe; import vazkii.botania.common.crafting.recipe.SpecialFloatingFlowerRecipe; import vazkii.botania.common.crafting.recipe.TerraPickTippingRecipe; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.block.ItemBlockSpecialFlower; -import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.item.brew.ItemBrewBase; +import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; import java.util.List; @@ -71,13 +64,14 @@ import static vazkii.botania.common.lib.LibBlockNames.SUBTILE_ORECHID; import static vazkii.botania.common.lib.LibBlockNames.SUBTILE_ORECHID_IGNEM; import static vazkii.botania.common.lib.LibBlockNames.SUBTILE_PUREDAISY; -@JEIPlugin +@JeiPlugin public class JEIBotaniaPlugin implements IModPlugin { + private static final ResourceLocation ID = new ResourceLocation(LibMisc.MOD_ID, "main"); @Override - public void registerItemSubtypes(@Nonnull ISubtypeRegistry subtypeRegistry) { - subtypeRegistry.registerSubtypeInterpreter(Item.getItemFromBlock(ModBlocks.specialFlower), stack -> ItemBlockSpecialFlower.getType(stack).toString()); - subtypeRegistry.registerSubtypeInterpreter(Item.getItemFromBlock(ModBlocks.floatingSpecialFlower), stack -> ItemBlockSpecialFlower.getType(stack).toString()); + public void registerItemSubtypes(@Nonnull ISubtypeRegistration subtypeRegistry) { + subtypeRegistry.registerSubtypeInterpreter(ModBlocks.specialFlower.asItem(), stack -> ItemBlockSpecialFlower.getType(stack).toString()); + subtypeRegistry.registerSubtypeInterpreter(ModBlocks.floatingSpecialFlower.asItem(), stack -> ItemBlockSpecialFlower.getType(stack).toString()); subtypeRegistry.registerSubtypeInterpreter(ModItems.brewVial, ItemBrewBase::getSubtype); subtypeRegistry.registerSubtypeInterpreter(ModItems.brewFlask, ItemBrewBase::getSubtype); subtypeRegistry.registerSubtypeInterpreter(ModItems.incenseStick, ItemBrewBase::getSubtype); @@ -98,32 +92,26 @@ public class JEIBotaniaPlugin implements IModPlugin { ); } - public static boolean doesOreExist(String key) { - return OreDictionary.doesOreNameExist(key) - && OreDictionary.getOres(key).stream() - .anyMatch(s -> s.getItem() instanceof ItemBlock); + public static boolean doesOreExist(ResourceLocation tagId) { + return !BlockTags.getCollection().getOrCreate(tagId).getAllElements().isEmpty(); } @Override - public void register(@Nonnull IModRegistry registry) { - registry.handleRecipes(RecipeBrew.class, BreweryRecipeWrapper::new, BreweryRecipeCategory.UID); - registry.handleRecipes(RecipePureDaisy.class, PureDaisyRecipeWrapper::new, PureDaisyRecipeCategory.UID); - registry.handleRecipes(RecipeRuneAltar.class, RunicAltarRecipeWrapper::new, RunicAltarRecipeCategory.UID); // Runic must come before petals. See williewillus/Botania#172 - registry.handleRecipes(RecipePetals.class, PetalApothecaryRecipeWrapper::new, PetalApothecaryRecipeCategory.UID); - registry.handleRecipes(RecipeElvenTrade.class, ElvenTradeRecipeWrapper::new, ElvenTradeRecipeCategory.UID); - registry.handleRecipes(RecipeManaInfusion.class, ManaPoolRecipeWrapper::new, ManaPoolRecipeCategory.UID); - - registry.handleRecipes(SpecialFloatingFlowerRecipe.class, SpecialFloatingFlowerWrapper::new, VanillaRecipeCategoryUid.CRAFTING); - registry.handleRecipes(AncientWillRecipe.class, AncientWillRecipeWrapper::new, VanillaRecipeCategoryUid.CRAFTING); - registry.handleRecipes(TerraPickTippingRecipe.class, TerraPickTippingRecipeWrapper::new, VanillaRecipeCategoryUid.CRAFTING); - registry.handleRecipes(CompositeLensRecipe.class, r -> new CompositeLensRecipeWrapper(), VanillaRecipeCategoryUid.CRAFTING); - + public void registerVanillaCategoryExtensions(IVanillaCategoryExtensionRegistration registration) { + registration.getCraftingCategory().addCategoryExtension(SpecialFloatingFlowerRecipe.class, SpecialFloatingFlowerWrapper::new); + registration.getCraftingCategory().addCategoryExtension(AncientWillRecipe.class, AncientWillRecipeWrapper::new); + registration.getCraftingCategory().addCategoryExtension(TerraPickTippingRecipe.class, TerraPickTippingRecipeWrapper::new); + registration.getCraftingCategory().addCategoryExtension(CompositeLensRecipe.class, CompositeLensRecipeWrapper::new); + } + + @Override + public void registerRecipes(@Nonnull IRecipeRegistration registry) { registry.addRecipes(BotaniaAPI.brewRecipes, BreweryRecipeCategory.UID); registry.addRecipes(BotaniaAPI.pureDaisyRecipes, PureDaisyRecipeCategory.UID); registry.addRecipes(BotaniaAPI.petalRecipes, PetalApothecaryRecipeCategory.UID); registry.addRecipes(BotaniaAPI.elvenTradeRecipes, ElvenTradeRecipeCategory.UID); registry.addRecipes(BotaniaAPI.runeAltarRecipes, RunicAltarRecipeCategory.UID); - registry.addRecipes(BotaniaAPI.manaInfusionRecipes, ManaPoolRecipeCategory.UID); + registry.addRecipes(BotaniaAPI.manaInfusionRecipes.values(), ManaPoolRecipeCategory.UID); registry.addRecipes( BotaniaAPI.oreWeights.entrySet().stream() @@ -141,7 +129,15 @@ public class JEIBotaniaPlugin implements IModPlugin { .collect(Collectors.toList()), OrechidIgnemRecipeCategory.UID); + } + @Override + public void registerRecipeTransferHandlers(IRecipeTransferRegistration registry) { + registry.addRecipeTransferHandler(ContainerCraftingHalo.class, VanillaRecipeCategoryUid.CRAFTING, 1, 9, 10, 36); + } + + @Override + public void registerRecipeCatalysts(IRecipeCatalystRegistration registry) { registry.addRecipeCatalyst(new ItemStack(ModBlocks.brewery), BreweryRecipeCategory.UID); registry.addRecipeCatalyst(new ItemStack(ModBlocks.alfPortal), ElvenTradeRecipeCategory.UID); @@ -162,32 +158,26 @@ public class JEIBotaniaPlugin implements IModPlugin { registry.addRecipeCatalyst(new ItemStack(ModBlocks.mossyAltar), PetalApothecaryRecipeCategory.UID); registry.addRecipeCatalyst(ItemBlockSpecialFlower.ofType(SUBTILE_ORECHID), OrechidRecipeCategory.UID); - registry.addRecipeCatalyst(ItemBlockSpecialFlower.ofType(new ItemStack(ModBlocks.floatingSpecialFlower), SUBTILE_ORECHID), OrechidRecipeCategory.UID); + registry.addRecipeCatalyst(ItemBlockSpecialFlower.ofType(new ItemStack(ModBlocks.floatingSpecialFlower), ModSubtiles.orechid), OrechidRecipeCategory.UID); registry.addRecipeCatalyst(ItemBlockSpecialFlower.ofType(SUBTILE_ORECHID_IGNEM), OrechidIgnemRecipeCategory.UID); - registry.addRecipeCatalyst(ItemBlockSpecialFlower.ofType(new ItemStack(ModBlocks.floatingSpecialFlower), SUBTILE_ORECHID_IGNEM), OrechidIgnemRecipeCategory.UID); + registry.addRecipeCatalyst(ItemBlockSpecialFlower.ofType(new ItemStack(ModBlocks.floatingSpecialFlower), ModSubtiles.orechidIgnem), OrechidIgnemRecipeCategory.UID); registry.addRecipeCatalyst(ItemBlockSpecialFlower.ofType(SUBTILE_PUREDAISY), PureDaisyRecipeCategory.UID); - registry.addRecipeCatalyst(ItemBlockSpecialFlower.ofType(new ItemStack(ModBlocks.floatingSpecialFlower), SUBTILE_PUREDAISY), PureDaisyRecipeCategory.UID); + registry.addRecipeCatalyst(ItemBlockSpecialFlower.ofType(new ItemStack(ModBlocks.floatingSpecialFlower), ModSubtiles.pureDaisy), PureDaisyRecipeCategory.UID); registry.addRecipeCatalyst(new ItemStack(ModBlocks.runeAltar), RunicAltarRecipeCategory.UID); registry.addRecipeCatalyst(new ItemStack(ModItems.autocraftingHalo), VanillaRecipeCategoryUid.CRAFTING); registry.addRecipeCatalyst(new ItemStack(ModItems.craftingHalo), VanillaRecipeCategoryUid.CRAFTING); - - registry.getRecipeTransferRegistry().addRecipeTransferHandler(ContainerCraftingHalo.class, VanillaRecipeCategoryUid.CRAFTING, 1, 9, 10, 36); } @Override public void onRuntimeAvailable(IJeiRuntime jeiRuntime) { - IRecipeRegistry recipeRegistry = jeiRuntime.getRecipeRegistry(); + IRecipeManager recipeRegistry = jeiRuntime.getRecipeManager(); for(RecipeElvenTrade recipe : BotaniaAPI.elvenTradeRecipes) { - List inputs = recipe.getInputs(); + List inputs = recipe.getInputs(); List outputs = recipe.getOutputs(); - if(inputs.size() == 1 && outputs.size() == 1 && inputs.get(0) instanceof ItemStack - && ItemStack.areItemStacksEqual((ItemStack) inputs.get(0), outputs.get(0))) { - IRecipeWrapper wrapper = recipeRegistry.getRecipeWrapper(recipe, ElvenTradeRecipeCategory.UID); - if(wrapper != null) { - recipeRegistry.hideRecipe(wrapper, ElvenTradeRecipeCategory.UID); - } + if(inputs.size() == 1 && outputs.size() == 1 && inputs.get(0).test(outputs.get(0))) { + recipeRegistry.hideRecipe(recipe, ElvenTradeRecipeCategory.UID); } } @@ -205,4 +195,9 @@ public class JEIBotaniaPlugin implements IModPlugin { CorporeaInputHandler.supportedGuiFilter = gui -> gui instanceof GuiContainer || gui instanceof IRecipesGui; } + @Nonnull + @Override + public ResourceLocation getPluginUid() { + return ID; + } } diff --git a/src_disabled/main/java/vazkii/botania/client/integration/jei/brewery/BreweryRecipeCategory.java b/src/main/java/vazkii/botania/client/integration/jei/brewery/BreweryRecipeCategory.java similarity index 57% rename from src_disabled/main/java/vazkii/botania/client/integration/jei/brewery/BreweryRecipeCategory.java rename to src/main/java/vazkii/botania/client/integration/jei/brewery/BreweryRecipeCategory.java index a6dc10ee8..525a5c76b 100644 --- a/src_disabled/main/java/vazkii/botania/client/integration/jei/brewery/BreweryRecipeCategory.java +++ b/src/main/java/vazkii/botania/client/integration/jei/brewery/BreweryRecipeCategory.java @@ -8,61 +8,100 @@ */ package vazkii.botania.client.integration.jei.brewery; -import mezz.jei.api.IGuiHelper; -import mezz.jei.api.gui.IDrawable; -import mezz.jei.api.gui.IDrawableStatic; +import com.google.common.collect.ImmutableList; +import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.gui.drawable.IDrawable; +import mezz.jei.api.gui.drawable.IDrawableStatic; +import mezz.jei.api.helpers.IGuiHelper; import mezz.jei.api.ingredients.IIngredients; -import mezz.jei.api.ingredients.VanillaTypes; import mezz.jei.api.recipe.IFocus; -import mezz.jei.api.recipe.IRecipeCategory; +import mezz.jei.api.recipe.category.IRecipeCategory; import net.minecraft.client.resources.I18n; import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.ResourceLocation; +import vazkii.botania.api.recipe.RecipeBrew; +import vazkii.botania.common.block.ModBlocks; +import vazkii.botania.common.item.ModItems; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; +import java.util.Arrays; import java.util.Collections; import java.util.List; -public class BreweryRecipeCategory implements IRecipeCategory { +public class BreweryRecipeCategory implements IRecipeCategory { - public static final String UID = "botania.brewery"; + public static final ResourceLocation UID = new ResourceLocation(LibMisc.MOD_ID, "brewery"); private final IDrawableStatic background; + private final IDrawable icon; private final String localizedName; public BreweryRecipeCategory(IGuiHelper guiHelper) { ResourceLocation location = new ResourceLocation("botania", "textures/gui/neiBrewery.png"); background = guiHelper.createDrawable(location, 0, 0, 166, 65); localizedName = I18n.format("botania.nei.brewery"); + icon = guiHelper.createDrawableIngredient(new ItemStack(ModBlocks.brewery)); } @Nonnull @Override - public String getUid() { + public ResourceLocation getUid() { return UID; } + @Nonnull + @Override + public Class getRecipeClass() { + return RecipeBrew.class; + } + @Nonnull @Override public String getTitle() { return localizedName; } - @Nonnull - @Override - public String getModName() { - return LibMisc.MOD_NAME; - } - @Nonnull @Override public IDrawable getBackground() { return background; } + @Nonnull @Override - public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull BreweryRecipeWrapper recipeWrapper, @Nonnull IIngredients ingredients) { + public IDrawable getIcon() { + return icon; + } + + @Override + public void setIngredients(RecipeBrew recipe, IIngredients iIngredients) { + ImmutableList.Builder> inputBuilder = ImmutableList.builder(); + ImmutableList.Builder outputBuilder = ImmutableList.builder(); + ImmutableList.Builder containers = ImmutableList.builder(); + + final List inputs = Arrays.asList(new ItemStack(ModItems.vial), + new ItemStack(ModItems.flask), new ItemStack(ModItems.incenseStick), new ItemStack(ModItems.bloodPendant)); + for(ItemStack stack : inputs) { + ItemStack brewed = recipe.getOutput(stack); + if(!brewed.isEmpty()) { + containers.add(stack); + outputBuilder.add(brewed); + } + } + inputBuilder.add(containers.build()); + + for(Ingredient i : recipe.getInputs()) { + inputBuilder.add(Arrays.asList(i.getMatchingStacks())); + } + + iIngredients.setInputLists(VanillaTypes.ITEM, inputBuilder.build()); + iIngredients.setOutputLists(VanillaTypes.ITEM, ImmutableList.of(outputBuilder.build())); + } + + @Override + public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull RecipeBrew recipe, @Nonnull IIngredients ingredients) { List> inputs = ingredients.getInputs(VanillaTypes.ITEM); List> outputs = ingredients.getOutputs(VanillaTypes.ITEM); diff --git a/src_disabled/main/java/vazkii/botania/client/integration/jei/crafting/AncientWillRecipeWrapper.java b/src/main/java/vazkii/botania/client/integration/jei/crafting/AncientWillRecipeWrapper.java similarity index 62% rename from src_disabled/main/java/vazkii/botania/client/integration/jei/crafting/AncientWillRecipeWrapper.java rename to src/main/java/vazkii/botania/client/integration/jei/crafting/AncientWillRecipeWrapper.java index 5167ca139..7c2389c10 100644 --- a/src_disabled/main/java/vazkii/botania/client/integration/jei/crafting/AncientWillRecipeWrapper.java +++ b/src/main/java/vazkii/botania/client/integration/jei/crafting/AncientWillRecipeWrapper.java @@ -1,53 +1,53 @@ package vazkii.botania.client.integration.jei.crafting; import com.google.common.collect.ImmutableList; -import mezz.jei.api.gui.IGuiItemStackGroup; +import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.gui.ingredient.IGuiItemStackGroup; import mezz.jei.api.ingredients.IIngredients; -import mezz.jei.api.ingredients.VanillaTypes; import mezz.jei.api.recipe.IFocus; -import mezz.jei.api.recipe.wrapper.ICustomCraftingRecipeWrapper; +import mezz.jei.api.recipe.category.extensions.vanilla.crafting.ICustomCraftingCategoryExtension; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import vazkii.botania.api.item.IAncientWillContainer; import vazkii.botania.common.Botania; import vazkii.botania.common.crafting.recipe.AncientWillRecipe; +import vazkii.botania.common.item.ItemAncientWill; import vazkii.botania.common.item.ModItems; import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.util.List; -public class AncientWillRecipeWrapper implements ICustomCraftingRecipeWrapper { +public class AncientWillRecipeWrapper implements ICustomCraftingCategoryExtension { private final ResourceLocation name; - private final List> inputs; - private final List output; public AncientWillRecipeWrapper(AncientWillRecipe recipe) { - this.name = recipe.getRegistryName(); + this.name = recipe.getId(); + } - ImmutableList.Builder> builder = ImmutableList.builder(); + @Override + public void setIngredients(@Nonnull IIngredients ingredients) { + ImmutableList.Builder> builder = ImmutableList.builder(); ImmutableList.Builder helmets = ImmutableList.builder(); ImmutableList.Builder wills = ImmutableList.builder(); helmets.add(new ItemStack(ModItems.terrasteelHelm)); if(Botania.thaumcraftLoaded) { helmets.add(new ItemStack(ModItems.terrasteelHelmRevealing)); } - for(int i = 0; i < 6; i++) { - wills.add(new ItemStack(ModItems.ancientWill, 1, i)); - } + wills.add(new ItemStack(ModItems.ancientWillAhrim)); + wills.add(new ItemStack(ModItems.ancientWillDharok)); + wills.add(new ItemStack(ModItems.ancientWillGuthan)); + wills.add(new ItemStack(ModItems.ancientWillTorag)); + wills.add(new ItemStack(ModItems.ancientWillVerac)); + wills.add(new ItemStack(ModItems.ancientWillKaril)); - output = helmets.build(); - builder.add(output); + builder.add(helmets.build()); builder.add(wills.build()); - inputs = builder.build(); - } - @Override - public void getIngredients(@Nonnull IIngredients ingredients) { - ingredients.setInputLists(VanillaTypes.ITEM, inputs); - ingredients.setOutputLists(VanillaTypes.ITEM, ImmutableList.of(output)); + ingredients.setInputLists(VanillaTypes.ITEM, builder.build()); + ingredients.setOutputLists(VanillaTypes.ITEM, ImmutableList.of(helmets.build())); } @Nullable @@ -65,9 +65,11 @@ public class AncientWillRecipeWrapper implements ICustomCraftingRecipeWrapper { if(focus != null) { ItemStack focused = (ItemStack) focus.getValue(); - if(focus.getMode() == IFocus.Mode.INPUT && focused.getItem() == ModItems.ancientWill) { - group.set(2, new ItemStack(ModItems.ancientWill, 1, focused.getMetadata())); - group.set(0, getHelmetsWithWill(focused.getMetadata())); + if(focus.getMode() == IFocus.Mode.INPUT && focused.getItem() instanceof ItemAncientWill) { + ItemStack copy = focused.copy(); + copy.setCount(1); + group.set(2, copy); + group.set(0, getHelmetsWithWill(((ItemAncientWill) focused.getItem()).type, ingredients)); } else if(focused.getItem() instanceof IAncientWillContainer) { //helmet group.set(1, new ItemStack(focused.getItem())); group.set(0, getWillsOnHelmet(focused.getItem())); @@ -75,11 +77,11 @@ public class AncientWillRecipeWrapper implements ICustomCraftingRecipeWrapper { } } - private List getHelmetsWithWill(int meta) { + private List getHelmetsWithWill(IAncientWillContainer.AncientWillType type, IIngredients ingredients) { ImmutableList.Builder builder = ImmutableList.builder(); - for(ItemStack itemStack : output) { + for(ItemStack itemStack : ingredients.getOutputs(VanillaTypes.ITEM).get(0)) { ItemStack toAdd = itemStack.copy(); - ((IAncientWillContainer) toAdd.getItem()).addAncientWill(toAdd, meta); + ((IAncientWillContainer) toAdd.getItem()).addAncientWill(toAdd, type); builder.add(toAdd); } return builder.build(); @@ -88,9 +90,9 @@ public class AncientWillRecipeWrapper implements ICustomCraftingRecipeWrapper { private List getWillsOnHelmet(Item item) { if(item instanceof IAncientWillContainer) { ImmutableList.Builder builder = ImmutableList.builder(); - for(int i = 0; i < 6; i++) { + for(IAncientWillContainer.AncientWillType type : IAncientWillContainer.AncientWillType.values()) { ItemStack stack = new ItemStack(item); - ((IAncientWillContainer) item).addAncientWill(stack, i); + ((IAncientWillContainer) item).addAncientWill(stack, type); builder.add(stack); } return builder.build(); diff --git a/src/main/java/vazkii/botania/client/integration/jei/crafting/CompositeLensRecipeWrapper.java b/src/main/java/vazkii/botania/client/integration/jei/crafting/CompositeLensRecipeWrapper.java new file mode 100644 index 000000000..878a37eae --- /dev/null +++ b/src/main/java/vazkii/botania/client/integration/jei/crafting/CompositeLensRecipeWrapper.java @@ -0,0 +1,87 @@ +package vazkii.botania.client.integration.jei.crafting; + +import com.google.common.collect.ImmutableList; +import mezz.jei.api.constants.VanillaTypes; +import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.recipe.category.extensions.vanilla.crafting.ICustomCraftingCategoryExtension; +import net.minecraft.init.Items; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tags.ItemTags; +import net.minecraft.util.NonNullList; +import net.minecraft.util.ResourceLocation; +import vazkii.botania.common.crafting.recipe.CompositeLensRecipe; +import vazkii.botania.common.item.ModItems; +import vazkii.botania.common.item.lens.ItemLens; +import vazkii.botania.common.lib.LibMisc; + +import javax.annotation.Nonnull; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +public class CompositeLensRecipeWrapper implements ICustomCraftingCategoryExtension { + private final List> inputs; + private final List lenses; + + public CompositeLensRecipeWrapper(CompositeLensRecipe recipe) { + List lensStacks = ItemTags.getCollection().getOrCreate(new ResourceLocation(LibMisc.MOD_ID, "lens")) + .getAllElements().stream() + .map(ItemStack::new) + .filter(s -> !((ItemLens) s.getItem()).isControlLens(s)) + .filter(s -> ((ItemLens) s.getItem()).isCombinable(s)) + .collect(Collectors.toList()); + lenses = lensStacks.stream().map(ItemStack::getItem).collect(Collectors.toList()); + inputs = ImmutableList.of(lensStacks, ImmutableList.of(new ItemStack(Items.SLIME_BALL)), lensStacks); + } + + @Override + public void setIngredients(@Nonnull IIngredients ingredients) { + ingredients.setInputLists(VanillaTypes.ITEM, inputs); + } + + @Override + public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IIngredients ingredients) { + recipeLayout.getItemStacks().set(ingredients); + recipeLayout.setShapeless(); + if(recipeLayout.getFocus() != null) { + ItemStack stack = (ItemStack) recipeLayout.getFocus().getValue(); + int idx = lenses.indexOf(stack.getItem()); + if(idx != -1) { + setLenses(recipeLayout, idx, idx); + return; + } + } + setLenses(recipeLayout, 1, lenses.size() - 1); + } + + private void setLenses(IRecipeLayout recipeLayout, int start, int end) { + List firstInput = new ArrayList<>(); + List secondInput = new ArrayList<>(); + List outputs = new ArrayList<>(); + + if(end >= lenses.size()) + end = lenses.size() - 1; + + for(int i = start; i <= end; i++) { + ItemStack firstLens = new ItemStack(lenses.get(i)); + for(Item secondLens : lenses) { + if(secondLens == firstLens.getItem()) + continue; + + ItemStack secondLensStack = new ItemStack(secondLens); + if(((ItemLens) firstLens.getItem()).canCombineLenses(firstLens, secondLensStack)) { + firstInput.add(firstLens); + secondInput.add(secondLensStack); + outputs.add(((ItemLens) firstLens.getItem()).setCompositeLens(firstLens.copy(), secondLensStack)); + } + } + + } + recipeLayout.getItemStacks().set(1, firstInput); + recipeLayout.getItemStacks().set(3, secondInput); + recipeLayout.getItemStacks().set(0, outputs); + } + +} diff --git a/src_disabled/main/java/vazkii/botania/client/integration/jei/crafting/SpecialFloatingFlowerWrapper.java b/src/main/java/vazkii/botania/client/integration/jei/crafting/SpecialFloatingFlowerWrapper.java similarity index 74% rename from src_disabled/main/java/vazkii/botania/client/integration/jei/crafting/SpecialFloatingFlowerWrapper.java rename to src/main/java/vazkii/botania/client/integration/jei/crafting/SpecialFloatingFlowerWrapper.java index 648f4f8d0..65dbe53c3 100644 --- a/src_disabled/main/java/vazkii/botania/client/integration/jei/crafting/SpecialFloatingFlowerWrapper.java +++ b/src/main/java/vazkii/botania/client/integration/jei/crafting/SpecialFloatingFlowerWrapper.java @@ -1,9 +1,9 @@ package vazkii.botania.client.integration.jei.crafting; import com.google.common.collect.ImmutableList; +import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.ingredients.IIngredients; -import mezz.jei.api.ingredients.VanillaTypes; -import mezz.jei.api.recipe.wrapper.ICraftingRecipeWrapper; +import mezz.jei.api.recipe.category.extensions.vanilla.crafting.ICraftingCategoryExtension; import net.minecraft.item.EnumDyeColor; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; @@ -16,24 +16,24 @@ import javax.annotation.Nullable; import java.util.ArrayList; import java.util.List; -public class SpecialFloatingFlowerWrapper implements ICraftingRecipeWrapper { +public class SpecialFloatingFlowerWrapper implements ICraftingCategoryExtension { private final List> inputs = new ArrayList<>(); private final ItemStack output; private final ResourceLocation name; public SpecialFloatingFlowerWrapper(SpecialFloatingFlowerRecipe recipe) { - name = recipe.getRegistryName(); - inputs.add(ImmutableList.of(ItemBlockSpecialFlower.ofType(recipe.type))); + name = recipe.getId(); + inputs.add(ImmutableList.of(ItemBlockSpecialFlower.ofType(recipe.flowerType))); List normalFloaters = new ArrayList<>(); for(EnumDyeColor color : EnumDyeColor.values()) { - normalFloaters.add(new ItemStack(ModBlocks.floatingFlower, 1, color.getMetadata())); + normalFloaters.add(new ItemStack(ModBlocks.getFloatingFlower(color))); } inputs.add(normalFloaters); - output = ItemBlockSpecialFlower.ofType(new ItemStack(ModBlocks.floatingSpecialFlower), recipe.type); + output = ItemBlockSpecialFlower.ofType(new ItemStack(ModBlocks.floatingSpecialFlower), recipe.flowerType); } @Override - public void getIngredients(@Nonnull IIngredients ingredients) { + public void setIngredients(@Nonnull IIngredients ingredients) { ingredients.setInputLists(VanillaTypes.ITEM, inputs); ingredients.setOutput(VanillaTypes.ITEM, output); } diff --git a/src_disabled/main/java/vazkii/botania/client/integration/jei/crafting/TerraPickTippingRecipeWrapper.java b/src/main/java/vazkii/botania/client/integration/jei/crafting/TerraPickTippingRecipeWrapper.java similarity index 78% rename from src_disabled/main/java/vazkii/botania/client/integration/jei/crafting/TerraPickTippingRecipeWrapper.java rename to src/main/java/vazkii/botania/client/integration/jei/crafting/TerraPickTippingRecipeWrapper.java index 053b1d43c..a6f67c756 100644 --- a/src_disabled/main/java/vazkii/botania/client/integration/jei/crafting/TerraPickTippingRecipeWrapper.java +++ b/src/main/java/vazkii/botania/client/integration/jei/crafting/TerraPickTippingRecipeWrapper.java @@ -1,9 +1,9 @@ package vazkii.botania.client.integration.jei.crafting; import com.google.common.collect.ImmutableList; +import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.ingredients.IIngredients; -import mezz.jei.api.ingredients.VanillaTypes; -import mezz.jei.api.recipe.wrapper.ICraftingRecipeWrapper; +import mezz.jei.api.recipe.category.extensions.vanilla.crafting.ICraftingCategoryExtension; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import vazkii.botania.common.crafting.recipe.TerraPickTippingRecipe; @@ -14,7 +14,7 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.util.List; -public class TerraPickTippingRecipeWrapper implements ICraftingRecipeWrapper { +public class TerraPickTippingRecipeWrapper implements ICraftingCategoryExtension { private final List> inputs; private final ItemStack output; private final ResourceLocation name; @@ -24,11 +24,11 @@ public class TerraPickTippingRecipeWrapper implements ICraftingRecipeWrapper { output = new ItemStack(ModItems.terraPick); ItemTerraPick.setTipped(output); - this.name = recipe.getRegistryName(); + this.name = recipe.getId(); } @Override - public void getIngredients(@Nonnull IIngredients ingredients) { + public void setIngredients(@Nonnull IIngredients ingredients) { ingredients.setInputLists(VanillaTypes.ITEM, inputs); ingredients.setOutput(VanillaTypes.ITEM, output); } diff --git a/src_disabled/main/java/vazkii/botania/client/integration/jei/elventrade/ElvenTradeRecipeCategory.java b/src/main/java/vazkii/botania/client/integration/jei/elventrade/ElvenTradeRecipeCategory.java similarity index 66% rename from src_disabled/main/java/vazkii/botania/client/integration/jei/elventrade/ElvenTradeRecipeCategory.java rename to src/main/java/vazkii/botania/client/integration/jei/elventrade/ElvenTradeRecipeCategory.java index fb383d7c2..9371c8c39 100644 --- a/src_disabled/main/java/vazkii/botania/client/integration/jei/elventrade/ElvenTradeRecipeCategory.java +++ b/src/main/java/vazkii/botania/client/integration/jei/elventrade/ElvenTradeRecipeCategory.java @@ -8,12 +8,13 @@ */ package vazkii.botania.client.integration.jei.elventrade; -import mezz.jei.api.IGuiHelper; -import mezz.jei.api.gui.IDrawable; +import com.google.common.collect.ImmutableList; +import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.gui.drawable.IDrawable; +import mezz.jei.api.helpers.IGuiHelper; import mezz.jei.api.ingredients.IIngredients; -import mezz.jei.api.ingredients.VanillaTypes; -import mezz.jei.api.recipe.IRecipeCategory; +import mezz.jei.api.recipe.category.IRecipeCategory; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.BufferBuilder; import net.minecraft.client.renderer.GlStateManager; @@ -23,33 +24,45 @@ import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.resources.I18n; import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; +import vazkii.botania.api.recipe.RecipeElvenTrade; import vazkii.botania.client.core.handler.MiscellaneousIcons; +import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; +import java.util.Arrays; import java.util.List; -public class ElvenTradeRecipeCategory implements IRecipeCategory { +public class ElvenTradeRecipeCategory implements IRecipeCategory { - public static final String UID = "botania.elvenTrade"; + public static final ResourceLocation UID = new ResourceLocation(LibMisc.MOD_ID, "elven_trade"); private final String localizedName; private final IDrawable background; private final IDrawable overlay; + private final IDrawable icon; public ElvenTradeRecipeCategory(IGuiHelper guiHelper) { localizedName = I18n.format("botania.nei.elvenTrade"); background = guiHelper.createBlankDrawable(145, 95); overlay = guiHelper.createDrawable(new ResourceLocation("botania", "textures/gui/elvenTradeOverlay.png"), 0, 15, 140, 90); + icon = guiHelper.createDrawableIngredient(new ItemStack(ModBlocks.alfPortal)); } @Nonnull @Override - public String getUid() { + public ResourceLocation getUid() { return UID; } + @Nonnull + @Override + public Class getRecipeClass() { + return RecipeElvenTrade.class; + } + @Nonnull @Override public String getTitle() { @@ -62,15 +75,31 @@ public class ElvenTradeRecipeCategory implements IRecipeCategory> builder = ImmutableList.builder(); + for(Ingredient i : recipe.getInputs()) { + builder.add(Arrays.asList(i.getMatchingStacks())); + } + iIngredients.setInputLists(VanillaTypes.ITEM, builder.build()); + iIngredients.setOutputs(VanillaTypes.ITEM, ImmutableList.copyOf(recipe.getOutputs())); + } + + @Override + public void draw(RecipeElvenTrade recipe, double mouseX, double mouseY) { + GlStateManager.enableAlphaTest(); + GlStateManager.enableBlend(); + overlay.draw(0, 4); + GlStateManager.disableBlend(); + GlStateManager.disableAlphaTest(); + + Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); TextureAtlasSprite sprite = MiscellaneousIcons.INSTANCE.alfPortalTex; Tessellator tess = Tessellator.getInstance(); BufferBuilder wr = tess.getBuffer(); @@ -87,7 +116,7 @@ public class ElvenTradeRecipeCategory implements IRecipeCategory o : ingredients.getInputs(VanillaTypes.ITEM)) { recipeLayout.getItemStacks().init(index, true, posX, 0); @@ -102,11 +131,4 @@ public class ElvenTradeRecipeCategory implements IRecipeCategory { +public class ManaPoolRecipeCategory implements IRecipeCategory { - public static final String UID = "botania.manaPool"; + public static final ResourceLocation UID = new ResourceLocation(LibMisc.MOD_ID, "mana_pool"); private final IDrawable background; private final String localizedName; private final IDrawable overlay; + private final IDrawable icon; private final ItemStack renderStack = new ItemStack(ModBlocks.manaPool); public ManaPoolRecipeCategory(IGuiHelper guiHelper) { @@ -41,15 +50,22 @@ public class ManaPoolRecipeCategory implements IRecipeCategory getRecipeClass() { + return RecipeManaInfusion.class; + } + @Nonnull @Override public String getTitle() { @@ -62,23 +78,41 @@ public class ManaPoolRecipeCategory implements IRecipeCategory> builder = ImmutableList.builder(); + + builder.add(Arrays.asList(recipe.getInput().getMatchingStacks())); + + if(recipe.getCatalyst() != null) { + Block block = recipe.getCatalyst().getBlock(); + if (block.asItem() != Items.AIR) { + builder.add(ImmutableList.of(new ItemStack(block))); + } + } + + iIngredients.setInputLists(VanillaTypes.ITEM, builder.build()); + iIngredients.setOutput(VanillaTypes.ITEM, recipe.getOutput()); + } + + @Override + public void draw(RecipeManaInfusion recipe, double mouseX, double mouseY) { + GlStateManager.enableAlphaTest(); GlStateManager.enableBlend(); - overlay.draw(minecraft, 48, 0); + overlay.draw(48, 0); + HUDHandler.renderManaBar(28, 50, 0x0000FF, 0.75F, recipe.getManaToConsume(), TilePool.MAX_MANA / 10); GlStateManager.disableBlend(); - GlStateManager.disableAlpha(); + GlStateManager.disableAlphaTest(); } @Override - public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull ManaPoolRecipeWrapper recipeWrapper, @Nonnull IIngredients ingredients) { + public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull RecipeManaInfusion recipe, @Nonnull IIngredients ingredients) { int index = 0; recipeLayout.getItemStacks().init(index, true, 40, 12); @@ -100,17 +134,4 @@ public class ManaPoolRecipeCategory implements IRecipeCategory getTooltipStrings(int mouseX, int mouseY) { - return new ArrayList<>(); - } - - @Nonnull - @Override - public String getModName() { - return LibMisc.MOD_NAME; - } - } diff --git a/src_disabled/main/java/vazkii/botania/client/integration/jei/orechid/OrechidIgnemRecipeCategory.java b/src/main/java/vazkii/botania/client/integration/jei/orechid/OrechidIgnemRecipeCategory.java similarity index 66% rename from src_disabled/main/java/vazkii/botania/client/integration/jei/orechid/OrechidIgnemRecipeCategory.java rename to src/main/java/vazkii/botania/client/integration/jei/orechid/OrechidIgnemRecipeCategory.java index 1f586543d..e46e882cb 100644 --- a/src_disabled/main/java/vazkii/botania/client/integration/jei/orechid/OrechidIgnemRecipeCategory.java +++ b/src/main/java/vazkii/botania/client/integration/jei/orechid/OrechidIgnemRecipeCategory.java @@ -8,18 +8,18 @@ */ package vazkii.botania.client.integration.jei.orechid; -import mezz.jei.api.IGuiHelper; -import mezz.jei.api.gui.IDrawable; -import mezz.jei.api.gui.IDrawableStatic; -import mezz.jei.api.gui.IGuiItemStackGroup; +import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.gui.drawable.IDrawable; +import mezz.jei.api.gui.drawable.IDrawableStatic; +import mezz.jei.api.gui.ingredient.IGuiItemStackGroup; +import mezz.jei.api.helpers.IGuiHelper; import mezz.jei.api.ingredients.IIngredients; -import mezz.jei.api.ingredients.VanillaTypes; -import mezz.jei.api.recipe.IRecipeCategory; -import net.minecraft.client.Minecraft; +import mezz.jei.api.recipe.category.IRecipeCategory; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.resources.I18n; import net.minecraft.util.ResourceLocation; +import vazkii.botania.common.block.ModSubtiles; import vazkii.botania.common.item.block.ItemBlockSpecialFlower; import vazkii.botania.common.lib.LibBlockNames; import vazkii.botania.common.lib.LibMisc; @@ -28,24 +28,32 @@ import javax.annotation.Nonnull; public class OrechidIgnemRecipeCategory implements IRecipeCategory { - public static final String UID = "botania.orechid_ignem"; + public static final ResourceLocation UID = new ResourceLocation(LibMisc.MOD_ID, "orechid_ignem"); private final IDrawableStatic background; private final String localizedName; private final IDrawableStatic overlay; + private final IDrawable icon; public OrechidIgnemRecipeCategory(IGuiHelper guiHelper) { background = guiHelper.createBlankDrawable(168, 64); localizedName = I18n.format("botania.nei.orechidIgnem"); overlay = guiHelper.createDrawable(new ResourceLocation("botania", "textures/gui/pureDaisyOverlay.png"), 0, 0, 64, 46); + icon = guiHelper.createDrawableIngredient(ItemBlockSpecialFlower.ofType(ModSubtiles.orechidIgnem)); } @Nonnull @Override - public String getUid() { + public ResourceLocation getUid() { return UID; } + @Nonnull + @Override + public Class getRecipeClass() { + return OrechidIgnemRecipeWrapper.class; + } + @Nonnull @Override public String getTitle() { @@ -58,6 +66,17 @@ public class OrechidIgnemRecipeCategory implements IRecipeCategory entry) { + public OrechidIgnemRecipeWrapper(Map.Entry entry) { super(entry); } - @Override - protected ItemStack getInputStack() { - return new ItemStack(Blocks.NETHERRACK, 64); - } - - public Map getOreWeights() { - return BotaniaAPI.oreWeightsNether; - } - } diff --git a/src/main/java/vazkii/botania/client/integration/jei/orechid/OrechidRecipeCategory.java b/src/main/java/vazkii/botania/client/integration/jei/orechid/OrechidRecipeCategory.java new file mode 100644 index 000000000..f2a8b6cf5 --- /dev/null +++ b/src/main/java/vazkii/botania/client/integration/jei/orechid/OrechidRecipeCategory.java @@ -0,0 +1,136 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + *

+ * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php + */ +package vazkii.botania.client.integration.jei.orechid; + +import mezz.jei.api.constants.VanillaTypes; +import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.gui.drawable.IDrawable; +import mezz.jei.api.gui.drawable.IDrawableStatic; +import mezz.jei.api.gui.ingredient.IGuiItemStackGroup; +import mezz.jei.api.helpers.IGuiHelper; +import mezz.jei.api.ingredients.IIngredients; +import mezz.jei.api.recipe.category.IRecipeCategory; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.resources.I18n; +import net.minecraft.init.Blocks; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraft.tags.BlockTags; +import net.minecraft.util.ResourceLocation; +import vazkii.botania.api.BotaniaAPI; +import vazkii.botania.client.integration.jei.JEIBotaniaPlugin; +import vazkii.botania.common.block.ModSubtiles; +import vazkii.botania.common.item.block.ItemBlockSpecialFlower; +import vazkii.botania.common.lib.LibBlockNames; +import vazkii.botania.common.lib.LibMisc; + +import javax.annotation.Nonnull; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +public class OrechidRecipeCategory implements IRecipeCategory { + + public static final ResourceLocation UID = new ResourceLocation(LibMisc.MOD_ID, "orechid"); + private final IDrawableStatic background; + private final String localizedName; + private final IDrawableStatic overlay; + private final IDrawable icon; + + public OrechidRecipeCategory(IGuiHelper guiHelper) { + background = guiHelper.createBlankDrawable(168, 64); + localizedName = I18n.format("botania.nei.orechid"); + overlay = guiHelper.createDrawable(new ResourceLocation("botania", "textures/gui/pureDaisyOverlay.png"), + 0, 0, 64, 46); + icon = guiHelper.createDrawableIngredient(ItemBlockSpecialFlower.ofType(ModSubtiles.orechid)); + } + + @Nonnull + @Override + public ResourceLocation getUid() { + return UID; + } + + @Nonnull + @Override + public Class getRecipeClass() { + return OrechidRecipeWrapper.class; + } + + @Nonnull + @Override + public String getTitle() { + return localizedName; + } + + @Nonnull + @Override + public IDrawable getBackground() { + return background; + } + + @Nonnull + @Override + public IDrawable getIcon() { + return icon; + } + + @Override + public void setIngredients(OrechidRecipeWrapper recipe, IIngredients ingredients) { + ingredients.setInput(VanillaTypes.ITEM, new ItemStack(Blocks.STONE, 64)); + + final int myWeight = recipe.entry.getValue(); + final int amount = Math.max(1, Math.round((float) myWeight * 64 / getTotalOreWeight(BotaniaAPI.oreWeights, myWeight))); + + // Shouldn't ever return an empty list since the ore weight + // list is filtered to only have ores with ItemBlocks + List stackList = BlockTags.getCollection().getOrCreate(recipe.entry.getKey()) + .getAllElements() + .stream() + .filter(s -> s.asItem() != Items.AIR) + .map(ItemStack::new) + .collect(Collectors.toList()); + + stackList.forEach(s -> s.setCount(amount)); + ingredients.setOutputLists(VanillaTypes.ITEM, Collections.singletonList(stackList)); + } + + public static float getTotalOreWeight(Map weights, int myWeight) { + return (weights.entrySet().stream() + .filter(e -> JEIBotaniaPlugin.doesOreExist(e.getKey())) + .map(Map.Entry::getValue) + .reduce(Integer::sum)).orElse(myWeight * 64 * 64); + } + + @Override + public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull OrechidRecipeWrapper recipeWrapper, @Nonnull IIngredients ingredients) { + final IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks(); + + itemStacks.init(0, true, 40, 12); + itemStacks.set(0, ingredients.getInputs(VanillaTypes.ITEM).get(0)); + + itemStacks.init(1, true, 70, 12); + itemStacks.set(1, ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ORECHID)); + + itemStacks.init(2, true, 99, 12); + itemStacks.set(2, ingredients.getOutputs(VanillaTypes.ITEM).get(0)); + } + + @Override + public void draw(OrechidRecipeWrapper recipe, double mouseX, double mouseY) { + GlStateManager.enableAlphaTest(); + GlStateManager.enableBlend(); + overlay.draw(48, 0); + GlStateManager.disableBlend(); + GlStateManager.disableAlphaTest(); + } + +} diff --git a/src/main/java/vazkii/botania/client/integration/jei/orechid/OrechidRecipeWrapper.java b/src/main/java/vazkii/botania/client/integration/jei/orechid/OrechidRecipeWrapper.java new file mode 100644 index 000000000..268f959cb --- /dev/null +++ b/src/main/java/vazkii/botania/client/integration/jei/orechid/OrechidRecipeWrapper.java @@ -0,0 +1,30 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + *

+ * Botania is Open Source and distributed under the + * Botania License: http://botaniamod.net/license.php + */ +package vazkii.botania.client.integration.jei.orechid; + +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; + +import javax.annotation.Nonnull; +import java.util.Map; + +// This only exists to hold the map entry +public class OrechidRecipeWrapper implements Comparable { + public final Map.Entry entry; + + public OrechidRecipeWrapper(Map.Entry entry) { + this.entry = entry; + } + + @Override + public int compareTo(@Nonnull OrechidRecipeWrapper o) { + return Integer.compare(o.entry.getValue(), entry.getValue()); + } +} diff --git a/src_disabled/main/java/vazkii/botania/client/integration/jei/petalapothecary/PetalApothecaryRecipeCategory.java b/src/main/java/vazkii/botania/client/integration/jei/petalapothecary/PetalApothecaryRecipeCategory.java similarity index 67% rename from src_disabled/main/java/vazkii/botania/client/integration/jei/petalapothecary/PetalApothecaryRecipeCategory.java rename to src/main/java/vazkii/botania/client/integration/jei/petalapothecary/PetalApothecaryRecipeCategory.java index 5fdecdd54..b5a98e3ee 100644 --- a/src_disabled/main/java/vazkii/botania/client/integration/jei/petalapothecary/PetalApothecaryRecipeCategory.java +++ b/src/main/java/vazkii/botania/client/integration/jei/petalapothecary/PetalApothecaryRecipeCategory.java @@ -8,48 +8,57 @@ */ package vazkii.botania.client.integration.jei.petalapothecary; -import mezz.jei.api.IGuiHelper; -import mezz.jei.api.gui.IDrawable; -import mezz.jei.api.gui.IDrawableStatic; +import mezz.jei.api.constants.VanillaTypes; import mezz.jei.api.gui.IRecipeLayout; +import mezz.jei.api.gui.drawable.IDrawable; +import mezz.jei.api.gui.drawable.IDrawableStatic; +import mezz.jei.api.helpers.IGuiHelper; 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 mezz.jei.api.recipe.category.IRecipeCategory; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.resources.I18n; import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.Ingredient; import net.minecraft.util.ResourceLocation; +import vazkii.botania.api.recipe.RecipePetals; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; -import javax.annotation.Nullable; import java.awt.Point; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; -public class PetalApothecaryRecipeCategory implements IRecipeCategory { +public class PetalApothecaryRecipeCategory implements IRecipeCategory { - public static final String UID = "botania.petals"; + public static final ResourceLocation UID = new ResourceLocation(LibMisc.MOD_ID, "petals"); private final IDrawableStatic background; private final String localizedName; private final IDrawableStatic overlay; + private final IDrawable icon; public PetalApothecaryRecipeCategory(IGuiHelper guiHelper) { background = guiHelper.createBlankDrawable(150, 110); localizedName = I18n.format("botania.nei.petalApothecary"); overlay = guiHelper.createDrawable(new ResourceLocation("botania", "textures/gui/petalOverlay.png"), 0, 0, 150, 110); + icon = guiHelper.createDrawableIngredient(new ItemStack(ModBlocks.defaultAltar)); } @Nonnull @Override - public String getUid() { + public ResourceLocation getUid() { return UID; } + @Nonnull + @Override + public Class getRecipeClass() { + return RecipePetals.class; + } + @Nonnull @Override public String getTitle() { @@ -62,17 +71,33 @@ public class PetalApothecaryRecipeCategory implements IRecipeCategory> list = new ArrayList<>(); + for(Ingredient ingr : recipe.getInputs()) { + list.add(Arrays.asList(ingr.getMatchingStacks())); + } + iIngredients.setInputLists(VanillaTypes.ITEM, list); + iIngredients.setOutput(VanillaTypes.ITEM, recipe.getOutput()); + } + + @Override + public void draw(RecipePetals recipe, double mouseX, double mouseY) { + GlStateManager.enableAlphaTest(); + GlStateManager.enableBlend(); + overlay.draw(); + GlStateManager.disableBlend(); + GlStateManager.disableAlphaTest(); + } + + @Override + public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull RecipePetals recipe, @Nonnull IIngredients ingredients) { recipeLayout.getItemStacks().init(0, true, 64, 52); recipeLayout.getItemStacks().set(0, new ItemStack(ModBlocks.defaultAltar)); @@ -97,11 +122,4 @@ public class PetalApothecaryRecipeCategory implements IRecipeCategory { +public class PureDaisyRecipeCategory implements IRecipeCategory { - public static final String UID = "botania.pureDaisy"; + public static final ResourceLocation UID = new ResourceLocation(LibMisc.MOD_ID, "pure_daisy"); private final IDrawable background; private final String localizedName; private final IDrawable overlay; + private final IDrawable icon; public PureDaisyRecipeCategory(IGuiHelper guiHelper) { background = guiHelper.createBlankDrawable(168, 64); localizedName = I18n.format("botania.nei.pureDaisy"); overlay = guiHelper.createDrawable(new ResourceLocation("botania", "textures/gui/pureDaisyOverlay.png"), 0, 0, 64, 46); + icon = guiHelper.createDrawableIngredient(ItemBlockSpecialFlower.ofType(ModSubtiles.pureDaisy)); } @Nonnull @Override - public String getUid() { + public ResourceLocation getUid() { return UID; } + @Nonnull + @Override + public Class getRecipeClass() { + return RecipePureDaisy.class; + } + @Nonnull @Override public String getTitle() { @@ -62,17 +73,49 @@ public class PureDaisyRecipeCategory implements IRecipeCategory all = ((Tag) recipe.getInput()).getAllElements(); + iIngredients.setInputs(VanillaTypes.ITEM, all.stream().map(ItemStack::new).filter(ItemStack::isEmpty).collect(Collectors.toList())); + } else if(recipe.getInput() instanceof Block || recipe.getInput() instanceof IBlockState) { + IBlockState state = recipe.getInput() instanceof IBlockState ? (IBlockState) recipe.getInput() : ((Block) recipe.getInput()).getDefaultState(); + Block b = state.getBlock(); + + // todo 1.13 fluids + //if(FluidRegistry.lookupFluidForBlock(b) != null) { + // iIngredients.setInput(VanillaTypes.FLUID, new FluidStack(FluidRegistry.lookupFluidForBlock(b), 1000)); + //} else { + iIngredients.setInput(VanillaTypes.ITEM, new ItemStack(b)); + //} + } + + Block outBlock = recipe.getOutputState().getBlock(); + // todo 1.13 fluids + //if(FluidRegistry.lookupFluidForBlock(outBlock) != null) { + // iIngredients.setOutput(VanillaTypes.FLUID, new FluidStack(FluidRegistry.lookupFluidForBlock(outBlock), 1000)); + //} else { + iIngredients.setOutput(VanillaTypes.ITEM, new ItemStack(outBlock)); + //} + } + + @Override + public void draw(RecipePureDaisy recipe, double mouseX, double mouseY) { + GlStateManager.enableAlphaTest(); + GlStateManager.enableBlend(); + overlay.draw(48, 0); + GlStateManager.disableBlend(); + GlStateManager.disableAlphaTest(); + } + + @Override + public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull RecipePureDaisy recipe, @Nonnull IIngredients ingredients) { boolean inputFluid = !ingredients.getInputs(VanillaTypes.FLUID).isEmpty(); boolean outputFluid = !ingredients.getOutputs(VanillaTypes.FLUID).isEmpty(); @@ -95,11 +138,4 @@ public class PureDaisyRecipeCategory implements IRecipeCategory { +public class RunicAltarRecipeCategory implements IRecipeCategory { - public static final String UID = "botania.runicAltar"; + public static final ResourceLocation UID = new ResourceLocation(LibMisc.MOD_ID, "runic_altar"); private final IDrawable background; private final String localizedName; private final IDrawable overlay; + private final IDrawable icon; public RunicAltarRecipeCategory(IGuiHelper guiHelper) { background = guiHelper.createBlankDrawable(150, 110); localizedName = I18n.format("botania.nei.runicAltar"); overlay = guiHelper.createDrawable(new ResourceLocation("botania", "textures/gui/petalOverlay.png"), 0, 0, 150, 110); + icon = guiHelper.createDrawableIngredient(new ItemStack(ModBlocks.runeAltar)); } @Nonnull @Override - public String getUid() { + public ResourceLocation getUid() { return UID; } + @Nonnull + @Override + public Class getRecipeClass() { + return RecipeRuneAltar.class; + } + @Nonnull @Override public String getTitle() { @@ -58,17 +73,34 @@ public class RunicAltarRecipeCategory implements IRecipeCategory> list = new ArrayList<>(); + for(Ingredient ingr : recipe.getInputs()) { + list.add(Arrays.asList(ingr.getMatchingStacks())); + } + iIngredients.setInputLists(VanillaTypes.ITEM, list); + iIngredients.setOutput(VanillaTypes.ITEM, recipe.getOutput()); + } + + @Override + public void draw(RecipeRuneAltar recipe, double mouseX, double mouseY) { + GlStateManager.enableAlphaTest(); + GlStateManager.enableBlend(); + overlay.draw(); + HUDHandler.renderManaBar(28, 113, 0x0000FF, 0.75F, recipe.getManaUsage(), TilePool.MAX_MANA / 10); + GlStateManager.disableBlend(); + GlStateManager.disableAlphaTest(); + } + + @Override + public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull RecipeRuneAltar recipe, @Nonnull IIngredients ingredients) { recipeLayout.getItemStacks().init(0, true, 64, 52); recipeLayout.getItemStacks().set(0, new ItemStack(ModBlocks.runeAltar)); @@ -95,10 +127,4 @@ public class RunicAltarRecipeCategory implements IRecipeCategory. It's distributed as - * part of the Botania Mod. Get the Source Code in github: - * https://github.com/Vazkii/Botania - *

- * Botania is Open Source and distributed under the - * Botania License: http://botaniamod.net/license.php - */ -package vazkii.botania.client.integration.jei.brewery; - -import com.google.common.collect.ImmutableList; -import mezz.jei.api.ingredients.IIngredients; -import mezz.jei.api.ingredients.VanillaTypes; -import mezz.jei.api.recipe.IRecipeWrapper; -import net.minecraft.item.ItemStack; -import net.minecraftforge.oredict.OreDictionary; -import vazkii.botania.api.recipe.RecipeBrew; -import vazkii.botania.common.item.ModItems; - -import javax.annotation.Nonnull; -import java.util.Arrays; -import java.util.List; - -public class BreweryRecipeWrapper implements IRecipeWrapper { - - private final List> input; - private final List output; - - private static final List inputs = Arrays.asList(new ItemStack(ModItems.vial), - new ItemStack(ModItems.flask), new ItemStack(ModItems.incenseStick), new ItemStack(ModItems.bloodPendant)); - - public BreweryRecipeWrapper(RecipeBrew recipeBrew) { - ImmutableList.Builder> inputBuilder = ImmutableList.builder(); - ImmutableList.Builder outputBuilder = ImmutableList.builder(); - ImmutableList.Builder containers = ImmutableList.builder(); - - for(ItemStack stack : inputs) { - ItemStack brewed = recipeBrew.getOutput(stack); - if(!brewed.isEmpty()) { - containers.add(stack); - outputBuilder.add(brewed); - } - } - inputBuilder.add(containers.build()); - - for(Object o : recipeBrew.getInputs()) { - if(o instanceof ItemStack) { - inputBuilder.add(ImmutableList.of((ItemStack) o)); - } - if(o instanceof String) { - inputBuilder.add(OreDictionary.getOres((String) o)); - } - } - - input = inputBuilder.build(); - output = outputBuilder.build(); - } - - @Override - public void getIngredients(@Nonnull IIngredients ingredients) { - ingredients.setInputLists(VanillaTypes.ITEM, input); - ingredients.setOutputLists(VanillaTypes.ITEM, ImmutableList.of(output)); - } -} diff --git a/src_disabled/main/java/vazkii/botania/client/integration/jei/crafting/CompositeLensRecipeWrapper.java b/src_disabled/main/java/vazkii/botania/client/integration/jei/crafting/CompositeLensRecipeWrapper.java deleted file mode 100644 index 3a3003dcd..000000000 --- a/src_disabled/main/java/vazkii/botania/client/integration/jei/crafting/CompositeLensRecipeWrapper.java +++ /dev/null @@ -1,81 +0,0 @@ -package vazkii.botania.client.integration.jei.crafting; - -import com.google.common.collect.ImmutableList; -import mezz.jei.api.gui.IRecipeLayout; -import mezz.jei.api.ingredients.IIngredients; -import mezz.jei.api.ingredients.VanillaTypes; -import mezz.jei.api.recipe.wrapper.ICustomCraftingRecipeWrapper; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.util.NonNullList; -import vazkii.botania.common.item.ModItems; -import vazkii.botania.common.item.lens.ItemLens; - -import javax.annotation.Nonnull; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; - -public class CompositeLensRecipeWrapper implements ICustomCraftingRecipeWrapper { - private final List> inputs; - private static final List lenses; - - static { - NonNullList allLenses = NonNullList.create(); - ItemLens lens = (ItemLens) ModItems.lens; - lens.getSubItems(CreativeTabs.SEARCH, allLenses); - lenses = ImmutableList.copyOf(allLenses.stream().filter(stack -> !lens.isControlLens(stack)).filter(lens::isCombinable).collect(Collectors.toList())); - } - - public CompositeLensRecipeWrapper() { - inputs = ImmutableList.of(lenses, ImmutableList.of(new ItemStack(Items.SLIME_BALL)), lenses); - } - - @Override - public void getIngredients(@Nonnull IIngredients ingredients) { - ingredients.setInputLists(VanillaTypes.ITEM, inputs); - } - - @Override - public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IIngredients ingredients) { - recipeLayout.getItemStacks().set(ingredients); - recipeLayout.setShapeless(); - if(recipeLayout.getFocus() != null) { - ItemStack stack = (ItemStack) recipeLayout.getFocus().getValue(); - if(stack.getItem() == ModItems.lens) { - setLenses(recipeLayout, stack.getMetadata(), stack.getMetadata()); - return; - } - } - setLenses(recipeLayout, 1, ItemLens.SUBTYPES - 1); - } - - private void setLenses(IRecipeLayout recipeLayout, int start, int end) { - List firstInput = new ArrayList<>(); - List secondInput = new ArrayList<>(); - List outputs = new ArrayList<>(); - - if(end >= ItemLens.SUBTYPES) - end = ItemLens.SUBTYPES - 1; - - for(int i = start; i <= end; i++) { - ItemStack firstLens = new ItemStack(ModItems.lens, 1, i); - for(ItemStack secondLens : lenses) { - if(secondLens.getMetadata() == i) - continue; - - if(((ItemLens) ModItems.lens).canCombineLenses(firstLens, secondLens)) { - firstInput.add(firstLens); - secondInput.add(secondLens); - outputs.add(((ItemLens) ModItems.lens).setCompositeLens(firstLens.copy(), secondLens)); - } - } - - } - recipeLayout.getItemStacks().set(1, firstInput); - recipeLayout.getItemStacks().set(3, secondInput); - recipeLayout.getItemStacks().set(0, outputs); - } - -} diff --git a/src_disabled/main/java/vazkii/botania/client/integration/jei/elventrade/ElvenTradeRecipeWrapper.java b/src_disabled/main/java/vazkii/botania/client/integration/jei/elventrade/ElvenTradeRecipeWrapper.java deleted file mode 100644 index 160e308a3..000000000 --- a/src_disabled/main/java/vazkii/botania/client/integration/jei/elventrade/ElvenTradeRecipeWrapper.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: - * https://github.com/Vazkii/Botania - *

- * Botania is Open Source and distributed under the - * Botania License: http://botaniamod.net/license.php - */ -package vazkii.botania.client.integration.jei.elventrade; - -import com.google.common.collect.ImmutableList; -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.item.ItemStack; -import net.minecraftforge.oredict.OreDictionary; -import vazkii.botania.api.recipe.RecipeElvenTrade; - -import javax.annotation.Nonnull; -import java.util.List; - -public class ElvenTradeRecipeWrapper implements IRecipeWrapper { - - private final List> input; - private final List outputs; - - public ElvenTradeRecipeWrapper(RecipeElvenTrade recipe) { - ImmutableList.Builder> builder = ImmutableList.builder(); - for(Object o : recipe.getInputs()) { - if(o instanceof ItemStack) { - builder.add(ImmutableList.of((ItemStack) o)); - } - if(o instanceof String) { - builder.add(OreDictionary.getOres((String) o)); - } - } - input = builder.build(); - outputs = ImmutableList.copyOf(recipe.getOutputs()); - } - - @Override - public void getIngredients(@Nonnull IIngredients ingredients) { - ingredients.setInputLists(VanillaTypes.ITEM, input); - ingredients.setOutputs(VanillaTypes.ITEM, outputs); - } -} diff --git a/src_disabled/main/java/vazkii/botania/client/integration/jei/manapool/ManaPoolRecipeWrapper.java b/src_disabled/main/java/vazkii/botania/client/integration/jei/manapool/ManaPoolRecipeWrapper.java deleted file mode 100644 index d0cb9be1e..000000000 --- a/src_disabled/main/java/vazkii/botania/client/integration/jei/manapool/ManaPoolRecipeWrapper.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: - * https://github.com/Vazkii/Botania - *

- * Botania is Open Source and distributed under the - * Botania License: http://botaniamod.net/license.php - */ -package vazkii.botania.client.integration.jei.manapool; - -import com.google.common.collect.ImmutableList; -import mezz.jei.api.ingredients.IIngredients; -import mezz.jei.api.ingredients.VanillaTypes; -import mezz.jei.api.recipe.IRecipeWrapper; -import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraftforge.oredict.OreDictionary; -import vazkii.botania.api.recipe.RecipeManaInfusion; -import vazkii.botania.client.core.handler.HUDHandler; -import vazkii.botania.common.block.tile.mana.TilePool; - -import javax.annotation.Nonnull; -import java.util.List; - -public class ManaPoolRecipeWrapper implements IRecipeWrapper { - - private final List> input; - private final ItemStack output; - private final int mana; - - public ManaPoolRecipeWrapper(RecipeManaInfusion recipe) { - ImmutableList.Builder> builder = ImmutableList.builder(); - - if(recipe.getInput() instanceof ItemStack) { - builder.add(ImmutableList.of((ItemStack) recipe.getInput())); - } else if(recipe.getInput() instanceof String) { - builder.add(OreDictionary.getOres((String) recipe.getInput())); - } - - if(recipe.getCatalyst() != null) { - Block block = recipe.getCatalyst().getBlock(); - if (Item.getItemFromBlock(block) != Items.AIR) { - builder.add(ImmutableList.of(new ItemStack(block, 1, block.getMetaFromState(recipe.getCatalyst())))); - } - } - - input = builder.build(); - output = recipe.getOutput(); - mana = recipe.getManaToConsume(); - } - - @Override - public void getIngredients(@Nonnull IIngredients ingredients) { - ingredients.setInputLists(VanillaTypes.ITEM, input); - ingredients.setOutput(VanillaTypes.ITEM, output); - } - - @Override - public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) { - GlStateManager.enableAlpha(); - HUDHandler.renderManaBar(28, 50, 0x0000FF, 0.75F, mana, TilePool.MAX_MANA / 10); - GlStateManager.disableAlpha(); - } - - @Nonnull - @Override - public List getTooltipStrings(int mouseX, int mouseY) { - return ImmutableList.of(); - } - - @Override - public boolean handleClick(@Nonnull Minecraft minecraft, int mouseX, int mouseY, int mouseButton) { - return false; - } - -} diff --git a/src_disabled/main/java/vazkii/botania/client/integration/jei/orechid/OrechidRecipeCategory.java b/src_disabled/main/java/vazkii/botania/client/integration/jei/orechid/OrechidRecipeCategory.java deleted file mode 100644 index 653344e18..000000000 --- a/src_disabled/main/java/vazkii/botania/client/integration/jei/orechid/OrechidRecipeCategory.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: - * https://github.com/Vazkii/Botania - *

- * Botania is Open Source and distributed under the - * Botania License: http://botaniamod.net/license.php - */ -package vazkii.botania.client.integration.jei.orechid; - -import mezz.jei.api.IGuiHelper; -import mezz.jei.api.gui.IDrawable; -import mezz.jei.api.gui.IDrawableStatic; -import mezz.jei.api.gui.IGuiItemStackGroup; -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 net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.resources.I18n; -import net.minecraft.util.ResourceLocation; -import vazkii.botania.common.item.block.ItemBlockSpecialFlower; -import vazkii.botania.common.lib.LibBlockNames; -import vazkii.botania.common.lib.LibMisc; - -import javax.annotation.Nonnull; - -public class OrechidRecipeCategory implements IRecipeCategory { - - public static final String UID = "botania.orechid"; - private final IDrawableStatic background; - private final String localizedName; - private final IDrawableStatic overlay; - - public OrechidRecipeCategory(IGuiHelper guiHelper) { - background = guiHelper.createBlankDrawable(168, 64); - localizedName = I18n.format("botania.nei.orechid"); - overlay = guiHelper.createDrawable(new ResourceLocation("botania", "textures/gui/pureDaisyOverlay.png"), - 0, 0, 64, 46); - } - - @Nonnull - @Override - public String getUid() { - return UID; - } - - @Nonnull - @Override - public String getTitle() { - return localizedName; - } - - @Nonnull - @Override - public IDrawable getBackground() { - return background; - } - - - @Override - public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull OrechidRecipeWrapper recipeWrapper, @Nonnull IIngredients ingredients) { - final IGuiItemStackGroup itemStacks = recipeLayout.getItemStacks(); - - itemStacks.init(0, true, 40, 12); - itemStacks.set(0, ingredients.getInputs(VanillaTypes.ITEM).get(0)); - - itemStacks.init(1, true, 70, 12); - itemStacks.set(1, ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_ORECHID)); - - itemStacks.init(2, true, 99, 12); - itemStacks.set(2, ingredients.getOutputs(VanillaTypes.ITEM).get(0)); - } - - @Override - public void drawExtras(@Nonnull Minecraft minecraft) { - GlStateManager.enableAlpha(); - GlStateManager.enableBlend(); - overlay.draw(minecraft, 48, 0); - GlStateManager.disableBlend(); - GlStateManager.disableAlpha(); - } - - @Nonnull - @Override - public String getModName() { - return LibMisc.MOD_NAME; - } - -} diff --git a/src_disabled/main/java/vazkii/botania/client/integration/jei/orechid/OrechidRecipeWrapper.java b/src_disabled/main/java/vazkii/botania/client/integration/jei/orechid/OrechidRecipeWrapper.java deleted file mode 100644 index 498a8dfd7..000000000 --- a/src_disabled/main/java/vazkii/botania/client/integration/jei/orechid/OrechidRecipeWrapper.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: - * https://github.com/Vazkii/Botania - *

- * Botania is Open Source and distributed under the - * Botania License: http://botaniamod.net/license.php - */ -package vazkii.botania.client.integration.jei.orechid; - -import mezz.jei.api.ingredients.IIngredients; -import mezz.jei.api.ingredients.VanillaTypes; -import mezz.jei.api.recipe.IRecipeWrapper; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraftforge.oredict.OreDictionary; -import vazkii.botania.api.BotaniaAPI; - -import javax.annotation.Nonnull; -import java.util.Collections; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import static vazkii.botania.client.integration.jei.JEIBotaniaPlugin.doesOreExist; - -public class OrechidRecipeWrapper implements IRecipeWrapper, Comparable { - - private final int weight; - private final List> outputStacks; - - protected ItemStack getInputStack() { - return new ItemStack(Blocks.STONE, 64); - } - - public OrechidRecipeWrapper(Map.Entry entry) { - this.weight = entry.getValue(); - - final int amount = Math.max(1, Math.round((float) weight * 64 / getTotalOreWeight())); - - // Shouldn't ever return an empty list since the ore weight - // list is filtered to only have ores with ItemBlocks - List stackList = OreDictionary.getOres(entry.getKey()).stream() - .filter(s -> s.getItem() instanceof ItemBlock) - .map(ItemStack::copy) - .collect(Collectors.toList()); - - stackList.forEach(s -> s.setCount(amount)); - - outputStacks = Collections.singletonList(stackList); - } - - public Map getOreWeights() { - return BotaniaAPI.oreWeights; - } - - private float getTotalOreWeight() { - return (getOreWeights().entrySet().stream() - .filter(e -> doesOreExist(e.getKey())) - .map(Map.Entry::getValue) - .reduce(Integer::sum)).orElse(weight * 64 * 64); - } - - @Override - public void getIngredients(@Nonnull IIngredients ingredients) { - ingredients.setInput(VanillaTypes.ITEM, getInputStack()); - ingredients.setOutputLists(VanillaTypes.ITEM, outputStacks); - } - - @Override - public int compareTo(@Nonnull OrechidRecipeWrapper o) { - return Integer.compare(o.weight, weight); - } -} diff --git a/src_disabled/main/java/vazkii/botania/client/integration/jei/petalapothecary/PetalApothecaryRecipeWrapper.java b/src_disabled/main/java/vazkii/botania/client/integration/jei/petalapothecary/PetalApothecaryRecipeWrapper.java deleted file mode 100644 index 425da04cd..000000000 --- a/src_disabled/main/java/vazkii/botania/client/integration/jei/petalapothecary/PetalApothecaryRecipeWrapper.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: - * https://github.com/Vazkii/Botania - *

- * Botania is Open Source and distributed under the - * Botania License: http://botaniamod.net/license.php - */ -package vazkii.botania.client.integration.jei.petalapothecary; - -import com.google.common.collect.ImmutableList; -import mezz.jei.api.ingredients.IIngredients; -import mezz.jei.api.ingredients.VanillaTypes; -import mezz.jei.api.recipe.IRecipeWrapper; -import net.minecraft.item.ItemStack; -import net.minecraftforge.oredict.OreDictionary; -import vazkii.botania.api.recipe.RecipePetals; - -import javax.annotation.Nonnull; -import java.util.List; - -public class PetalApothecaryRecipeWrapper implements IRecipeWrapper { - - private final List> input; - private final ItemStack output; - - public PetalApothecaryRecipeWrapper(RecipePetals recipe) { - ImmutableList.Builder> builder = ImmutableList.builder(); - for(Object o : recipe.getInputs()) { - if(o instanceof ItemStack) { - builder.add(ImmutableList.of((ItemStack) o)); - } - if(o instanceof String) { - builder.add(OreDictionary.getOres((String) o)); - } - } - input = builder.build(); - output = recipe.getOutput(); - } - - @Override - public void getIngredients(@Nonnull IIngredients ingredients) { - ingredients.setInputLists(VanillaTypes.ITEM, input); - ingredients.setOutput(VanillaTypes.ITEM, output); - } - -} diff --git a/src_disabled/main/java/vazkii/botania/client/integration/jei/puredaisy/PureDaisyRecipeWrapper.java b/src_disabled/main/java/vazkii/botania/client/integration/jei/puredaisy/PureDaisyRecipeWrapper.java deleted file mode 100644 index 28583c235..000000000 --- a/src_disabled/main/java/vazkii/botania/client/integration/jei/puredaisy/PureDaisyRecipeWrapper.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: - * https://github.com/Vazkii/Botania - *

- * Botania is Open Source and distributed under the - * Botania License: http://botaniamod.net/license.php - */ -package vazkii.botania.client.integration.jei.puredaisy; - -import com.google.common.collect.ImmutableList; -import mezz.jei.api.ingredients.IIngredients; -import mezz.jei.api.ingredients.VanillaTypes; -import mezz.jei.api.recipe.IRecipeWrapper; -import net.minecraft.block.Block; -import net.minecraft.block.state.IBlockState; -import net.minecraft.client.Minecraft; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.oredict.OreDictionary; -import vazkii.botania.api.recipe.RecipePureDaisy; - -import javax.annotation.Nonnull; -import java.util.List; - -public class PureDaisyRecipeWrapper implements IRecipeWrapper { - - private List inputs = ImmutableList.of(); - private ItemStack output = ItemStack.EMPTY; - private FluidStack fluidInput = null; - private FluidStack fluidOutput = null; - - public PureDaisyRecipeWrapper(RecipePureDaisy recipe) { - if(recipe.getInput() instanceof String) { - inputs = ImmutableList.copyOf(OreDictionary.getOres((String) recipe.getInput())); - } else if(recipe.getInput() instanceof Block || recipe.getInput() instanceof IBlockState) { - IBlockState state = recipe.getInput() instanceof IBlockState ? (IBlockState) recipe.getInput() : ((Block) recipe.getInput()).getDefaultState(); - Block b = state.getBlock(); - - if(FluidRegistry.lookupFluidForBlock(b) != null) { - fluidInput = new FluidStack(FluidRegistry.lookupFluidForBlock(b), 1000); - } else { - inputs = ImmutableList.of(new ItemStack(b, 1, b.getMetaFromState(state))); - } - } - - Block outBlock = recipe.getOutputState().getBlock(); - if(FluidRegistry.lookupFluidForBlock(outBlock) != null) { - fluidOutput = new FluidStack(FluidRegistry.lookupFluidForBlock(outBlock), 1000); - } else { - output = new ItemStack(outBlock, 1, outBlock.getMetaFromState(recipe.getOutputState())); - } - } - - @Override - public void getIngredients(@Nonnull IIngredients ingredients) { - ingredients.setInputs(VanillaTypes.ITEM, inputs); - - if (fluidInput != null) { - ingredients.setInput(VanillaTypes.FLUID, fluidInput); - } - - if (!output.isEmpty()) { - ingredients.setOutput(VanillaTypes.ITEM, output); - } - - if (fluidOutput != null) { - ingredients.setOutput(VanillaTypes.FLUID, fluidOutput); - } - } - -} diff --git a/src_disabled/main/java/vazkii/botania/client/integration/jei/runicaltar/RunicAltarRecipeWrapper.java b/src_disabled/main/java/vazkii/botania/client/integration/jei/runicaltar/RunicAltarRecipeWrapper.java deleted file mode 100644 index 56c85735f..000000000 --- a/src_disabled/main/java/vazkii/botania/client/integration/jei/runicaltar/RunicAltarRecipeWrapper.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: - * https://github.com/Vazkii/Botania - *

- * Botania is Open Source and distributed under the - * Botania License: http://botaniamod.net/license.php - */ -package vazkii.botania.client.integration.jei.runicaltar; - -import com.google.common.collect.ImmutableList; -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.renderer.GlStateManager; -import net.minecraft.item.ItemStack; -import net.minecraftforge.oredict.OreDictionary; -import vazkii.botania.api.recipe.RecipeRuneAltar; -import vazkii.botania.client.core.handler.HUDHandler; -import vazkii.botania.common.block.tile.mana.TilePool; - -import javax.annotation.Nonnull; -import java.util.List; - -public class RunicAltarRecipeWrapper implements IRecipeWrapper { - - private final List> input; - private final ItemStack output; - private final int manaUsage; - - public RunicAltarRecipeWrapper(RecipeRuneAltar recipe) { - ImmutableList.Builder> builder = ImmutableList.builder(); - for(Object o : recipe.getInputs()) { - if(o instanceof ItemStack) { - builder.add(ImmutableList.of((ItemStack) o)); - } - if(o instanceof String) { - builder.add(OreDictionary.getOres((String) o)); - } - } - input = builder.build(); - output = recipe.getOutput(); - manaUsage = recipe.getManaUsage(); - } - - @Override - public void getIngredients(@Nonnull IIngredients ingredients) { - ingredients.setInputLists(VanillaTypes.ITEM, input); - ingredients.setOutput(VanillaTypes.ITEM, output); - } - - @Override - public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) { - GlStateManager.enableAlpha(); - HUDHandler.renderManaBar(28, 113, 0x0000FF, 0.75F, manaUsage, TilePool.MAX_MANA / 10); - GlStateManager.disableAlpha(); - } - -}