mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-19 11:49:37 +00:00
JEI integration complete (runic altar, mana infusion)
This commit is contained in:
1 parent
28249d1e33
commit
8e6dc7c637
12 files changed
+460
-47
No files matched your search
@@ -22,10 +22,14 @@ import vazkii.botania.client.integration.jei.brewery.BreweryRecipeCategory;
|
||||
import vazkii.botania.client.integration.jei.brewery.BreweryRecipeHandler;
|
||||
import vazkii.botania.client.integration.jei.elventrade.ElvenTradeRecipeCategory;
|
||||
import vazkii.botania.client.integration.jei.elventrade.ElvenTradeRecipeHandler;
|
||||
import vazkii.botania.client.integration.jei.manapool.ManaPoolRecipeCategory;
|
||||
import vazkii.botania.client.integration.jei.manapool.ManaPoolRecipeHandler;
|
||||
import vazkii.botania.client.integration.jei.petalapothecary.PetalApothecaryRecipeCategory;
|
||||
import vazkii.botania.client.integration.jei.petalapothecary.PetalApothecaryRecipeHandler;
|
||||
import vazkii.botania.client.integration.jei.puredaisy.PureDaisyRecipeCategory;
|
||||
import vazkii.botania.client.integration.jei.puredaisy.PureDaisyRecipeHandler;
|
||||
import vazkii.botania.client.integration.jei.runicaltar.RunicAltarRecipeCategory;
|
||||
import vazkii.botania.client.integration.jei.runicaltar.RunicAltarRecipeHandler;
|
||||
|
||||
@JEIPlugin
|
||||
public class JEIBotaniaPlugin implements IModPlugin {
|
||||
@@ -54,25 +58,29 @@ public class JEIBotaniaPlugin implements IModPlugin {
|
||||
new BreweryRecipeCategory(jeiHelpers.getGuiHelper()),
|
||||
new PureDaisyRecipeCategory(jeiHelpers.getGuiHelper()),
|
||||
new PetalApothecaryRecipeCategory(jeiHelpers.getGuiHelper()),
|
||||
new ElvenTradeRecipeCategory(jeiHelpers.getGuiHelper())
|
||||
new ElvenTradeRecipeCategory(jeiHelpers.getGuiHelper()),
|
||||
new RunicAltarRecipeCategory(jeiHelpers.getGuiHelper()),
|
||||
new ManaPoolRecipeCategory(jeiHelpers.getGuiHelper())
|
||||
);
|
||||
|
||||
registry.addRecipeHandlers(
|
||||
new BreweryRecipeHandler(),
|
||||
new PureDaisyRecipeHandler(),
|
||||
new PetalApothecaryRecipeHandler(),
|
||||
new ElvenTradeRecipeHandler()
|
||||
new ElvenTradeRecipeHandler(),
|
||||
new RunicAltarRecipeHandler(),
|
||||
new ManaPoolRecipeHandler()
|
||||
);
|
||||
|
||||
registry.addRecipes(BotaniaAPI.brewRecipes);
|
||||
registry.addRecipes(BotaniaAPI.pureDaisyRecipes);
|
||||
registry.addRecipes(BotaniaAPI.petalRecipes);
|
||||
registry.addRecipes(BotaniaAPI.elvenTradeRecipes);
|
||||
registry.addRecipes(BotaniaAPI.runeAltarRecipes);
|
||||
registry.addRecipes(BotaniaAPI.manaInfusionRecipes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRecipeRegistryAvailable(IRecipeRegistry recipeRegistry) {
|
||||
|
||||
}
|
||||
public void onRecipeRegistryAvailable(IRecipeRegistry recipeRegistry) {}
|
||||
|
||||
}
|
||||
+24
-19
@@ -61,27 +61,32 @@ public class BreweryRecipeCategory implements IRecipeCategory {
|
||||
|
||||
@Override
|
||||
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) {
|
||||
recipeLayout.getItemStacks().init(slotContainerInput, true, 39, 41);
|
||||
recipeLayout.getItemStacks().init(slotIngredient1, true, 64, 6);
|
||||
recipeLayout.getItemStacks().init(slotIngredient2, true, 80, 6);
|
||||
recipeLayout.getItemStacks().init(slotIngredient3, true, 96, 6);
|
||||
recipeLayout.getItemStacks().init(slotIngredient4, true, 112, 6);
|
||||
recipeLayout.getItemStacks().init(slotIngredient5, true, 128, 6);
|
||||
recipeLayout.getItemStacks().init(slotIngredient6, true, 144, 6);
|
||||
recipeLayout.getItemStacks().init(slotOutput, false, 87, 41);
|
||||
|
||||
if (!(recipeWrapper instanceof BreweryRecipeWrapper))
|
||||
return;
|
||||
BreweryRecipeWrapper wrapper = ((BreweryRecipeWrapper) recipeWrapper);
|
||||
|
||||
List inputs = wrapper.getInputs();
|
||||
for (int i = 0; i < inputs.size(); i++) {
|
||||
if (i > slotOutput) {
|
||||
break;
|
||||
}
|
||||
if (inputs.get(i) instanceof ItemStack) {
|
||||
recipeLayout.getItemStacks().set(i, ((ItemStack) inputs.get(i)));
|
||||
} else if (inputs.get(i) instanceof Collection) {
|
||||
recipeLayout.getItemStacks().set(i, ((Collection<ItemStack>) inputs.get(i)));
|
||||
}
|
||||
|
||||
recipeLayout.getItemStacks().init(0, true, 39, 41);
|
||||
if (inputs.get(0) instanceof ItemStack) {
|
||||
recipeLayout.getItemStacks().set(0, ((ItemStack) inputs.get(0)));
|
||||
} else {
|
||||
recipeLayout.getItemStacks().set(0, ((Collection<ItemStack>) inputs.get(0)));
|
||||
}
|
||||
recipeLayout.getItemStacks().set(slotOutput, wrapper.getOutputs().get(0));
|
||||
|
||||
int index = 1, posX = 60;
|
||||
for (Object o : wrapper.getInputs()) {
|
||||
recipeLayout.getItemStacks().init(index, true, posX, 6);
|
||||
if (o instanceof ItemStack) {
|
||||
recipeLayout.getItemStacks().set(index, ((ItemStack) o));
|
||||
} else if (o instanceof Collection) {
|
||||
recipeLayout.getItemStacks().set(index, ((Collection<ItemStack>) o));
|
||||
}
|
||||
index++;
|
||||
posX += 18;
|
||||
}
|
||||
|
||||
recipeLayout.getItemStacks().init(7, false, 87, 41);
|
||||
recipeLayout.getItemStacks().set(7, wrapper.getOutputs().get(0));
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -16,7 +16,7 @@ import java.util.List;
|
||||
public class BreweryRecipeWrapper implements IRecipeWrapper {
|
||||
|
||||
private final List input;
|
||||
private final List<ItemStack> output;
|
||||
private final ItemStack output;
|
||||
|
||||
public BreweryRecipeWrapper(RecipeBrew recipeBrew) {
|
||||
ImmutableList.Builder builder = ImmutableList.builder();
|
||||
@@ -31,7 +31,7 @@ public class BreweryRecipeWrapper implements IRecipeWrapper {
|
||||
}
|
||||
|
||||
input = builder.build();
|
||||
output = ImmutableList.of(recipeBrew.getOutput(new ItemStack(ModItems.vial)).copy(), new ItemStack(ModBlocks.brewery));
|
||||
output = recipeBrew.getOutput(new ItemStack(ModItems.vial)).copy();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -41,7 +41,7 @@ public class BreweryRecipeWrapper implements IRecipeWrapper {
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getOutputs() {
|
||||
return output;
|
||||
return ImmutableList.of(output);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
-1
@@ -17,7 +17,6 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import vazkii.botania.client.core.handler.RenderEventHandler;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collection;
|
||||
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
package vazkii.botania.client.integration.jei.manapool;
|
||||
|
||||
import mezz.jei.api.IGuiHelper;
|
||||
import mezz.jei.api.gui.IDrawable;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.recipe.IRecipeCategory;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.Collection;
|
||||
|
||||
public class ManaPoolRecipeCategory implements IRecipeCategory {
|
||||
|
||||
private final IDrawable background;
|
||||
private final String localizedName;
|
||||
private final IDrawable overlay;
|
||||
|
||||
public ManaPoolRecipeCategory(IGuiHelper guiHelper) {
|
||||
background = guiHelper.createBlankDrawable(168, 64);
|
||||
localizedName = StatCollector.translateToLocal("botania.nei.manaPool");
|
||||
overlay = guiHelper.createDrawable(new ResourceLocation("botania", "textures/gui/pureDaisyOverlay.png"),
|
||||
0, 0, 64, 46);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getUid() {
|
||||
return "botania.manaPool";
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return localizedName;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IDrawable getBackground() {
|
||||
return background;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(Minecraft minecraft) {
|
||||
GlStateManager.enableAlpha();
|
||||
GlStateManager.enableBlend();
|
||||
overlay.draw(minecraft, 48, 0);
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.disableAlpha();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawAnimations(Minecraft minecraft) {}
|
||||
|
||||
@Override
|
||||
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) {
|
||||
if (!(recipeWrapper instanceof ManaPoolRecipeWrapper))
|
||||
return;
|
||||
|
||||
ManaPoolRecipeWrapper wrapper = ((ManaPoolRecipeWrapper) recipeWrapper);
|
||||
int index = 0;
|
||||
|
||||
recipeLayout.getItemStacks().init(index, true, 40, 12);
|
||||
if (wrapper.getInputs().get(0) instanceof Collection) {
|
||||
recipeLayout.getItemStacks().set(index, ((Collection<ItemStack>) wrapper.getInputs().get(0)));
|
||||
} else {
|
||||
recipeLayout.getItemStacks().set(index, ((ItemStack) wrapper.getInputs().get(0)));
|
||||
}
|
||||
|
||||
index++;
|
||||
|
||||
if (wrapper.getInputs().size() > 1) {
|
||||
// Has catalyst
|
||||
recipeLayout.getItemStacks().init(index, true, 20, 12);
|
||||
recipeLayout.getItemStacks().set(index, ((ItemStack) wrapper.getInputs().get(1)));
|
||||
index++;
|
||||
}
|
||||
|
||||
recipeLayout.getItemStacks().init(index, true, 70, 12);
|
||||
recipeLayout.getItemStacks().set(index, new ItemStack(ModBlocks.pool, 1, 0));
|
||||
index++;
|
||||
|
||||
recipeLayout.getItemStacks().init(index, false, 99, 12);
|
||||
if (wrapper.getOutputs().get(0) instanceof Collection) {
|
||||
recipeLayout.getItemStacks().set(index, ((Collection<ItemStack>) wrapper.getOutputs().get(0)));
|
||||
} else {
|
||||
recipeLayout.getItemStacks().set(index, ((ItemStack) wrapper.getOutputs().get(0)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package vazkii.botania.client.integration.jei.manapool;
|
||||
|
||||
import mezz.jei.api.recipe.IRecipeHandler;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import vazkii.botania.api.recipe.RecipeManaInfusion;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class ManaPoolRecipeHandler implements IRecipeHandler<RecipeManaInfusion> {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Class<RecipeManaInfusion> getRecipeClass() {
|
||||
return RecipeManaInfusion.class;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getRecipeCategoryUid() {
|
||||
return "botania.manaPool";
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IRecipeWrapper getRecipeWrapper(@Nonnull RecipeManaInfusion recipe) {
|
||||
return new ManaPoolRecipeWrapper(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRecipeValid(@Nonnull RecipeManaInfusion recipe) {
|
||||
return recipe.getManaToConsume() <= 100000;
|
||||
}
|
||||
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
package vazkii.botania.client.integration.jei.manapool;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
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 javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
|
||||
public class ManaPoolRecipeWrapper implements IRecipeWrapper {
|
||||
|
||||
private final List input;
|
||||
private final ItemStack output;
|
||||
private final int mana;
|
||||
|
||||
public ManaPoolRecipeWrapper(RecipeManaInfusion recipe) {
|
||||
ImmutableList.Builder builder = ImmutableList.builder();
|
||||
|
||||
if (recipe.getInput() instanceof ItemStack) {
|
||||
builder.add(recipe.getInput());
|
||||
} else if (recipe.getInput() instanceof String) {
|
||||
builder.add(OreDictionary.getOres(((String) recipe.getInput())));
|
||||
}
|
||||
|
||||
if (recipe.isAlchemy()) {
|
||||
builder.add(new ItemStack(ModBlocks.alchemyCatalyst));
|
||||
} else if (recipe.isConjuration()) {
|
||||
builder.add(new ItemStack(ModBlocks.conjurationCatalyst));
|
||||
}
|
||||
|
||||
input = builder.build();
|
||||
output = recipe.getOutput();
|
||||
mana = recipe.getManaToConsume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getInputs() {
|
||||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getOutputs() {
|
||||
return ImmutableList.of(output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FluidStack> getFluidInputs() {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FluidStack> getFluidOutputs() {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight) {
|
||||
GlStateManager.enableAlpha();
|
||||
HUDHandler.renderManaBar(28, 50, 0x0000FF, 0.75F, mana, TilePool.MAX_MANA / 10);
|
||||
GlStateManager.disableAlpha();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawAnimations(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight) {}
|
||||
|
||||
}
|
||||
+1
-1
@@ -54,7 +54,7 @@ public class PetalApothecaryRecipeCategory implements IRecipeCategory {
|
||||
public void drawExtras(Minecraft minecraft) {
|
||||
GlStateManager.enableAlpha();
|
||||
GlStateManager.enableBlend();
|
||||
overlay.draw(minecraft, 0, 0);
|
||||
overlay.draw(minecraft);
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.disableAlpha();
|
||||
}
|
||||
|
||||
+14
-18
@@ -19,13 +19,9 @@ import java.util.Collection;
|
||||
|
||||
public class PureDaisyRecipeCategory implements IRecipeCategory {
|
||||
|
||||
private final IDrawableStatic background;
|
||||
private final IDrawable background;
|
||||
private final String localizedName;
|
||||
private final IDrawableStatic overlay;
|
||||
|
||||
private static final int inputSlot = 0;
|
||||
private static final int pureDaisySlot = 1;
|
||||
private static final int outputSlot = 2;
|
||||
private final IDrawable overlay;
|
||||
|
||||
public PureDaisyRecipeCategory(IGuiHelper guiHelper) {
|
||||
background = guiHelper.createBlankDrawable(168, 64);
|
||||
@@ -75,29 +71,29 @@ public class PureDaisyRecipeCategory implements IRecipeCategory {
|
||||
|
||||
|
||||
if (inputFluid) {
|
||||
recipeLayout.getFluidStacks().init(inputSlot, true, 40, 12, 16, 16, 1000, false, null);
|
||||
recipeLayout.getFluidStacks().set(inputSlot, wrapper.getFluidInputs().get(0));
|
||||
recipeLayout.getFluidStacks().init(0, true, 40, 12, 16, 16, 1000, false, null);
|
||||
recipeLayout.getFluidStacks().set(0, wrapper.getFluidInputs().get(0));
|
||||
} else {
|
||||
recipeLayout.getItemStacks().init(inputSlot, true, 40, 12);
|
||||
recipeLayout.getItemStacks().init(0, true, 40, 12);
|
||||
if (wrapper.getInputs().get(0) instanceof Collection) {
|
||||
recipeLayout.getItemStacks().set(inputSlot, ((Collection<ItemStack>) wrapper.getInputs().get(0)));
|
||||
recipeLayout.getItemStacks().set(0, ((Collection<ItemStack>) wrapper.getInputs().get(0)));
|
||||
} else {
|
||||
recipeLayout.getItemStacks().set(inputSlot, ((ItemStack) wrapper.getInputs().get(0)));
|
||||
recipeLayout.getItemStacks().set(0, ((ItemStack) wrapper.getInputs().get(0)));
|
||||
}
|
||||
}
|
||||
|
||||
recipeLayout.getItemStacks().init(pureDaisySlot, true, 72, 12);
|
||||
recipeLayout.getItemStacks().set(pureDaisySlot, ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_PUREDAISY));
|
||||
recipeLayout.getItemStacks().init(1, true, 70, 12);
|
||||
recipeLayout.getItemStacks().set(1, ItemBlockSpecialFlower.ofType(LibBlockNames.SUBTILE_PUREDAISY));
|
||||
|
||||
if (outputFluid) {
|
||||
recipeLayout.getFluidStacks().init(outputSlot, false, 99, 12, 16, 16, 1000, false, null);
|
||||
recipeLayout.getFluidStacks().set(outputSlot, wrapper.getFluidOutputs().get(0));
|
||||
recipeLayout.getFluidStacks().init(2, false, 99, 12, 16, 16, 1000, false, null);
|
||||
recipeLayout.getFluidStacks().set(2, wrapper.getFluidOutputs().get(0));
|
||||
} else {
|
||||
recipeLayout.getItemStacks().init(outputSlot, false, 99, 12);
|
||||
recipeLayout.getItemStacks().init(2, false, 99, 12);
|
||||
if (wrapper.getOutputs().get(0) instanceof Collection) {
|
||||
recipeLayout.getItemStacks().set(outputSlot, ((Collection<ItemStack>) wrapper.getOutputs().get(0)));
|
||||
recipeLayout.getItemStacks().set(2, ((Collection<ItemStack>) wrapper.getOutputs().get(0)));
|
||||
} else {
|
||||
recipeLayout.getItemStacks().set(outputSlot, ((ItemStack) wrapper.getOutputs().get(0)));
|
||||
recipeLayout.getItemStacks().set(2, ((ItemStack) wrapper.getOutputs().get(0)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
package vazkii.botania.client.integration.jei.runicaltar;
|
||||
|
||||
import mezz.jei.api.IGuiHelper;
|
||||
import mezz.jei.api.gui.IDrawable;
|
||||
import mezz.jei.api.gui.IRecipeLayout;
|
||||
import mezz.jei.api.recipe.IRecipeCategory;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.awt.*;
|
||||
import java.util.Collection;
|
||||
|
||||
public class RunicAltarRecipeCategory implements IRecipeCategory {
|
||||
|
||||
private final IDrawable background;
|
||||
private final String localizedName;
|
||||
private final IDrawable overlay;
|
||||
|
||||
public RunicAltarRecipeCategory(IGuiHelper guiHelper) {
|
||||
background = guiHelper.createBlankDrawable(150, 110);
|
||||
localizedName = StatCollector.translateToLocal("botania.nei.runicAltar");
|
||||
overlay = guiHelper.createDrawable(new ResourceLocation("botania", "textures/gui/petalOverlay.png"),
|
||||
0, 0, 150, 110);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getUid() {
|
||||
return "botania.runicAltar";
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return localizedName;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IDrawable getBackground() {
|
||||
return background;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawExtras(Minecraft minecraft) {
|
||||
GlStateManager.enableAlpha();
|
||||
GlStateManager.enableBlend();
|
||||
overlay.draw(minecraft);
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.disableAlpha();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawAnimations(Minecraft minecraft) {}
|
||||
|
||||
@Override
|
||||
public void setRecipe(@Nonnull IRecipeLayout recipeLayout, @Nonnull IRecipeWrapper recipeWrapper) {
|
||||
if (!(recipeWrapper instanceof RunicAltarRecipeWrapper))
|
||||
return;
|
||||
RunicAltarRecipeWrapper wrapper = ((RunicAltarRecipeWrapper) recipeWrapper);
|
||||
|
||||
recipeLayout.getItemStacks().init(0, true, 64, 52);
|
||||
recipeLayout.getItemStacks().set(0, new ItemStack(ModBlocks.runeAltar));
|
||||
|
||||
int index = 1;
|
||||
double angleBetweenEach = 360.0 / wrapper.getInputs().size();
|
||||
Point point = new Point(64, 20), center = new Point(64, 52);
|
||||
|
||||
for (Object o : wrapper.getInputs()) {
|
||||
recipeLayout.getItemStacks().init(index, true, point.x, point.y);
|
||||
if (o instanceof Collection) {
|
||||
recipeLayout.getItemStacks().set(index, ((Collection<ItemStack>) o));
|
||||
}
|
||||
if (o instanceof ItemStack) {
|
||||
recipeLayout.getItemStacks().set(index, ((ItemStack) o));
|
||||
}
|
||||
index += 1;
|
||||
point = rotatePointAbout(point, center, angleBetweenEach);
|
||||
}
|
||||
|
||||
recipeLayout.getItemStacks().init(index, false, 103, 17);
|
||||
recipeLayout.getItemStacks().set(index, wrapper.getOutputs().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));
|
||||
}
|
||||
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package vazkii.botania.client.integration.jei.runicaltar;
|
||||
|
||||
import mezz.jei.api.recipe.IRecipeHandler;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import vazkii.botania.api.recipe.RecipeRuneAltar;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public class RunicAltarRecipeHandler implements IRecipeHandler<RecipeRuneAltar> {
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Class<RecipeRuneAltar> getRecipeClass() {
|
||||
return RecipeRuneAltar.class;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getRecipeCategoryUid() {
|
||||
return "botania.runicAltar";
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IRecipeWrapper getRecipeWrapper(@Nonnull RecipeRuneAltar recipe) {
|
||||
return new RunicAltarRecipeWrapper(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRecipeValid(@Nonnull RecipeRuneAltar recipe) {
|
||||
return recipe.getInputs().size() <= 16;
|
||||
}
|
||||
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
package vazkii.botania.client.integration.jei.runicaltar;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import mezz.jei.api.recipe.IRecipeWrapper;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import vazkii.botania.api.recipe.RecipeRuneAltar;
|
||||
import vazkii.botania.client.core.handler.HUDHandler;
|
||||
import vazkii.botania.common.block.tile.mana.TilePool;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
|
||||
public class RunicAltarRecipeWrapper implements IRecipeWrapper {
|
||||
|
||||
private final List input;
|
||||
private final ItemStack output;
|
||||
private final int manaUsage;
|
||||
|
||||
public RunicAltarRecipeWrapper(RecipeRuneAltar recipe) {
|
||||
ImmutableList.Builder builder = ImmutableList.builder();
|
||||
for (Object o : recipe.getInputs()) {
|
||||
if (o instanceof ItemStack) {
|
||||
builder.add(o);
|
||||
}
|
||||
if (o instanceof String) {
|
||||
builder.add(OreDictionary.getOres(((String) o)));
|
||||
}
|
||||
}
|
||||
input = builder.build();
|
||||
output = recipe.getOutput();
|
||||
manaUsage = recipe.getManaUsage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getInputs() {
|
||||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getOutputs() {
|
||||
return ImmutableList.of(output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FluidStack> getFluidInputs() {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FluidStack> getFluidOutputs() {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawInfo(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight) {
|
||||
GlStateManager.enableAlpha();
|
||||
HUDHandler.renderManaBar(28, 113, 0x0000FF, 0.75F, manaUsage, TilePool.MAX_MANA / 10);
|
||||
GlStateManager.disableAlpha();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawAnimations(@Nonnull Minecraft minecraft, int recipeWidth, int recipeHeight) {}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user