Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Arcaratus 2015-06-12 15:12:22 -04:00
commit 4f9acb223f
124 changed files with 4228 additions and 288 deletions

View file

@ -0,0 +1,135 @@
package WayofTime.alchemicalWizardry.api.guide;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import WayofTime.alchemicalWizardry.api.items.ShapedBloodOrbRecipe;
import WayofTime.alchemicalWizardry.api.items.ShapelessBloodOrbRecipe;
import WayofTime.alchemicalWizardry.api.spell.APISpellHelper;
import amerifrance.guideapi.ModInformation;
import amerifrance.guideapi.api.abstraction.CategoryAbstract;
import amerifrance.guideapi.api.abstraction.EntryAbstract;
import amerifrance.guideapi.api.abstraction.IRecipeRenderer;
import amerifrance.guideapi.api.base.Book;
import amerifrance.guideapi.api.util.GuiHelper;
import amerifrance.guideapi.gui.GuiBase;
import cpw.mods.fml.relauncher.ReflectionHelper;
public class OrbRecipeRenderer implements IRecipeRenderer
{
public IRecipe recipe;
public OrbRecipeRenderer(IRecipe recipe)
{
this.recipe = recipe;
}
@Override
public void draw(Book book, CategoryAbstract category, EntryAbstract entry,
int guiLeft, int guiTop, int mouseX, int mouseY, GuiBase guiBase,
FontRenderer fontRenderer) {
Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation(ModInformation.GUITEXLOC + "recipe_elements.png"));
guiBase.drawTexturedModalRect(guiLeft + 42, guiTop + 53, 0, 0, 105, 65);
guiBase.drawCenteredString(fontRenderer, StatCollector.translateToLocal("text.recipe.shapedOrb"), guiLeft + guiBase.xSize / 2, guiTop + 12, 0);
if(recipe instanceof ShapelessBloodOrbRecipe)
{
ShapelessBloodOrbRecipe shapelessBloodOrbRecipe = (ShapelessBloodOrbRecipe) recipe;
List<Object> list = shapelessBloodOrbRecipe.getInput();
int width = 3;
int height = 3;
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
if(list.size() - 1 < y * width + x)
{
continue;
}
int stackX = (x + 1) * 18 + (guiLeft + guiBase.xSize / 7);
int stackY = (y + 1) * 18 + (guiTop + guiBase.ySize / 5);
Object component = list.get(y * width + x);
if (component != null) {
if (component instanceof ItemStack) {
GuiHelper.drawItemStack((ItemStack) component, stackX, stackY);
if (GuiHelper.isMouseBetween(mouseX, mouseY, stackX, stackY, 15, 15)) {
guiBase.renderToolTip((ItemStack) component, stackX, stackY);
}
} else if (component instanceof Integer) {
GuiHelper.drawItemStack(APISpellHelper.getOrbForLevel((Integer) component), stackX, stackY);
if (GuiHelper.isMouseBetween(mouseX, mouseY, stackX, stackY, 15, 15)) {
guiBase.renderToolTip(APISpellHelper.getOrbForLevel((Integer) component), stackX, stackY);
}
} else {
if (((ArrayList<ItemStack>) component).isEmpty()) return;
GuiHelper.drawItemStack(((ArrayList<ItemStack>) component).get(0), stackX, stackY);
if (GuiHelper.isMouseBetween(mouseX, mouseY, stackX, stackY, 15, 15)) {
guiBase.renderToolTip(((ArrayList<ItemStack>) component).get(0), stackX, stackY);
}
}
}
}
}
int outputX = (5 * 18) + (guiLeft + guiBase.xSize / 7);
int outputY = (2 * 18) + (guiTop + guiBase.xSize / 5);
GuiHelper.drawItemStack(shapelessBloodOrbRecipe.getRecipeOutput(), outputX, outputY);
if (GuiHelper.isMouseBetween(mouseX, mouseY, outputX, outputY, 15, 15)) {
guiBase.renderToolTip(shapelessBloodOrbRecipe.getRecipeOutput(), outputX, outputY);
}
}else
{
ShapedBloodOrbRecipe shapedBloodOrbRecipe = (ShapedBloodOrbRecipe) recipe;
int width = ReflectionHelper.getPrivateValue(ShapedBloodOrbRecipe.class, shapedBloodOrbRecipe, 4);
int height = ReflectionHelper.getPrivateValue(ShapedBloodOrbRecipe.class, shapedBloodOrbRecipe, 5);
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
int stackX = (x + 1) * 18 + (guiLeft + guiBase.xSize / 7);
int stackY = (y + 1) * 18 + (guiTop + guiBase.ySize / 5);
Object component = shapedBloodOrbRecipe.getInput()[y * width + x];
if (component != null) {
if (component instanceof ItemStack) {
GuiHelper.drawItemStack((ItemStack) component, stackX, stackY);
if (GuiHelper.isMouseBetween(mouseX, mouseY, stackX, stackY, 15, 15)) {
guiBase.renderToolTip((ItemStack) component, stackX, stackY);
}
} else if (component instanceof Integer) {
GuiHelper.drawItemStack(APISpellHelper.getOrbForLevel((Integer) component), stackX, stackY);
if (GuiHelper.isMouseBetween(mouseX, mouseY, stackX, stackY, 15, 15)) {
guiBase.renderToolTip(APISpellHelper.getOrbForLevel((Integer) component), stackX, stackY);
}
} else {
if (((ArrayList<ItemStack>) component).isEmpty()) return;
GuiHelper.drawItemStack(((ArrayList<ItemStack>) component).get(0), stackX, stackY);
if (GuiHelper.isMouseBetween(mouseX, mouseY, stackX, stackY, 15, 15)) {
guiBase.renderToolTip(((ArrayList<ItemStack>) component).get(0), stackX, stackY);
}
}
}
}
}
int outputX = (5 * 18) + (guiLeft + guiBase.xSize / 7);
int outputY = (2 * 18) + (guiTop + guiBase.xSize / 5);
GuiHelper.drawItemStack(shapedBloodOrbRecipe.getRecipeOutput(), outputX, outputY);
if (GuiHelper.isMouseBetween(mouseX, mouseY, outputX, outputY, 15, 15)) {
guiBase.renderToolTip(shapedBloodOrbRecipe.getRecipeOutput(), outputX, outputY);
}
}
}
@Override
public void drawExtras(Book book, CategoryAbstract category,
EntryAbstract entry, int guiLeft, int guiTop, int mouseX,
int mouseY, GuiBase guiBase, FontRenderer fontRenderer) {
// TODO Auto-generated method stub
}
}

