Semi working petal apothecary itnegration

This commit is contained in:
Vincent Lee committed 2016-01-04 22:34:45 -06:00
1 parent 95118696ce
commit 9bf2e0c555
2 files changed
+29 -8

No files matched your search

@@ -7,6 +7,7 @@ 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;
@@ -15,6 +16,7 @@ import vazkii.botania.common.item.block.ItemBlockSpecialFlower;
import vazkii.botania.common.lib.LibBlockNames;
import javax.annotation.Nonnull;
import java.awt.*;
import java.util.Collection;
public class PetalApothecaryRecipeCategory implements IRecipeCategory {
@@ -24,10 +26,10 @@ public class PetalApothecaryRecipeCategory implements IRecipeCategory {
private final IDrawableStatic overlay;
public PetalApothecaryRecipeCategory(IGuiHelper guiHelper) {
background = guiHelper.createBlankDrawable(168, 64);
background = guiHelper.createBlankDrawable(150, 110);
localizedName = StatCollector.translateToLocal("botania.nei.petalApothecary");
overlay = guiHelper.createDrawable(new ResourceLocation("botania", "textures/gui/petalOverlay.png"),
0, 0, 64, 46);
0, 0, 150, 110);
}
@Nonnull
@@ -50,7 +52,11 @@ public class PetalApothecaryRecipeCategory implements IRecipeCategory {
@Override
public void drawExtras(Minecraft minecraft) {
overlay.draw(minecraft, 48, 0);
GlStateManager.enableAlpha();
GlStateManager.enableBlend();
overlay.draw(minecraft, 0, 0);
GlStateManager.disableBlend();
GlStateManager.disableAlpha();
}
@Override
@@ -62,24 +68,34 @@ public class PetalApothecaryRecipeCategory implements IRecipeCategory {
return;
PetalApothecaryRecipeWrapper wrapper = ((PetalApothecaryRecipeWrapper) recipeWrapper);
recipeLayout.getItemStacks().init(0, true, 0, 0);
recipeLayout.getItemStacks().init(0, true, 64, 52);
recipeLayout.getItemStacks().set(0, new ItemStack(ModBlocks.altar));
int index = 1, pos = 16;
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, pos, 0);
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));
}
pos += 16;
index += 1;
point = rotatePointAbout(point, center, angleBetweenEach);
}
recipeLayout.getItemStacks().init(index, false, 32, 0);
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));
}
}
@@ -7,6 +7,7 @@ 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;
@@ -53,7 +54,11 @@ public class PureDaisyRecipeCategory implements IRecipeCategory {
@Override
public void drawExtras(Minecraft minecraft) {
GlStateManager.enableAlpha();
GlStateManager.enableBlend();
overlay.draw(minecraft, 48, 0);
GlStateManager.disableBlend();
GlStateManager.disableAlpha();
}
@Override