Move jei integration out temporarily for compiling, update mods.toml

This commit is contained in:
Vincent Lee committed 2019-07-01 20:37:48 -07:00
1 parent 5304645972
commit 633c3e7b4d
15 files changed
+1 -1

No files matched your search

@@ -1,195 +0,0 @@
/**
* This class was created by <williewillus>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
* <p/>
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*/
package vazkii.botania.client.integration.jei;
import mezz.jei.api.IModPlugin;
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.screen.inventory.ContainerScreen;
import net.minecraft.item.ItemStack;
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.RecipeElvenTrade;
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.crafting.AncientWillRecipeWrapper;
import vazkii.botania.client.integration.jei.crafting.CompositeLensRecipeWrapper;
import vazkii.botania.client.integration.jei.crafting.TerraPickTippingRecipeWrapper;
import vazkii.botania.client.integration.jei.elventrade.ElvenTradeRecipeCategory;
import vazkii.botania.client.integration.jei.manapool.ManaPoolRecipeCategory;
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.puredaisy.PureDaisyRecipeCategory;
import vazkii.botania.client.integration.jei.runicaltar.RunicAltarRecipeCategory;
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.TerraPickTippingRecipe;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.item.brew.ItemBrewBase;
import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
import java.util.List;
import java.util.stream.Collectors;
@JeiPlugin
public class JEIBotaniaPlugin implements IModPlugin {
private static final ResourceLocation ID = new ResourceLocation(LibMisc.MOD_ID, "main");
@Override
public void registerItemSubtypes(@Nonnull ISubtypeRegistration subtypeRegistry) {
subtypeRegistry.registerSubtypeInterpreter(ModItems.brewVial, ItemBrewBase::getSubtype);
subtypeRegistry.registerSubtypeInterpreter(ModItems.brewFlask, ItemBrewBase::getSubtype);
subtypeRegistry.registerSubtypeInterpreter(ModItems.incenseStick, ItemBrewBase::getSubtype);
subtypeRegistry.registerSubtypeInterpreter(ModItems.bloodPendant, ItemBrewBase::getSubtype);
}
@Override
public void registerCategories(IRecipeCategoryRegistration registry) {
registry.addRecipeCategories(
new BreweryRecipeCategory(registry.getJeiHelpers().getGuiHelper()),
new PureDaisyRecipeCategory(registry.getJeiHelpers().getGuiHelper()),
new RunicAltarRecipeCategory(registry.getJeiHelpers().getGuiHelper()), // Runic must come before petals. See williewillus/Botania#172
new PetalApothecaryRecipeCategory(registry.getJeiHelpers().getGuiHelper()),
new ElvenTradeRecipeCategory(registry.getJeiHelpers().getGuiHelper()),
new ManaPoolRecipeCategory(registry.getJeiHelpers().getGuiHelper()),
new OrechidRecipeCategory(registry.getJeiHelpers().getGuiHelper()),
new OrechidIgnemRecipeCategory(registry.getJeiHelpers().getGuiHelper())
);
}
public static boolean doesOreExist(ResourceLocation tagId) {
return !BlockTags.getCollection().getOrCreate(tagId).getAllElements().isEmpty();
}
@Override
public void registerVanillaCategoryExtensions(IVanillaCategoryExtensionRegistration registration) {
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.values(), ManaPoolRecipeCategory.UID);
registry.addRecipes(
BotaniaAPI.oreWeights.entrySet().stream()
.filter(e -> doesOreExist(e.getKey()))
.map(OrechidRecipeWrapper::new)
.sorted()
.collect(Collectors.toList()),
OrechidRecipeCategory.UID);
registry.addRecipes(
BotaniaAPI.oreWeightsNether.entrySet().stream()
.filter(e -> doesOreExist(e.getKey()))
.map(OrechidIgnemRecipeWrapper::new)
.sorted()
.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);
registry.addRecipeCatalyst(new ItemStack(ModBlocks.manaPool), ManaPoolRecipeCategory.UID);
registry.addRecipeCatalyst(new ItemStack(ModBlocks.creativePool), ManaPoolRecipeCategory.UID);
registry.addRecipeCatalyst(new ItemStack(ModBlocks.dilutedPool), ManaPoolRecipeCategory.UID);
registry.addRecipeCatalyst(new ItemStack(ModBlocks.fabulousPool), ManaPoolRecipeCategory.UID);
registry.addRecipeCatalyst(new ItemStack(ModBlocks.defaultAltar), PetalApothecaryRecipeCategory.UID);
registry.addRecipeCatalyst(new ItemStack(ModBlocks.forestAltar), PetalApothecaryRecipeCategory.UID);
registry.addRecipeCatalyst(new ItemStack(ModBlocks.plainsAltar), PetalApothecaryRecipeCategory.UID);
registry.addRecipeCatalyst(new ItemStack(ModBlocks.mountainAltar), PetalApothecaryRecipeCategory.UID);
registry.addRecipeCatalyst(new ItemStack(ModBlocks.fungalAltar), PetalApothecaryRecipeCategory.UID);
registry.addRecipeCatalyst(new ItemStack(ModBlocks.swampAltar), PetalApothecaryRecipeCategory.UID);
registry.addRecipeCatalyst(new ItemStack(ModBlocks.desertAltar), PetalApothecaryRecipeCategory.UID);
registry.addRecipeCatalyst(new ItemStack(ModBlocks.taigaAltar), PetalApothecaryRecipeCategory.UID);
registry.addRecipeCatalyst(new ItemStack(ModBlocks.mesaAltar), PetalApothecaryRecipeCategory.UID);
registry.addRecipeCatalyst(new ItemStack(ModBlocks.mossyAltar), PetalApothecaryRecipeCategory.UID);
registry.addRecipeCatalyst(new ItemStack(ModSubtiles.orechid), OrechidRecipeCategory.UID);
registry.addRecipeCatalyst(new ItemStack(ModSubtiles.orechidFloating), OrechidRecipeCategory.UID);
registry.addRecipeCatalyst(new ItemStack(ModSubtiles.orechidIgnem), OrechidIgnemRecipeCategory.UID);
registry.addRecipeCatalyst(new ItemStack(ModSubtiles.orechidIgnemFloating), OrechidIgnemRecipeCategory.UID);
registry.addRecipeCatalyst(new ItemStack(ModSubtiles.pureDaisy), PureDaisyRecipeCategory.UID);
registry.addRecipeCatalyst(new ItemStack(ModSubtiles.pureDaisyFloating), 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);
}
@Override
public void onRuntimeAvailable(IJeiRuntime jeiRuntime) {
IRecipeManager recipeRegistry = jeiRuntime.getRecipeManager();
for(RecipeElvenTrade recipe : BotaniaAPI.elvenTradeRecipes) {
List<Ingredient> inputs = recipe.getInputs();
List<ItemStack> outputs = recipe.getOutputs();
if(inputs.size() == 1 && outputs.size() == 1 && inputs.get(0).test(outputs.get(0))) {
recipeRegistry.hideRecipe(recipe, ElvenTradeRecipeCategory.UID);
}
}
CorporeaInputHandler.jeiPanelSupplier = () -> {
Object o = jeiRuntime.getIngredientListOverlay().getIngredientUnderMouse();
if(o == null && Minecraft.getInstance().currentScreen == jeiRuntime.getRecipesGui())
o = jeiRuntime.getRecipesGui().getIngredientUnderMouse();
if(o == null)
o = jeiRuntime.getBookmarkOverlay().getIngredientUnderMouse();
if(o instanceof ItemStack)
return (ItemStack) o;
return ItemStack.EMPTY;
};
CorporeaInputHandler.supportedGuiFilter = gui -> gui instanceof ContainerScreen || gui instanceof IRecipesGui;
}
@Nonnull
@Override
public ResourceLocation getPluginUid() {
return ID;
}
}
@@ -1,138 +0,0 @@
/**
* This class was created by <williewillus>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
* <p/>
* 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.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.recipe.IFocus;
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<RecipeBrew> {
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/nei_brewery.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 ResourceLocation getUid() {
return UID;
}
@Nonnull
@Override
public Class<? extends RecipeBrew> getRecipeClass() {
return RecipeBrew.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(RecipeBrew recipe, IIngredients iIngredients) {
ImmutableList.Builder<List<ItemStack>> inputBuilder = ImmutableList.builder();
ImmutableList.Builder<ItemStack> outputBuilder = ImmutableList.builder();
ImmutableList.Builder<ItemStack> containers = ImmutableList.builder();
final List<ItemStack> 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<List<ItemStack>> inputs = ingredients.getInputs(VanillaTypes.ITEM);
List<List<ItemStack>> outputs = ingredients.getOutputs(VanillaTypes.ITEM);
IFocus<?> focus = recipeLayout.getFocus();
recipeLayout.getItemStacks().init(0, true, 39, 41);
recipeLayout.getItemStacks().set(0, getItemMatchingFocus(focus, IFocus.Mode.OUTPUT, outputs.get(0), inputs.get(0)));
int index = 1, posX = 60;
for(int i = 1; i < inputs.size(); i++) {
List<ItemStack> o = inputs.get(i);
recipeLayout.getItemStacks().init(index, true, posX, 6);
recipeLayout.getItemStacks().set(index, o);
index++;
posX += 18;
}
recipeLayout.getItemStacks().init(7, false, 87, 41);
recipeLayout.getItemStacks().set(7, getItemMatchingFocus(focus, IFocus.Mode.INPUT, inputs.get(0), outputs.get(0)));
}
/**
* If an item in this recipe is focused, returns the corresponding item instead of all the containers/results.
*/
private List<ItemStack> getItemMatchingFocus(IFocus<?> focus, IFocus.Mode mode, List<ItemStack> focused, List<ItemStack> other) {
if(focus != null && focus.getMode() == mode) {
ItemStack focusStack = (ItemStack) focus.getValue();
for(int i = 0; i < focused.size(); i++)
if(focusStack.isItemEqual(focused.get(i)))
return Collections.singletonList(other.get(i));
}
return other;
}
}
@@ -1,102 +0,0 @@
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.gui.ingredient.IGuiItemStackGroup;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.IFocus;
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 ICustomCraftingCategoryExtension {
private final ResourceLocation name;
public AncientWillRecipeWrapper(AncientWillRecipe recipe) {
this.name = recipe.getId();
}
@Override
public void setIngredients(@Nonnull IIngredients ingredients) {
ImmutableList.Builder<List<ItemStack>> builder = ImmutableList.builder();
ImmutableList.Builder<ItemStack> helmets = ImmutableList.builder();
ImmutableList.Builder<ItemStack> wills = ImmutableList.builder();
helmets.add(new ItemStack(ModItems.terrasteelHelm));
if(Botania.thaumcraftLoaded) {
helmets.add(new ItemStack(ModItems.terrasteelHelmRevealing));
}
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));
builder.add(helmets.build());
builder.add(wills.build());
ingredients.setInputLists(VanillaTypes.ITEM, builder.build());
ingredients.setOutputLists(VanillaTypes.ITEM, ImmutableList.of(helmets.build()));
}
@Nullable
@Override
public ResourceLocation getRegistryName() {
return name;
}
@Override
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IIngredients ingredients) {
IFocus<?> focus = recipeLayout.getFocus();
IGuiItemStackGroup group = recipeLayout.getItemStacks();
group.set(ingredients);
if(focus != null) {
ItemStack focused = (ItemStack) focus.getValue();
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()));
}
}
}
private List<ItemStack> getHelmetsWithWill(IAncientWillContainer.AncientWillType type, IIngredients ingredients) {
ImmutableList.Builder<ItemStack> builder = ImmutableList.builder();
for(ItemStack itemStack : ingredients.getOutputs(VanillaTypes.ITEM).get(0)) {
ItemStack toAdd = itemStack.copy();
((IAncientWillContainer) toAdd.getItem()).addAncientWill(toAdd, type);
builder.add(toAdd);
}
return builder.build();
}
private List<ItemStack> getWillsOnHelmet(Item item) {
if(item instanceof IAncientWillContainer) {
ImmutableList.Builder<ItemStack> builder = ImmutableList.builder();
for(IAncientWillContainer.AncientWillType type : IAncientWillContainer.AncientWillType.values()) {
ItemStack stack = new ItemStack(item);
((IAncientWillContainer) item).addAncientWill(stack, type);
builder.add(stack);
}
return builder.build();
}
return ImmutableList.of();
}
}
@@ -1,87 +0,0 @@
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.item.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<List<ItemStack>> inputs;
private final List<Item> lenses;
public CompositeLensRecipeWrapper(CompositeLensRecipe recipe) {
List<ItemStack> 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<ItemStack> firstInput = new ArrayList<>();
List<ItemStack> secondInput = new ArrayList<>();
List<ItemStack> 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);
}
}
@@ -1,41 +0,0 @@
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.recipe.category.extensions.vanilla.crafting.ICraftingCategoryExtension;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import vazkii.botania.common.crafting.recipe.TerraPickTippingRecipe;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.item.equipment.tool.terrasteel.ItemTerraPick;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
public class TerraPickTippingRecipeWrapper implements ICraftingCategoryExtension {
private final List<List<ItemStack>> inputs;
private final ItemStack output;
private final ResourceLocation name;
public TerraPickTippingRecipeWrapper(TerraPickTippingRecipe recipe) {
inputs = ImmutableList.of(ImmutableList.of(new ItemStack(ModItems.terraPick)), ImmutableList.of(new ItemStack(ModItems.elementiumPick)));
output = new ItemStack(ModItems.terraPick);
ItemTerraPick.setTipped(output);
this.name = recipe.getId();
}
@Override
public void setIngredients(@Nonnull IIngredients ingredients) {
ingredients.setInputLists(VanillaTypes.ITEM, inputs);
ingredients.setOutput(VanillaTypes.ITEM, output);
}
@Nullable
@Override
public ResourceLocation getRegistryName() {
return name;
}
}
@@ -1,134 +0,0 @@
/**
* This class was created by <williewillus>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
* <p/>
* 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.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.recipe.category.IRecipeCategory;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BufferBuilder;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.AtlasTexture;
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<RecipeElvenTrade> {
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/elven_trade_overlay.png"), 0, 15, 140, 90);
icon = guiHelper.createDrawableIngredient(new ItemStack(ModBlocks.alfPortal));
}
@Nonnull
@Override
public ResourceLocation getUid() {
return UID;
}
@Nonnull
@Override
public Class<? extends RecipeElvenTrade> getRecipeClass() {
return RecipeElvenTrade.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(RecipeElvenTrade recipe, IIngredients iIngredients) {
ImmutableList.Builder<List<ItemStack>> 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(AtlasTexture.LOCATION_BLOCKS_TEXTURE);
TextureAtlasSprite sprite = MiscellaneousIcons.INSTANCE.alfPortalTex;
Tessellator tess = Tessellator.getInstance();
BufferBuilder wr = tess.getBuffer();
wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
int startX = 22;
int startY = 25;
int stopX = 70;
int stopY = 73;
wr.pos(startX, startY, 0).tex(sprite.getMinU(), sprite.getMinV()).endVertex();
wr.pos(startX, stopY, 0).tex(sprite.getMinU(), sprite.getMaxV()).endVertex();
wr.pos(stopX, stopY, 0).tex(sprite.getMaxU(), sprite.getMaxV()).endVertex();
wr.pos(stopX, startY, 0).tex(sprite.getMaxU(), sprite.getMinV()).endVertex();
tess.draw();
}
@Override
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull RecipeElvenTrade recipe, @Nonnull IIngredients ingredients) {
int index = 0, posX = 42;
for(List<ItemStack> o : ingredients.getInputs(VanillaTypes.ITEM)) {
recipeLayout.getItemStacks().init(index, true, posX, 0);
recipeLayout.getItemStacks().set(index, o);
index++;
posX += 18;
}
for(int i = 0; i < ingredients.getOutputs(VanillaTypes.ITEM).size(); i++) {
List<ItemStack> stacks = ingredients.getOutputs(VanillaTypes.ITEM).get(i);
recipeLayout.getItemStacks().init(index + i, false, 93 + i % 2 * 20, 41 + i / 2 * 20);
recipeLayout.getItemStacks().set(index + i, stacks);
}
}
}
@@ -1,137 +0,0 @@
/**
* This class was created by <williewillus>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
* <p/>
* 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.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.recipe.category.IRecipeCategory;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import vazkii.botania.api.recipe.RecipeManaInfusion;
import vazkii.botania.client.core.handler.HUDHandler;
import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.block.tile.mana.TilePool;
import vazkii.botania.common.core.helper.ItemNBTHelper;
import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class ManaPoolRecipeCategory implements IRecipeCategory<RecipeManaInfusion> {
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) {
background = guiHelper.createBlankDrawable(168, 64);
localizedName = I18n.format("botania.nei.manaPool");
overlay = guiHelper.createDrawable(new ResourceLocation("botania", "textures/gui/pure_daisy_overlay.png"),
0, 0, 64, 46);
icon = guiHelper.createDrawableIngredient(renderStack.copy());
ItemNBTHelper.setBoolean(renderStack, "RenderFull", true);
}
@Nonnull
@Override
public ResourceLocation getUid() {
return UID;
}
@Nonnull
@Override
public Class<? extends RecipeManaInfusion> getRecipeClass() {
return RecipeManaInfusion.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(RecipeManaInfusion recipe, IIngredients iIngredients) {
ImmutableList.Builder<List<ItemStack>> 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(48, 0);
HUDHandler.renderManaBar(28, 50, 0x0000FF, 0.75F, recipe.getManaToConsume(), TilePool.MAX_MANA / 10);
GlStateManager.disableBlend();
GlStateManager.disableAlphaTest();
}
@Override
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull RecipeManaInfusion recipe, @Nonnull IIngredients ingredients) {
int index = 0;
recipeLayout.getItemStacks().init(index, true, 40, 12);
recipeLayout.getItemStacks().set(index, ingredients.getInputs(VanillaTypes.ITEM).get(0));
index++;
if(ingredients.getInputs(VanillaTypes.ITEM).size() > 1) {
// Has catalyst
recipeLayout.getItemStacks().init(index, true, 20, 12);
recipeLayout.getItemStacks().set(index, ingredients.getInputs(VanillaTypes.ITEM).get(1));
index++;
}
recipeLayout.getItemStacks().init(index, true, 70, 12);
recipeLayout.getItemStacks().set(index, renderStack);
index++;
recipeLayout.getItemStacks().init(index, false, 99, 12);
recipeLayout.getItemStacks().set(index, ingredients.getOutputs(VanillaTypes.ITEM).get(0));
}
}
@@ -1,104 +0,0 @@
/**
* This class was created by <codewarrior0>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
* <p/>
* 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 com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
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;
import javax.annotation.Nonnull;
public class OrechidIgnemRecipeCategory implements IRecipeCategory<OrechidIgnemRecipeWrapper> {
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/pure_daisy_overlay.png"),
0, 0, 64, 46);
icon = guiHelper.createDrawableIngredient(new ItemStack(ModSubtiles.orechidIgnem));
}
@Nonnull
@Override
public ResourceLocation getUid() {
return UID;
}
@Nonnull
@Override
public Class<? extends OrechidIgnemRecipeWrapper> getRecipeClass() {
return OrechidIgnemRecipeWrapper.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(OrechidIgnemRecipeWrapper recipe, IIngredients ingredients) {
}
@Override
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull OrechidIgnemRecipeWrapper 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, new ItemStack(ModSubtiles.orechidIgnem));
itemStacks.init(2, true, 99, 12);
itemStacks.set(2, ingredients.getOutputs(VanillaTypes.ITEM).get(0));
}
@Override
public void draw(OrechidIgnemRecipeWrapper recipe, double mouseX, double mouseY) {
GlStateManager.enableAlphaTest();
GlStateManager.enableBlend();
overlay.draw(48, 0);
GlStateManager.disableBlend();
GlStateManager.disableAlphaTest();
}
}
@@ -1,21 +0,0 @@
/**
* This class was created by <codewarrior0>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
* <p/>
* 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.util.ResourceLocation;
import java.util.Map;
public class OrechidIgnemRecipeWrapper extends OrechidRecipeWrapper {
public OrechidIgnemRecipeWrapper(Map.Entry<ResourceLocation, Integer> entry) {
super(entry);
}
}
@@ -1,136 +0,0 @@
/**
* This class was created by <codewarrior0>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
* <p/>
* 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 com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.block.Blocks;
import net.minecraft.item.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<OrechidRecipeWrapper> {
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/pure_daisy_overlay.png"),
0, 0, 64, 46);
icon = guiHelper.createDrawableIngredient(new ItemStack(ModSubtiles.orechid));
}
@Nonnull
@Override
public ResourceLocation getUid() {
return UID;
}
@Nonnull
@Override
public Class<? extends OrechidRecipeWrapper> 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<ItemStack> 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<ResourceLocation, Integer> 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, new ItemStack(ModSubtiles.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();
}
}
@@ -1,30 +0,0 @@
/**
* This class was created by <codewarrior0>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
* <p/>
* 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.block.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<OrechidRecipeWrapper> {
public final Map.Entry<ResourceLocation, Integer> entry;
public OrechidRecipeWrapper(Map.Entry<ResourceLocation, Integer> entry) {
this.entry = entry;
}
@Override
public int compareTo(@Nonnull OrechidRecipeWrapper o) {
return Integer.compare(o.entry.getValue(), entry.getValue());
}
}
@@ -1,125 +0,0 @@
/**
* This class was created by <williewillus>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
* <p/>
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*/
package vazkii.botania.client.integration.jei.petalapothecary;
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.recipe.category.IRecipeCategory;
import net.minecraft.client.Minecraft;
import com.mojang.blaze3d.platform.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 java.awt.Point;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class PetalApothecaryRecipeCategory implements IRecipeCategory<RecipePetals> {
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/petal_overlay.png"),
0, 0, 150, 110);
icon = guiHelper.createDrawableIngredient(new ItemStack(ModBlocks.defaultAltar));
}
@Nonnull
@Override
public ResourceLocation getUid() {
return UID;
}
@Nonnull
@Override
public Class<? extends RecipePetals> getRecipeClass() {
return RecipePetals.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(RecipePetals recipe, IIngredients iIngredients) {
List<List<ItemStack>> 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));
int index = 1;
double angleBetweenEach = 360.0 / ingredients.getInputs(VanillaTypes.ITEM).size();
Point point = new Point(64, 20), center = new Point(64, 52);
for(List<ItemStack> o : ingredients.getInputs(VanillaTypes.ITEM)) {
recipeLayout.getItemStacks().init(index, true, point.x, point.y);
recipeLayout.getItemStacks().set(index, o);
index += 1;
point = rotatePointAbout(point, center, angleBetweenEach);
}
recipeLayout.getItemStacks().init(index, false, 103, 17);
recipeLayout.getItemStacks().set(index, ingredients.getOutputs(VanillaTypes.ITEM).get(0));
}
private Point rotatePointAbout(Point in, Point about, double degrees) {
double rad = degrees * Math.PI / 180.0;
double newX = Math.cos(rad) * (in.x - about.x) - Math.sin(rad) * (in.y - about.y) + about.x;
double newY = Math.sin(rad) * (in.x - about.x) + Math.cos(rad) * (in.y - about.y) + about.y;
return new Point((int) newX, (int) newY);
}
}
@@ -1,145 +0,0 @@
/**
* This class was created by <williewillus>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
* <p/>
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*/
package vazkii.botania.client.integration.jei.puredaisy;
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.recipe.category.IRecipeCategory;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.BlockState;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.tags.Tag;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import vazkii.botania.api.recipe.RecipePureDaisy;
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.Collection;
import java.util.stream.Collectors;
public class PureDaisyRecipeCategory implements IRecipeCategory<RecipePureDaisy> {
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/pure_daisy_overlay.png"),
0, 0, 64, 46);
icon = guiHelper.createDrawableIngredient(new ItemStack(ModSubtiles.pureDaisy));
}
@Nonnull
@Override
public ResourceLocation getUid() {
return UID;
}
@Nonnull
@Override
public Class<? extends RecipePureDaisy> getRecipeClass() {
return RecipePureDaisy.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(RecipePureDaisy recipe, IIngredients iIngredients) {
if(recipe.getInput() instanceof Tag) {
Collection<Block> all = ((Tag<Block>) 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 BlockState) {
BlockState state = recipe.getInput() instanceof BlockState ? (BlockState) 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 {
if(b.asItem() != Items.AIR)
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 {
if(outBlock.asItem() != Items.AIR)
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();
if(inputFluid) {
recipeLayout.getFluidStacks().init(0, true, 40, 12, 16, 16, 1000, false, null);
recipeLayout.getFluidStacks().set(0, ingredients.getInputs(VanillaTypes.FLUID).get(0));
} else {
recipeLayout.getItemStacks().init(0, true, 40, 12);
recipeLayout.getItemStacks().set(0, ingredients.getInputs(VanillaTypes.ITEM).get(0));
}
recipeLayout.getItemStacks().init(1, true, 70, 12);
recipeLayout.getItemStacks().set(1, new ItemStack(ModSubtiles.pureDaisy));
if(outputFluid) {
recipeLayout.getFluidStacks().init(2, false, 99, 12, 16, 16, 1000, false, null);
recipeLayout.getFluidStacks().set(2, ingredients.getOutputs(VanillaTypes.FLUID).get(0));
} else {
recipeLayout.getItemStacks().init(2, false, 99, 12);
recipeLayout.getItemStacks().set(2, ingredients.getOutputs(VanillaTypes.ITEM).get(0));
}
}
}
@@ -1,131 +0,0 @@
/**
* This class was created by <williewillus>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
* <p/>
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*/
package vazkii.botania.client.integration.jei.runicaltar;
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.recipe.category.IRecipeCategory;
import net.minecraft.client.Minecraft;
import com.mojang.blaze3d.platform.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.RecipeRuneAltar;
import vazkii.botania.client.core.handler.HUDHandler;
import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.block.tile.mana.TilePool;
import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
import java.awt.Point;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
public class RunicAltarRecipeCategory implements IRecipeCategory<RecipeRuneAltar> {
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/petal_overlay.png"),
0, 0, 150, 110);
icon = guiHelper.createDrawableIngredient(new ItemStack(ModBlocks.runeAltar));
}
@Nonnull
@Override
public ResourceLocation getUid() {
return UID;
}
@Nonnull
@Override
public Class<? extends RecipeRuneAltar> getRecipeClass() {
return RecipeRuneAltar.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(RecipeRuneAltar recipe, IIngredients iIngredients) {
List<List<ItemStack>> list = new ArrayList<>();
for(Ingredient ingr : recipe.getInputs()) {
list.add(Arrays.asList(ingr.getMatchingStacks()));
}
System.out.println(list);
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));
int index = 1;
double angleBetweenEach = 360.0 / ingredients.getInputs(VanillaTypes.ITEM).size();
Point point = new Point(64, 20), center = new Point(64, 52);
for(List<ItemStack> o : ingredients.getInputs(VanillaTypes.ITEM)) {
recipeLayout.getItemStacks().init(index, true, point.x, point.y);
recipeLayout.getItemStacks().set(index, o);
index += 1;
point = rotatePointAbout(point, center, angleBetweenEach);
}
recipeLayout.getItemStacks().init(index, false, 103, 17);
recipeLayout.getItemStacks().set(index, ingredients.getOutputs(VanillaTypes.ITEM).get(0));
}
private Point rotatePointAbout(Point in, Point about, double degrees) {
double rad = degrees * Math.PI / 180.0;
double newX = Math.cos(rad) * (in.x - about.x) - Math.sin(rad) * (in.y - about.y) + about.x;
double newY = Math.sin(rad) * (in.x - about.x) + Math.cos(rad) * (in.y - about.y) + about.y;
return new Point((int) newX, (int) newY);
}
}