View file

@ -0,0 +1,145 @@
package WayofTime.alchemicalWizardry.api.guide;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.item.ItemStack;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import amerifrance.guideapi.api.abstraction.CategoryAbstract;
import amerifrance.guideapi.api.abstraction.EntryAbstract;
import amerifrance.guideapi.api.base.Book;
import amerifrance.guideapi.api.base.PageBase;
import amerifrance.guideapi.gui.GuiBase;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class PageMultiBlock extends PageBase
{
ItemStack[][][] structure;
boolean canTick = false;
int tick = 0;
int showLayer = -1;
float scaleFactor = 1;
boolean renderMouseOver = true;
public PageMultiBlock(ItemStack[][][] structure)
{
this.structure = structure;
initPage(structure);
}
int blockCount=0;
int[] countPerLevel;
int structureHeight = 0;
int structureLength = 0;
int structureWidth = 0;
public void initPage(ItemStack[][][] structure)
{
structureHeight = structure.length;
structureWidth=0;
structureLength=0;
countPerLevel = new int[structureHeight];
blockCount=0;
for(int h=0; h<structure.length; h++)
{
if(structure[h].length-1>structureLength)
structureLength = structure[h].length-1;
int perLvl=0;
for(int l=0; l<structure[h].length; l++)
{
if(structure[h][l].length-1>structureWidth)
structureWidth = structure[h][l].length-1;
for(ItemStack ss : structure[h][l])
if(ss!=null)
perLvl++;
}
countPerLevel[h] = perLvl;
blockCount += perLvl;
}
tick= (showLayer==-1?blockCount:countPerLevel[showLayer])*40;
int yOff = (structureHeight-1)*12+structureWidth*5+structureLength*5+16;
// pageButtons.add(new GuiButtonManualNavigation(gui, 100, x+4,y+yOff/2-5, 10,10, 4));
// pageButtons.add(new GuiButtonManualNavigation(gui, 101, x+4,y+yOff/2-8-16, 10,16, 3));
// pageButtons.add(new GuiButtonManualNavigation(gui, 102, x+4,y+yOff/2+8, 10,16, 2));
}
@Override
@SideOnly(Side.CLIENT)
public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, GuiBase guiBase, FontRenderer fontRenderer)
{
// if(multiblock.getStructureManual()!=null)
Minecraft mc = Minecraft.getMinecraft();
int x = guiLeft + 32;
int y = guiTop + 30;
{
if(canTick)
tick++;
int prevLayers = 0;
if(showLayer!=-1)
for(int ll=0; ll<showLayer; ll++)
prevLayers+=countPerLevel[ll];
int limiter = prevLayers+ (tick/40)% ((showLayer==-1?blockCount:countPerLevel[showLayer])+4);
int xHalf = (structureWidth*5 - structureLength*5);
int yOffPartial = (structureHeight-1)*12+structureWidth*5+structureLength*5;
int yOffTotal = yOffPartial+16;
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glPushMatrix();
GL11.glTranslatef((1-scaleFactor)*(guiLeft + 64), (1-scaleFactor)*(guiTop+60), 0);
GL11.glScalef(scaleFactor, scaleFactor, scaleFactor);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
RenderHelper.enableGUIStandardItemLighting();
RenderItem.getInstance().renderWithColor=true;
int i=0;
ItemStack highlighted = null;
for(int h=0; h<structure.length; h++)
if(showLayer==-1 || h<=showLayer)
{
ItemStack[][] level = structure[h];
for(int l=level.length-1; l>=0; l--)
{
ItemStack[] row = level[l];
for(int w=row.length-1; w>=0; w--)
{
int xx = 60 +xHalf -10*w +10*l -7;
int yy = yOffPartial - 5*w - 5*l -12*h;
GL11.glTranslated(0, 0, 1);
if(row[w]!=null && i<=limiter)
{
i++;
RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, row[w], x+xx, y+yy);
if(mouseX>=x+xx&&mouseX<x+xx+16 && mouseY>=y+yy&&mouseY<y+yy+16)
highlighted = row[w];
}
}
}
}
GL11.glTranslated(0, 0, -i);
RenderHelper.disableStandardItemLighting();
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
GL11.glPopMatrix();
GL11.glEnable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_DEPTH_TEST);
mc.fontRenderer.setUnicodeFlag(false);
if(highlighted!=null && renderMouseOver)
guiBase.renderToolTip(highlighted, mouseX, mouseY);
RenderHelper.disableStandardItemLighting();
// mc.fontRenderer.setUnicodeFlag(true);
// if(localizedText!=null&&!localizedText.isEmpty())
// manual.fontRenderer.drawSplitString(localizedText, x,y+yOffTotal, 120, manual.getTextColour());
}
}
}

View file

@ -1,78 +0,0 @@
package WayofTime.alchemicalWizardry.api.guide;
import java.util.ArrayList;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import WayofTime.alchemicalWizardry.api.items.ShapedBloodOrbRecipe;
import WayofTime.alchemicalWizardry.api.spell.APISpellHelper;
import amerifrance.guideapi.ModInformation;
import amerifrance.guideapi.api.abstraction.CategoryAbstract;
import amerifrance.guideapi.api.abstraction.EntryAbstract;
import amerifrance.guideapi.api.base.Book;
import amerifrance.guideapi.api.util.GuiHelper;
import amerifrance.guideapi.gui.GuiBase;
import amerifrance.guideapi.pages.PageIRecipe;
import cpw.mods.fml.relauncher.ReflectionHelper;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class PageOrbRecipe extends PageIRecipe {
/**
* @param recipe - Recipe to draw
*/
public PageOrbRecipe(IRecipe recipe)
{
super(recipe);
}
@Override
@SideOnly(Side.CLIENT)
public void draw(Book book, CategoryAbstract category, EntryAbstract entry, int guiLeft, int guiTop, int mouseX, int mouseY, GuiBase guiBase, FontRenderer fontRenderer) {
Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation(ModInformation.GUITEXLOC + "recipe_elements.png"));
guiBase.drawTexturedModalRect(guiLeft + 42, guiTop + 53, 0, 0, 105, 65);
guiBase.drawCenteredString(fontRenderer, StatCollector.translateToLocal("text.recipe.shapedOrb"), guiLeft + guiBase.xSize / 2, guiTop + 12, 0);
ShapedBloodOrbRecipe shapedBloodOrbRecipe = (ShapedBloodOrbRecipe) recipe;
int width = ReflectionHelper.getPrivateValue(ShapedBloodOrbRecipe.class, shapedBloodOrbRecipe, 4);
int height = ReflectionHelper.getPrivateValue(ShapedBloodOrbRecipe.class, shapedBloodOrbRecipe, 5);
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
int stackX = (x + 1) * 20 + (guiLeft + guiBase.xSize / 7);
int stackY = (y + 1) * 20 + (guiTop + guiBase.ySize / 5);
Object component = shapedBloodOrbRecipe.getInput()[y * width + x];
if (component != null) {
if (component instanceof ItemStack) {
GuiHelper.drawItemStack((ItemStack) component, stackX, stackY);
if (GuiHelper.isMouseBetween(mouseX, mouseY, stackX, stackY, 15, 15)) {
guiBase.renderToolTip((ItemStack) component, stackX, stackY);
}
} else if (component instanceof Integer) {
GuiHelper.drawItemStack(APISpellHelper.getOrbForLevel((Integer) component), stackX, stackY);
if (GuiHelper.isMouseBetween(mouseX, mouseY, stackX, stackY, 15, 15)) {
guiBase.renderToolTip(APISpellHelper.getOrbForLevel((Integer) component), stackX, stackY);
}
} else {
if (((ArrayList<ItemStack>) component).isEmpty()) return;
GuiHelper.drawItemStack(((ArrayList<ItemStack>) component).get(0), stackX, stackY);
if (GuiHelper.isMouseBetween(mouseX, mouseY, stackX, stackY, 15, 15)) {
guiBase.renderToolTip(((ArrayList<ItemStack>) component).get(0), stackX, stackY);
}
}
}
}
}
int outputX = (5 * 20) + (guiLeft + guiBase.xSize / 7);
int outputY = (2 * 20) + (guiTop + guiBase.xSize / 5);
GuiHelper.drawItemStack(shapedBloodOrbRecipe.getRecipeOutput(), outputX, outputY);
if (GuiHelper.isMouseBetween(mouseX, mouseY, outputX, outputY, 15, 15)) {
guiBase.renderToolTip(shapedBloodOrbRecipe.getRecipeOutput(), outputX, outputY);
}
}
}

