Finalized ARC
Finished 99% of the implementation work for the ARC and recipe system. Still need to populate the recipes (which will require textures for some items have have yet to be added).
This commit is contained in:
parent
9fa68e86ae
commit
1ead4ff820
56 changed files with 945 additions and 129 deletions
|
@ -2,6 +2,8 @@ package wayoftime.bloodmagic.compat.jei;
|
|||
|
||||
import java.util.Objects;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import mezz.jei.api.IModPlugin;
|
||||
import mezz.jei.api.JeiPlugin;
|
||||
import mezz.jei.api.helpers.IJeiHelpers;
|
||||
|
@ -11,12 +13,15 @@ import mezz.jei.api.registration.IRecipeRegistration;
|
|||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipeType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.api.impl.BloodMagicAPI;
|
||||
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
|
||||
import wayoftime.bloodmagic.common.item.BloodMagicItems;
|
||||
import wayoftime.bloodmagic.compat.jei.altar.BloodAltarRecipeCategory;
|
||||
import wayoftime.bloodmagic.compat.jei.arc.ARCFurnaceRecipeCategory;
|
||||
import wayoftime.bloodmagic.compat.jei.arc.ARCRecipeCategory;
|
||||
import wayoftime.bloodmagic.compat.jei.array.AlchemyArrayCraftingCategory;
|
||||
import wayoftime.bloodmagic.compat.jei.forge.TartaricForgeRecipeCategory;
|
||||
|
||||
|
@ -33,6 +38,8 @@ public class BloodMagicJEIPlugin implements IModPlugin
|
|||
registration.addRecipeCatalyst(new ItemStack(BloodMagicBlocks.SOUL_FORGE.get()), TartaricForgeRecipeCategory.UID);
|
||||
registration.addRecipeCatalyst(new ItemStack(BloodMagicBlocks.BLOOD_ALTAR.get()), BloodAltarRecipeCategory.UID);
|
||||
registration.addRecipeCatalyst(new ItemStack(BloodMagicItems.ARCANE_ASHES.get()), AlchemyArrayCraftingCategory.UID);
|
||||
registration.addRecipeCatalyst(new ItemStack(BloodMagicBlocks.ALCHEMICAL_REACTION_CHAMBER.get()), ARCRecipeCategory.UID);
|
||||
registration.addRecipeCatalyst(new ItemStack(BloodMagicBlocks.ALCHEMICAL_REACTION_CHAMBER.get()), ARCFurnaceRecipeCategory.UID);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -42,6 +49,8 @@ public class BloodMagicJEIPlugin implements IModPlugin
|
|||
registration.addRecipeCategories(new TartaricForgeRecipeCategory(registration.getJeiHelpers().getGuiHelper()));
|
||||
registration.addRecipeCategories(new BloodAltarRecipeCategory(registration.getJeiHelpers().getGuiHelper()));
|
||||
registration.addRecipeCategories(new AlchemyArrayCraftingCategory(registration.getJeiHelpers().getGuiHelper()));
|
||||
registration.addRecipeCategories(new ARCRecipeCategory(registration.getJeiHelpers().getGuiHelper()));
|
||||
registration.addRecipeCategories(new ARCFurnaceRecipeCategory(registration.getJeiHelpers().getGuiHelper()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -51,6 +60,8 @@ public class BloodMagicJEIPlugin implements IModPlugin
|
|||
registration.addRecipes(BloodMagicAPI.INSTANCE.getRecipeRegistrar().getTartaricForgeRecipes(world), TartaricForgeRecipeCategory.UID);
|
||||
registration.addRecipes(BloodMagicAPI.INSTANCE.getRecipeRegistrar().getAltarRecipes(world), BloodAltarRecipeCategory.UID);
|
||||
registration.addRecipes(BloodMagicAPI.INSTANCE.getRecipeRegistrar().getAlchemyArrayRecipes(world), AlchemyArrayCraftingCategory.UID);
|
||||
registration.addRecipes(BloodMagicAPI.INSTANCE.getRecipeRegistrar().getARCRecipes(world), ARCRecipeCategory.UID);
|
||||
registration.addRecipes(ImmutableSet.copyOf(world.getRecipeManager().getRecipesForType(IRecipeType.SMELTING)), ARCFurnaceRecipeCategory.UID);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,114 @@
|
|||
package wayoftime.bloodmagic.compat.jei.arc;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
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.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.crafting.FurnaceRecipe;
|
||||
import net.minecraft.item.crafting.Ingredient;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
|
||||
import wayoftime.bloodmagic.common.tags.BloodMagicTags;
|
||||
import wayoftime.bloodmagic.util.Constants;
|
||||
import wayoftime.bloodmagic.util.handler.event.ClientHandler;
|
||||
import wayoftime.bloodmagic.util.helper.TextHelper;
|
||||
|
||||
public class ARCFurnaceRecipeCategory implements IRecipeCategory<FurnaceRecipe>
|
||||
{
|
||||
private static final int OUTPUT_SLOT = 0;
|
||||
private static final int INPUT_SLOT = 1;
|
||||
private static final int CATALYST_SLOT = 2;
|
||||
public static final ResourceLocation UID = BloodMagic.rl(Constants.Compat.JEI_CATEGORY_ARC + "furnace");
|
||||
public static final ResourceLocation BACKGROUNDRL = BloodMagic.rl("gui/jei/arc.png");
|
||||
|
||||
@Nonnull
|
||||
private final IDrawable background;
|
||||
private final IDrawable icon;
|
||||
// @Nonnull
|
||||
// private final ICraftingGridHelper craftingGridHelper;
|
||||
|
||||
public ARCFurnaceRecipeCategory(IGuiHelper guiHelper)
|
||||
{
|
||||
icon = guiHelper.createDrawableIngredient(new ItemStack(BloodMagicBlocks.ALCHEMICAL_REACTION_CHAMBER.get()));
|
||||
background = guiHelper.createDrawable(BACKGROUNDRL, 0, 0, 157, 43);
|
||||
// craftingGridHelper = guiHelper.createCraftingGridHelper(INPUT_SLOT);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ResourceLocation getUid()
|
||||
{
|
||||
return UID;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return TextHelper.localize("jei.bloodmagic.recipe.arcfurnace");
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IDrawable getBackground()
|
||||
{
|
||||
return background;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IDrawable getIcon()
|
||||
{
|
||||
return icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull FurnaceRecipe recipe, @Nonnull IIngredients ingredients)
|
||||
{
|
||||
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
|
||||
|
||||
recipeLayout.getItemStacks().init(OUTPUT_SLOT, false, 53, 16);
|
||||
recipeLayout.getItemStacks().init(INPUT_SLOT, true, 0, 5);
|
||||
recipeLayout.getItemStacks().init(CATALYST_SLOT, true, 21, 16);
|
||||
|
||||
guiItemStacks.set(ingredients);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends FurnaceRecipe> getRecipeClass()
|
||||
{
|
||||
return FurnaceRecipe.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIngredients(FurnaceRecipe recipe, IIngredients ingredients)
|
||||
{
|
||||
List<Ingredient> inputIngList = recipe.getIngredients();
|
||||
inputIngList.add(Ingredient.fromTag(BloodMagicTags.ARC_TOOL_FURNACE));
|
||||
ingredients.setInputIngredients(inputIngList);
|
||||
ingredients.setOutput(VanillaTypes.ITEM, recipe.getRecipeOutput());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(FurnaceRecipe recipe, MatrixStack matrixStack, double mouseX, double mouseY)
|
||||
{
|
||||
FluidStack outputStack = FluidStack.EMPTY;
|
||||
ClientHandler.handleGuiTank(matrixStack, outputStack, outputStack.getAmount(), 140, 7, 16, 36, 157, 6, 18, 38, (int) mouseX, (int) mouseY, BACKGROUNDRL.toString(), null);
|
||||
|
||||
FluidStack inputStack = FluidStack.EMPTY;
|
||||
ClientHandler.handleGuiTank(matrixStack, inputStack, inputStack.getAmount(), 1, 26, 16, 16, 175, 26, 18, 18, (int) mouseX, (int) mouseY, BACKGROUNDRL.toString(), null);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,172 @@
|
|||
package wayoftime.bloodmagic.compat.jei.arc;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
|
||||
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.IGuiItemStackGroup;
|
||||
import mezz.jei.api.helpers.IGuiHelper;
|
||||
import mezz.jei.api.ingredients.IIngredients;
|
||||
import mezz.jei.api.recipe.category.IRecipeCategory;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.api.impl.recipe.RecipeARC;
|
||||
import wayoftime.bloodmagic.common.block.BloodMagicBlocks;
|
||||
import wayoftime.bloodmagic.util.Constants;
|
||||
import wayoftime.bloodmagic.util.handler.event.ClientHandler;
|
||||
import wayoftime.bloodmagic.util.helper.TextHelper;
|
||||
|
||||
public class ARCRecipeCategory implements IRecipeCategory<RecipeARC>
|
||||
{
|
||||
private static final int OUTPUT_SLOT = 0;
|
||||
private static final int INPUT_SLOT = 4;
|
||||
private static final int CATALYST_SLOT = 5;
|
||||
public static final ResourceLocation UID = BloodMagic.rl(Constants.Compat.JEI_CATEGORY_ARC);
|
||||
public static final ResourceLocation BACKGROUNDRL = BloodMagic.rl("gui/jei/arc.png");
|
||||
|
||||
@Nonnull
|
||||
private final IDrawable background;
|
||||
private final IDrawable icon;
|
||||
// @Nonnull
|
||||
// private final ICraftingGridHelper craftingGridHelper;
|
||||
|
||||
public ARCRecipeCategory(IGuiHelper guiHelper)
|
||||
{
|
||||
icon = guiHelper.createDrawableIngredient(new ItemStack(BloodMagicBlocks.ALCHEMICAL_REACTION_CHAMBER.get()));
|
||||
background = guiHelper.createDrawable(BACKGROUNDRL, 0, 0, 157, 43);
|
||||
// craftingGridHelper = guiHelper.createCraftingGridHelper(INPUT_SLOT);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ResourceLocation getUid()
|
||||
{
|
||||
return UID;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getTitle()
|
||||
{
|
||||
return TextHelper.localize("jei.bloodmagic.recipe.arc");
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IDrawable getBackground()
|
||||
{
|
||||
return background;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IDrawable getIcon()
|
||||
{
|
||||
return icon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull RecipeARC recipe, @Nonnull IIngredients ingredients)
|
||||
{
|
||||
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
|
||||
|
||||
recipeLayout.getItemStacks().init(OUTPUT_SLOT, false, 53, 16);
|
||||
recipeLayout.getItemStacks().init(OUTPUT_SLOT + 1, false, 53 + 22 * 1, 16);
|
||||
recipeLayout.getItemStacks().init(OUTPUT_SLOT + 2, false, 53 + 22 * 2, 16);
|
||||
recipeLayout.getItemStacks().init(OUTPUT_SLOT + 3, false, 53 + 22 * 3, 16);
|
||||
recipeLayout.getItemStacks().init(INPUT_SLOT, true, 0, 5);
|
||||
recipeLayout.getItemStacks().init(CATALYST_SLOT, true, 21, 16);
|
||||
|
||||
guiItemStacks.set(ingredients);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends RecipeARC> getRecipeClass()
|
||||
{
|
||||
return RecipeARC.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIngredients(RecipeARC recipe, IIngredients ingredients)
|
||||
{
|
||||
ingredients.setInputIngredients(recipe.getIngredients());
|
||||
ingredients.setOutputs(VanillaTypes.ITEM, recipe.getAllListedOutputs());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(RecipeARC recipe, MatrixStack matrixStack, double mouseX, double mouseY)
|
||||
{
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
double[] chanceArray = recipe.getAllOutputChances();
|
||||
|
||||
String[] infoString = new String[chanceArray.length];
|
||||
for (int i = 0; i < infoString.length; i++)
|
||||
{
|
||||
if (chanceArray[i] >= 1)
|
||||
{
|
||||
infoString[i] = "";
|
||||
} else if (chanceArray[i] < 0.01)
|
||||
{
|
||||
infoString[i] = "<1%";
|
||||
} else
|
||||
{
|
||||
infoString[i] = "" + (int) (chanceArray[i] * 100) + "%";
|
||||
}
|
||||
|
||||
mc.fontRenderer.drawStringWithShadow(matrixStack, infoString[i], 86 + 22 * i
|
||||
- mc.fontRenderer.getStringWidth(infoString[i]) / 2, 5, Color.white.getRGB());
|
||||
}
|
||||
|
||||
// if (recipe.getFluidOutput() != null && !recipe.getFluidOutput().isEmpty())
|
||||
{
|
||||
FluidStack outputStack = recipe.getFluidOutput();
|
||||
ClientHandler.handleGuiTank(matrixStack, outputStack, outputStack.getAmount(), 140, 7, 16, 36, 157, 6, 18, 38, (int) mouseX, (int) mouseY, BACKGROUNDRL.toString(), null);
|
||||
}
|
||||
|
||||
if (recipe.getFluidIngredient() != null)
|
||||
{
|
||||
List<FluidStack> inputFluids = recipe.getFluidIngredient().getRepresentations();
|
||||
FluidStack inputStack = inputFluids.get(0);
|
||||
ClientHandler.handleGuiTank(matrixStack, inputStack, inputStack.getAmount(), 1, 26, 16, 16, 175, 26, 18, 18, (int) mouseX, (int) mouseY, BACKGROUNDRL.toString(), null);
|
||||
}
|
||||
|
||||
// { TextHelper.localize("jei.bloodmagic.recipe.requiredtier", NumeralHelper.toRoman(recipe.getMinimumTier().toInt())),
|
||||
// TextHelper.localize("jei.bloodmagic.recipe.requiredlp", recipe.getSyphon()) };
|
||||
// mc.fontRenderer.drawString(matrixStack, infoString[0], 90
|
||||
// - mc.fontRenderer.getStringWidth(infoString[0]) / 2, 0, Color.gray.getRGB());
|
||||
// mc.fontRenderer.drawString(matrixStack, infoString[1], 90
|
||||
// - mc.fontRenderer.getStringWidth(infoString[1]) / 2, 10, Color.gray.getRGB());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ITextComponent> getTooltipStrings(RecipeARC recipe, double mouseX, double mouseY)
|
||||
{
|
||||
List<ITextComponent> tooltip = new ArrayList<>();
|
||||
FluidStack outputStack = recipe.getFluidOutput();
|
||||
if (!outputStack.isEmpty())
|
||||
{
|
||||
ClientHandler.handleGuiTank(null, outputStack, -1, 140, 8, 16, 34, 157, 7, 18, 36, (int) mouseX, (int) mouseY, BACKGROUNDRL.toString(), tooltip);
|
||||
}
|
||||
|
||||
if (recipe.getFluidIngredient() != null)
|
||||
{
|
||||
List<FluidStack> inputFluids = recipe.getFluidIngredient().getRepresentations();
|
||||
FluidStack inputStack = inputFluids.get(0);
|
||||
ClientHandler.handleGuiTank(null, inputStack, -1, 1, 26, 16, 16, 175, 26, 18, 18, (int) mouseX, (int) mouseY, BACKGROUNDRL.toString(), tooltip);
|
||||
}
|
||||
|
||||
return tooltip;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue