mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-20 20:22:33 +00:00
Restore JEI and compat
This commit is contained in:
1 parent
7ab7690c89
commit
5484cfc815
16 files changed
+28
-20
No files matched your search
@@ -0,0 +1,237 @@
|
||||
/*
|
||||
* This class is 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;
|
||||
|
||||
import mezz.jei.api.IModPlugin;
|
||||
import mezz.jei.api.JeiPlugin;
|
||||
import mezz.jei.api.constants.VanillaRecipeCategoryUid;
|
||||
import mezz.jei.api.gui.ingredient.IGuiIngredientGroup;
|
||||
import mezz.jei.api.recipe.IRecipeManager;
|
||||
import mezz.jei.api.registration.*;
|
||||
import mezz.jei.api.runtime.IJeiRuntime;
|
||||
import mezz.jei.api.runtime.IRecipesGui;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.mana.IManaItem;
|
||||
import vazkii.botania.api.recipe.IElvenTradeRecipe;
|
||||
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.block.tile.TileAlfPortal;
|
||||
import vazkii.botania.common.block.tile.mana.TilePool;
|
||||
import vazkii.botania.common.core.helper.ItemNBTHelper;
|
||||
import vazkii.botania.common.crafting.LexiconElvenTradeRecipe;
|
||||
import vazkii.botania.common.crafting.ModRecipeTypes;
|
||||
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.ItemLaputaShard;
|
||||
import vazkii.botania.common.item.ItemLexicon;
|
||||
import vazkii.botania.common.item.ItemManaTablet;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.item.brew.ItemBrewBase;
|
||||
import vazkii.botania.common.item.equipment.bauble.ItemFlightTiara;
|
||||
import vazkii.botania.common.item.equipment.tool.terrasteel.ItemTerraPick;
|
||||
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 registry) {
|
||||
registry.registerSubtypeInterpreter(ModItems.brewVial, ItemBrewBase::getSubtype);
|
||||
registry.registerSubtypeInterpreter(ModItems.brewFlask, ItemBrewBase::getSubtype);
|
||||
registry.registerSubtypeInterpreter(ModItems.incenseStick, ItemBrewBase::getSubtype);
|
||||
registry.registerSubtypeInterpreter(ModItems.bloodPendant, ItemBrewBase::getSubtype);
|
||||
|
||||
registry.registerSubtypeInterpreter(ModItems.flightTiara, stack -> String.valueOf(ItemFlightTiara.getVariant(stack)));
|
||||
registry.registerSubtypeInterpreter(ModItems.lexicon, stack -> String.valueOf(ItemNBTHelper.getBoolean(stack, ItemLexicon.TAG_ELVEN_UNLOCK, false)));
|
||||
registry.registerSubtypeInterpreter(ModItems.laputaShard, stack -> String.valueOf(ItemLaputaShard.getShardLevel(stack)));
|
||||
|
||||
registry.registerSubtypeInterpreter(ModItems.terraPick, stack -> String.valueOf(ItemTerraPick.getLevel(stack)) + ItemTerraPick.isTipped(stack));
|
||||
registry.registerSubtypeInterpreter(ModItems.manaTablet, stack -> String.valueOf(((IManaItem) ModItems.manaTablet).getMana(stack)) + ItemManaTablet.isStackCreative(stack));
|
||||
|
||||
for (Item item : new Item[] { ModItems.manaRing, ModItems.manaRingGreater }) {
|
||||
registry.registerSubtypeInterpreter(item, stack -> String.valueOf(((IManaItem) item).getMana(stack)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerCategories(IRecipeCategoryRegistration registry) {
|
||||
registry.addRecipeCategories(
|
||||
new PureDaisyRecipeCategory(registry.getJeiHelpers().getGuiHelper()),
|
||||
new ManaPoolRecipeCategory(registry.getJeiHelpers().getGuiHelper()),
|
||||
new PetalApothecaryRecipeCategory(registry.getJeiHelpers().getGuiHelper()),
|
||||
new RunicAltarRecipeCategory(registry.getJeiHelpers().getGuiHelper()),
|
||||
new ElvenTradeRecipeCategory(registry.getJeiHelpers().getGuiHelper()),
|
||||
new BreweryRecipeCategory(registry.getJeiHelpers().getGuiHelper()),
|
||||
new OrechidRecipeCategory(registry.getJeiHelpers().getGuiHelper()),
|
||||
new OrechidIgnemRecipeCategory(registry.getJeiHelpers().getGuiHelper())
|
||||
);
|
||||
}
|
||||
|
||||
public static boolean doesOreExist(ResourceLocation tagId) {
|
||||
return !BlockTags.getCollection().getOrCreate(tagId).func_230236_b_().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(Minecraft.getInstance().world.getRecipeManager().getRecipes(ModRecipeTypes.BREW_TYPE).values(), BreweryRecipeCategory.UID);
|
||||
registry.addRecipes(Minecraft.getInstance().world.getRecipeManager().getRecipes(ModRecipeTypes.PURE_DAISY_TYPE).values(), PureDaisyRecipeCategory.UID);
|
||||
registry.addRecipes(Minecraft.getInstance().world.getRecipeManager().getRecipes(ModRecipeTypes.PETAL_TYPE).values(), PetalApothecaryRecipeCategory.UID);
|
||||
registry.addRecipes(Minecraft.getInstance().world.getRecipeManager().getRecipes(ModRecipeTypes.ELVEN_TRADE_TYPE).values(), ElvenTradeRecipeCategory.UID);
|
||||
registry.addRecipes(Minecraft.getInstance().world.getRecipeManager().getRecipes(ModRecipeTypes.RUNE_TYPE).values(), RunicAltarRecipeCategory.UID);
|
||||
registry.addRecipes(TilePool.manaInfusionRecipes(Minecraft.getInstance().world.getRecipeManager()), ManaPoolRecipeCategory.UID);
|
||||
|
||||
registry.addRecipes(
|
||||
BotaniaAPI.instance().getOreWeights().entrySet().stream()
|
||||
.filter(e -> doesOreExist(e.getKey()))
|
||||
.map(OrechidRecipeWrapper::new)
|
||||
.sorted()
|
||||
.collect(Collectors.toList()),
|
||||
OrechidRecipeCategory.UID);
|
||||
|
||||
registry.addRecipes(
|
||||
BotaniaAPI.instance().getNetherOreWeights().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();
|
||||
// Hide the return recipes (iron ingot/diamond/ender pearl returns, not lexicon)
|
||||
for (IElvenTradeRecipe recipe : TileAlfPortal.elvenTradeRecipes(Minecraft.getInstance().world.getRecipeManager())) {
|
||||
if (recipe instanceof LexiconElvenTradeRecipe) {
|
||||
continue;
|
||||
}
|
||||
List<Ingredient> inputs = recipe.getIngredients();
|
||||
List<ItemStack> outputs = recipe.getOutputs();
|
||||
if (inputs.size() == 1 && outputs.size() == 1 && recipe.containsItem(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;
|
||||
}
|
||||
|
||||
public static void addDefaultRecipeIdTooltip(IGuiIngredientGroup<?> group, int slot, ResourceLocation recipeId) {
|
||||
group.addTooltipCallback((slotIndex, input, ingredient, tooltip) -> {
|
||||
if (slotIndex == slot) {
|
||||
if (Minecraft.getInstance().gameSettings.advancedItemTooltips || Screen.func_231173_s_()) {
|
||||
tooltip.add(new TranslationTextComponent("jei.tooltip.recipe.id", recipeId).func_240699_a_(TextFormatting.DARK_GRAY));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ResourceLocation getPluginUid() {
|
||||
return ID;
|
||||
}
|
||||
}
|
||||
+147
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* This class is 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.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.IBrewRecipe;
|
||||
import vazkii.botania.client.integration.jei.JEIBotaniaPlugin;
|
||||
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<IBrewRecipe> {
|
||||
|
||||
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 IBrewRecipe> getRecipeClass() {
|
||||
return IBrewRecipe.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(IBrewRecipe 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.getIngredients()) {
|
||||
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 IBrewRecipe 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)));
|
||||
|
||||
JEIBotaniaPlugin.addDefaultRecipeIdTooltip(recipeLayout.getItemStacks(), 7, recipe.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
+114
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* This class is 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.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();
|
||||
}
|
||||
}
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* This class is 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.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.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import vazkii.botania.common.crafting.recipe.CompositeLensRecipe;
|
||||
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"))
|
||||
.func_230236_b_().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);
|
||||
}
|
||||
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* This class is 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.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;
|
||||
}
|
||||
}
|
||||
+153
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
* This class is 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 com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
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.gui.screen.Screen;
|
||||
import net.minecraft.client.renderer.BufferBuilder;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.AtlasTexture;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
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 net.minecraft.util.text.TextFormatting;
|
||||
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import vazkii.botania.api.recipe.IElvenTradeRecipe;
|
||||
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<IElvenTradeRecipe> {
|
||||
|
||||
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 IElvenTradeRecipe> getRecipeClass() {
|
||||
return IElvenTradeRecipe.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(IElvenTradeRecipe recipe, IIngredients iIngredients) {
|
||||
ImmutableList.Builder<List<ItemStack>> builder = ImmutableList.builder();
|
||||
for (Ingredient i : recipe.getIngredients()) {
|
||||
builder.add(Arrays.asList(i.getMatchingStacks()));
|
||||
}
|
||||
iIngredients.setInputLists(VanillaTypes.ITEM, builder.build());
|
||||
iIngredients.setOutputs(VanillaTypes.ITEM, ImmutableList.copyOf(recipe.getOutputs()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(IElvenTradeRecipe recipe, MatrixStack ms, double mouseX, double mouseY) {
|
||||
RenderSystem.enableAlphaTest();
|
||||
RenderSystem.enableBlend();
|
||||
overlay.draw(ms, 0, 4);
|
||||
RenderSystem.disableBlend();
|
||||
RenderSystem.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 IElvenTradeRecipe 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);
|
||||
}
|
||||
|
||||
int endIndex = index;
|
||||
ResourceLocation recipeId = recipe.getId();
|
||||
recipeLayout.getItemStacks().addTooltipCallback((slotIndex, input, ingredient, tooltip) -> {
|
||||
if (slotIndex >= endIndex) {
|
||||
if (Minecraft.getInstance().gameSettings.advancedItemTooltips || Screen.func_231173_s_()) {
|
||||
tooltip.add(new TranslationTextComponent("jei.tooltip.recipe.id", recipeId).func_240699_a_(TextFormatting.DARK_GRAY));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
+141
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* This class is 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 com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
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.resources.I18n;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import vazkii.botania.api.recipe.IManaInfusionRecipe;
|
||||
import vazkii.botania.client.core.handler.HUDHandler;
|
||||
import vazkii.botania.client.integration.jei.JEIBotaniaPlugin;
|
||||
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 java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ManaPoolRecipeCategory implements IRecipeCategory<IManaInfusionRecipe> {
|
||||
|
||||
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);
|
||||
ItemNBTHelper.setBoolean(renderStack, "RenderFull", true);
|
||||
icon = guiHelper.createDrawableIngredient(renderStack.copy());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ResourceLocation getUid() {
|
||||
return UID;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Class<? extends IManaInfusionRecipe> getRecipeClass() {
|
||||
return IManaInfusionRecipe.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(IManaInfusionRecipe recipe, IIngredients iIngredients) {
|
||||
ImmutableList.Builder<List<ItemStack>> builder = ImmutableList.builder();
|
||||
|
||||
builder.add(Arrays.asList(recipe.getIngredients().get(0).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.getRecipeOutput());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(IManaInfusionRecipe recipe, MatrixStack ms, double mouseX, double mouseY) {
|
||||
RenderSystem.enableAlphaTest();
|
||||
RenderSystem.enableBlend();
|
||||
overlay.draw(ms, 48, 0);
|
||||
HUDHandler.renderManaBar(ms, 28, 50, 0x0000FF, 0.75F, recipe.getManaToConsume(), TilePool.MAX_MANA / 10);
|
||||
RenderSystem.disableBlend();
|
||||
RenderSystem.disableAlphaTest();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IManaInfusionRecipe 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));
|
||||
|
||||
JEIBotaniaPlugin.addDefaultRecipeIdTooltip(recipeLayout.getItemStacks(), index, recipe.getId());
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* This class is 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.helpers.IGuiHelper;
|
||||
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.common.block.ModSubtiles;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class OrechidIgnemRecipeCategory extends OrechidRecipeCategoryBase<OrechidIgnemRecipeWrapper> {
|
||||
|
||||
public static final ResourceLocation UID = new ResourceLocation(LibMisc.MOD_ID, "orechid_ignem");
|
||||
|
||||
public OrechidIgnemRecipeCategory(IGuiHelper guiHelper) {
|
||||
super(guiHelper, new ItemStack(ModSubtiles.orechidIgnem), new ItemStack(Blocks.NETHERRACK, 64),
|
||||
I18n.format("botania.nei.orechidIgnem"));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ResourceLocation getUid() {
|
||||
return UID;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Class<? extends OrechidIgnemRecipeWrapper> getRecipeClass() {
|
||||
return OrechidIgnemRecipeWrapper.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<ResourceLocation, Integer> getOreWeights() {
|
||||
return BotaniaAPI.instance().getNetherOreWeights();
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* This class is 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.util.ResourceLocation;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class OrechidIgnemRecipeWrapper extends OrechidRecipeWrapper {
|
||||
|
||||
public OrechidIgnemRecipeWrapper(Map.Entry<ResourceLocation, Integer> entry) {
|
||||
super(entry);
|
||||
}
|
||||
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* This class is 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.helpers.IGuiHelper;
|
||||
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.common.block.ModSubtiles;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class OrechidRecipeCategory extends OrechidRecipeCategoryBase<OrechidRecipeWrapper> {
|
||||
public static final ResourceLocation UID = new ResourceLocation(LibMisc.MOD_ID, "orechid");
|
||||
|
||||
public OrechidRecipeCategory(IGuiHelper guiHelper) {
|
||||
super(guiHelper, new ItemStack(ModSubtiles.orechid), new ItemStack(Blocks.STONE, 64),
|
||||
I18n.format("botania.nei.orechid"));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ResourceLocation getUid() {
|
||||
return UID;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Class<? extends OrechidRecipeWrapper> getRecipeClass() {
|
||||
return OrechidRecipeWrapper.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<ResourceLocation, Integer> getOreWeights() {
|
||||
return BotaniaAPI.instance().getOreWeights();
|
||||
}
|
||||
|
||||
}
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* This class is 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 com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
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.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import vazkii.botania.client.integration.jei.JEIBotaniaPlugin;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public abstract class OrechidRecipeCategoryBase<T extends OrechidRecipeWrapper> implements IRecipeCategory<T> {
|
||||
|
||||
private final IDrawableStatic background;
|
||||
private final String localizedName;
|
||||
private final IDrawableStatic overlay;
|
||||
private final IDrawable icon;
|
||||
private final ItemStack iconStack;
|
||||
private final ItemStack inputStack;
|
||||
|
||||
public OrechidRecipeCategoryBase(IGuiHelper guiHelper, ItemStack iconStack, ItemStack inputStack, String localizedName) {
|
||||
overlay = guiHelper.createDrawable(new ResourceLocation("botania", "textures/gui/pure_daisy_overlay.png"),
|
||||
0, 0, 64, 46);
|
||||
background = guiHelper.createBlankDrawable(168, 64);
|
||||
this.localizedName = localizedName;
|
||||
this.icon = guiHelper.createDrawableIngredient(iconStack);
|
||||
this.iconStack = iconStack;
|
||||
this.inputStack = inputStack;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public abstract Class<? extends T> getRecipeClass();
|
||||
|
||||
@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(T recipe, IIngredients ingredients) {
|
||||
ingredients.setInput(VanillaTypes.ITEM, inputStack);
|
||||
|
||||
final int myWeight = recipe.entry.getValue();
|
||||
final int amount = Math.max(1, Math.round((float) myWeight * 64 / getTotalOreWeight(getOreWeights(), 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())
|
||||
.func_230236_b_()
|
||||
.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);
|
||||
}
|
||||
|
||||
protected abstract Map<ResourceLocation, Integer> getOreWeights();
|
||||
|
||||
@Override
|
||||
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull T 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, iconStack);
|
||||
|
||||
itemStacks.init(2, true, 99, 12);
|
||||
itemStacks.set(2, ingredients.getOutputs(VanillaTypes.ITEM).get(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(T recipe, MatrixStack ms, double mouseX, double mouseY) {
|
||||
RenderSystem.enableAlphaTest();
|
||||
RenderSystem.enableBlend();
|
||||
overlay.draw(ms, 48, 0);
|
||||
RenderSystem.disableBlend();
|
||||
RenderSystem.disableAlphaTest();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* This class is 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.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());
|
||||
}
|
||||
}
|
||||
+132
@@ -0,0 +1,132 @@
|
||||
/*
|
||||
* This class is 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.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
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.resources.I18n;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import vazkii.botania.api.recipe.IPetalRecipe;
|
||||
import vazkii.botania.client.integration.jei.JEIBotaniaPlugin;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class PetalApothecaryRecipeCategory implements IRecipeCategory<IPetalRecipe> {
|
||||
|
||||
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 IPetalRecipe> getRecipeClass() {
|
||||
return IPetalRecipe.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(IPetalRecipe recipe, IIngredients iIngredients) {
|
||||
List<List<ItemStack>> list = new ArrayList<>();
|
||||
for (Ingredient ingr : recipe.getIngredients()) {
|
||||
list.add(Arrays.asList(ingr.getMatchingStacks()));
|
||||
}
|
||||
iIngredients.setInputLists(VanillaTypes.ITEM, list);
|
||||
iIngredients.setOutput(VanillaTypes.ITEM, recipe.getRecipeOutput());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(IPetalRecipe recipe, MatrixStack ms, double mouseX, double mouseY) {
|
||||
RenderSystem.enableAlphaTest();
|
||||
RenderSystem.enableBlend();
|
||||
overlay.draw(ms);
|
||||
RenderSystem.disableBlend();
|
||||
RenderSystem.disableAlphaTest();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IPetalRecipe 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));
|
||||
|
||||
JEIBotaniaPlugin.addDefaultRecipeIdTooltip(recipeLayout.getItemStacks(), index, recipe.getId());
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
+156
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
* This class is 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.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import mezz.jei.api.constants.VanillaTypes;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.gui.drawable.IDrawable;
|
||||
import mezz.jei.api.gui.ingredient.IGuiIngredientGroup;
|
||||
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.FlowingFluidBlock;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import vazkii.botania.api.recipe.IPureDaisyRecipe;
|
||||
import vazkii.botania.api.recipe.StateIngredient;
|
||||
import vazkii.botania.client.integration.jei.JEIBotaniaPlugin;
|
||||
import vazkii.botania.common.block.ModSubtiles;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class PureDaisyRecipeCategory implements IRecipeCategory<IPureDaisyRecipe> {
|
||||
|
||||
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, 46);
|
||||
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 IPureDaisyRecipe> getRecipeClass() {
|
||||
return IPureDaisyRecipe.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(IPureDaisyRecipe recipe, IIngredients iIngredients) {
|
||||
StateIngredient input = recipe.getInput();
|
||||
if (input.getDisplayed().size() > 1) {
|
||||
iIngredients.setInputLists(VanillaTypes.ITEM, Collections.singletonList(input.getDisplayed().stream()
|
||||
.map(BlockState::getBlock)
|
||||
.map(ItemStack::new)
|
||||
.filter(s -> !s.isEmpty())
|
||||
.collect(Collectors.toList())));
|
||||
} else {
|
||||
BlockState state = input.getDisplayed().get(0);
|
||||
Block b = state.getBlock();
|
||||
|
||||
if (b instanceof FlowingFluidBlock) {
|
||||
iIngredients.setInput(VanillaTypes.FLUID, new FluidStack(((FlowingFluidBlock) b).getFluid(), 1000));
|
||||
} else {
|
||||
if (b.asItem() != Items.AIR) {
|
||||
iIngredients.setInput(VanillaTypes.ITEM, new ItemStack(b));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Block outBlock = recipe.getOutputState().getBlock();
|
||||
if (outBlock instanceof FlowingFluidBlock) {
|
||||
iIngredients.setOutput(VanillaTypes.FLUID, new FluidStack(((FlowingFluidBlock) outBlock).getFluid(), 1000));
|
||||
} else {
|
||||
if (outBlock.asItem() != Items.AIR) {
|
||||
iIngredients.setOutput(VanillaTypes.ITEM, new ItemStack(outBlock));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(IPureDaisyRecipe recipe, MatrixStack ms, double mouseX, double mouseY) {
|
||||
RenderSystem.enableAlphaTest();
|
||||
RenderSystem.enableBlend();
|
||||
overlay.draw(ms, 48, 0);
|
||||
RenderSystem.disableBlend();
|
||||
RenderSystem.disableAlphaTest();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IPureDaisyRecipe 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));
|
||||
}
|
||||
|
||||
IGuiIngredientGroup<?> group = outputFluid ? recipeLayout.getFluidStacks() : recipeLayout.getItemStacks();
|
||||
JEIBotaniaPlugin.addDefaultRecipeIdTooltip(group, 2, recipe.getId());
|
||||
}
|
||||
}
|
||||
+135
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* This class is 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.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
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.resources.I18n;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import vazkii.botania.api.recipe.IRuneAltarRecipe;
|
||||
import vazkii.botania.client.core.handler.HUDHandler;
|
||||
import vazkii.botania.client.integration.jei.JEIBotaniaPlugin;
|
||||
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.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class RunicAltarRecipeCategory implements IRecipeCategory<IRuneAltarRecipe> {
|
||||
|
||||
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 IRuneAltarRecipe> getRecipeClass() {
|
||||
return IRuneAltarRecipe.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(IRuneAltarRecipe recipe, IIngredients iIngredients) {
|
||||
List<List<ItemStack>> list = new ArrayList<>();
|
||||
for (Ingredient ingr : recipe.getIngredients()) {
|
||||
list.add(Arrays.asList(ingr.getMatchingStacks()));
|
||||
}
|
||||
iIngredients.setInputLists(VanillaTypes.ITEM, list);
|
||||
iIngredients.setOutput(VanillaTypes.ITEM, recipe.getRecipeOutput());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(IRuneAltarRecipe recipe, MatrixStack ms, double mouseX, double mouseY) {
|
||||
RenderSystem.enableAlphaTest();
|
||||
RenderSystem.enableBlend();
|
||||
overlay.draw(ms);
|
||||
HUDHandler.renderManaBar(ms, 28, 113, 0x0000FF, 0.75F, recipe.getManaUsage(), TilePool.MAX_MANA / 10);
|
||||
RenderSystem.disableBlend();
|
||||
RenderSystem.disableAlphaTest();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRuneAltarRecipe 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));
|
||||
|
||||
JEIBotaniaPlugin.addDefaultRecipeIdTooltip(recipeLayout.getItemStacks(), index, recipe.getId());
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user