View file

@ -0,0 +1,96 @@
package WayofTime.alchemicalWizardry.api.guide;
import java.util.List;
import net.minecraft.item.ItemStack;
import WayofTime.alchemicalWizardry.ModBlocks;
import WayofTime.alchemicalWizardry.api.rituals.RitualComponent;
import WayofTime.alchemicalWizardry.api.rituals.Rituals;
public class PageRitualMultiBlock extends PageMultiBlock
{
private static ItemStack blankStone;
private static ItemStack waterStone;
private static ItemStack fireStone;
private static ItemStack earthStone;
private static ItemStack airStone;
private static ItemStack duskStone;
private static ItemStack dawnStone;
static
{
blankStone = new ItemStack(ModBlocks.ritualStone, 1, RitualComponent.BLANK);
waterStone = new ItemStack(ModBlocks.ritualStone, 1, RitualComponent.WATER);
fireStone = new ItemStack(ModBlocks.ritualStone, 1, RitualComponent.FIRE);
earthStone = new ItemStack(ModBlocks.ritualStone, 1, RitualComponent.EARTH);
airStone = new ItemStack(ModBlocks.ritualStone, 1, RitualComponent.AIR);
duskStone = new ItemStack(ModBlocks.ritualStone, 1, RitualComponent.DUSK);
dawnStone = new ItemStack(ModBlocks.ritualStone, 1, RitualComponent.DAWN);
}
private PageRitualMultiBlock(ItemStack[][][] structure)
{
super(structure);
}
public static PageRitualMultiBlock getPageForRitual(String ritualID)
{
return getPageForRitual(Rituals.getRitualList(ritualID));
}
public static PageRitualMultiBlock getPageForRitual(List<RitualComponent> ritualComponents)
{
int minX = 0;
int minY = 0;
int minZ = 0;
int maxX = 0;
int maxY = 0;
int maxZ = 0;
for(RitualComponent comp : ritualComponents)
{
minX = Math.min(comp.getX(), minX);
minY = Math.min(comp.getY(), minY);
minZ = Math.min(comp.getZ(), minZ);
maxX = Math.max(comp.getX(), maxX);
maxY = Math.max(comp.getY(), maxY);
maxZ = Math.max(comp.getZ(), maxZ);
}
System.out.println("Min: (" + minX + ", " + minY + ", " + minZ + "), Max: (" + maxX + ", " + maxY + ", " + maxZ + ")");
ItemStack[][][] tempStructure = new ItemStack[maxY-minY+1][maxX-minX+1][maxZ-minZ+1]; //First value is vertical, second is down to the left, third is down to the right
for(RitualComponent comp : ritualComponents)
{
tempStructure[comp.getY() - minY][comp.getX() - minX][comp.getZ() - minZ] = getStackForRitualStone(comp.getStoneType());
}
tempStructure[-minY][-minX][-minZ] = new ItemStack(ModBlocks.blockMasterStone);
return new PageRitualMultiBlock(tempStructure);
}
private static ItemStack getStackForRitualStone(int type)
{
switch(type)
{
case RitualComponent.BLANK:
return blankStone;
case RitualComponent.WATER:
return waterStone;
case RitualComponent.FIRE:
return fireStone;
case RitualComponent.EARTH:
return earthStone;
case RitualComponent.AIR:
return airStone;
case RitualComponent.DUSK:
return duskStone;
case RitualComponent.DAWN:
return dawnStone;
}
return blankStone;
}
}

View file

@ -30,9 +30,11 @@ public class PlayerSacrificeHandler
return false;
}
amount = amount + Math.max(increment, max - amount);
amount = amount + Math.min(increment, max - amount);
setPlayerIncense(player, amount);
// System.out.println("Amount of incense: " + amount + ", Increment: " + increment);
return true;
}