diff options
| author | OnyxDarkKnight <sor1n.iliutza16@gmail.com> | 2013-12-23 22:03:06 +0200 |
|---|---|---|
| committer | OnyxDarkKnight <sor1n.iliutza16@gmail.com> | 2013-12-23 22:03:06 +0200 |
| commit | 198677e5b01009a65d243da1d25a14f879df659c (patch) | |
| tree | 512da4c4fbccc40fdcfc79a6f6cbf0f4eb0efd50 /common/darkknight/jewelrycraft/renders/TileEntityJewelrsCraftingTableRender.java | |
| parent | b01cf1aa1d3480ad52ee7940f213596bfe6a2090 (diff) | |
Changed lots of stuff, added new features. Ender Rings!!!
Diffstat (limited to 'common/darkknight/jewelrycraft/renders/TileEntityJewelrsCraftingTableRender.java')
| -rw-r--r-- | common/darkknight/jewelrycraft/renders/TileEntityJewelrsCraftingTableRender.java | 223 |
1 files changed, 87 insertions, 136 deletions
diff --git a/common/darkknight/jewelrycraft/renders/TileEntityJewelrsCraftingTableRender.java b/common/darkknight/jewelrycraft/renders/TileEntityJewelrsCraftingTableRender.java index e68699b..ec5271b 100644 --- a/common/darkknight/jewelrycraft/renders/TileEntityJewelrsCraftingTableRender.java +++ b/common/darkknight/jewelrycraft/renders/TileEntityJewelrsCraftingTableRender.java @@ -2,17 +2,16 @@ package darkknight.jewelrycraft.renders; import org.lwjgl.opengl.GL11; -import darkknight.jewelrycraft.item.ItemRing; import darkknight.jewelrycraft.model.ModelJewlersCraftingBench; import darkknight.jewelrycraft.tileentity.TileEntityJewelrsCraftingTable; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.entity.Entity; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.entity.item.EntityItem; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; @@ -30,7 +29,6 @@ public class TileEntityJewelrsCraftingTableRender extends TileEntitySpecialRende ResourceLocation blockTexture = new ResourceLocation("jewelrycraft", texture); Minecraft.getMinecraft().renderEngine.bindTexture(blockTexture); - Tessellator tessellator = Tessellator.instance; int block = te.getBlockMetadata(); TileEntityJewelrsCraftingTable jt = (TileEntityJewelrsCraftingTable)te; @@ -47,152 +45,105 @@ public class TileEntityJewelrsCraftingTableRender extends TileEntitySpecialRende GL11.glRotatef(180F, 1.0F, 0.0F, 1.0F); modelTable.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); - //GL11.glTranslatef(0.05F, 0F, -0.5F); if (jt != null) { - if (jt.hasJewel) + if (jt.hasJewelry && jt.jewelry.getIconIndex().getIconName() != "") { - if(jt.jewel.getIconIndex().getIconName() != "") - { - String domain = ""; - if(jt.jewel.getIconIndex().getIconName().substring(0, jt.jewel.getIconIndex().getIconName().indexOf(":") + 1) != "") - domain = jt.jewel.getIconIndex().getIconName().substring(0, jt.jewel.getIconIndex().getIconName().indexOf(":") + 1).replace(":", " ").trim(); - else - domain = "minecraft"; - String texture = jt.jewel.getIconIndex().getIconName().substring(jt.jewel.getIconIndex().getIconName().lastIndexOf(":") + 1) + ".png"; - ResourceLocation lava = new ResourceLocation(domain, "textures/items/" + texture); - Minecraft.getMinecraft().renderEngine.bindTexture(lava); - jt.jewel.getIconIndex().getInterpolatedU(0); - double minu = jt.jewel.getIconIndex().getInterpolatedU(0); - double minv = jt.jewel.getIconIndex().getInterpolatedV(-64); - double maxu = jt.jewel.getIconIndex().getInterpolatedU(256); - double maxv = jt.jewel.getIconIndex().getInterpolatedV(256 - 64); - GL11.glPushMatrix(); - GL11.glScalef(1f / 16f, 1f / 16f, 1f / 16f); - GL11.glDisable(GL11.GL_LIGHTING); - if (jt.jewel.hasTagCompound()) - { - if (jt.jewel.getTagCompound().hasKey("ingot")) - { - NBTTagCompound ingotNBT = (NBTTagCompound) jt.jewel.getTagCompound().getTag("ingot"); - ItemStack ingotStack = new ItemStack(0, 0, 0); - ingotStack.readFromNBT(ingotNBT); - ItemRing.addMetal(jt.jewel, ingotStack); - int color = jt.jewel.getItem().getColorFromItemStack(jt.jewel, 0); - float red = (float)(color >> 16 & 255) / 255.0F; - float green = (float)(color >> 8 & 255) / 255.0F; - float blue = (float)(color & 255) / 255.0F; - if(!jt.jewel.getDisplayName().contains("Ingot")) GL11.glColor4f(red, green, blue, 1F); - } - } - tessellator.startDrawingQuads(); - for(float f=0; f<=1; f+=0.1){ - tessellator.addVertexWithUV(3, 9, -5+f, minu, minv); - tessellator.addVertexWithUV(-2.2, 9, -5+f, maxu, minv); - tessellator.addVertexWithUV(-2.2, 14, -5+f, maxu, maxv); - tessellator.addVertexWithUV(3, 14, -5+f, minu, maxv); + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + EntityItem entityitem = new EntityItem(te.worldObj, 0.0D, 0.0D, 0.0D, jt.jewelry); + entityitem.getEntityItem().stackSize = 1; + entityitem.hoverStart = 0.0F; - tessellator.addVertexWithUV(-3, 9, -5+f, minu, minv); - tessellator.addVertexWithUV(2.2, 9, -5+f, maxu, minv); - tessellator.addVertexWithUV(2.2, 14, -5+f, maxu, maxv); - tessellator.addVertexWithUV(-3, 14, -5+f, minu, maxv); - } - tessellator.draw(); - GL11.glColor4f(1, 1F, 1F, 1.0F); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glScalef(0.5F, 0.5F, 0.5F); + GL11.glTranslatef(0.05F, -1.6F, 0.5F); + GL11.glRotatef(jt.angle, 0F, 1F, 0F); + if(RenderManager.instance.options.fancyGraphics) + RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + else + { + GL11.glRotatef(180F, 0F, 1F, 0F); + RenderManager.instance.options.fancyGraphics = true; + RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderManager.instance.options.fancyGraphics = false; } + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); } - if (jt.hasEndItem) + if (jt.hasEndItem && jt.endItem.getIconIndex().getIconName() != "") { - if(jt.endItem.getIconIndex().getIconName() != "") + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + EntityItem entityitem = new EntityItem(te.worldObj, 0.0D, 0.0D, 0.0D, jt.endItem); + entityitem.getEntityItem().stackSize = 1; + entityitem.hoverStart = 0.0F; + + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glScalef(0.5F, 0.5F, 0.5F); + GL11.glTranslatef(0.05F, -1.6F, 0.5F); + GL11.glRotatef(jt.angle, 0F, 1F, 0F); + if(RenderManager.instance.options.fancyGraphics) + RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + else { - String domain = ""; - if(jt.endItem.getIconIndex().getIconName().substring(0, jt.endItem.getIconIndex().getIconName().indexOf(":") + 1) != "") - domain = jt.endItem.getIconIndex().getIconName().substring(0, jt.endItem.getIconIndex().getIconName().indexOf(":") + 1).replace(":", " ").trim(); - else - domain = "minecraft"; - String texture = jt.endItem.getIconIndex().getIconName().substring(jt.endItem.getIconIndex().getIconName().lastIndexOf(":") + 1) + ".png"; - ResourceLocation lava = new ResourceLocation(domain, "textures/items/" + texture); - Minecraft.getMinecraft().renderEngine.bindTexture(lava); - jt.endItem.getIconIndex().getInterpolatedU(0); - double minu = jt.endItem.getIconIndex().getInterpolatedU(0); - double minv = jt.endItem.getIconIndex().getInterpolatedV(-64); - double maxu = jt.endItem.getIconIndex().getInterpolatedU(256); - double maxv = jt.endItem.getIconIndex().getInterpolatedV(256 - 64); - GL11.glPushMatrix(); - GL11.glScalef(1f / 16f, 1f / 16f, 1f / 16f); - GL11.glDisable(GL11.GL_LIGHTING); - if (jt.endItem.hasTagCompound()) - { - if (jt.endItem.getTagCompound().hasKey("ingot")) - { - NBTTagCompound ingotNBT = (NBTTagCompound) jt.endItem.getTagCompound().getTag("ingot"); - ItemStack ingotStack = new ItemStack(0, 0, 0); - ingotStack.readFromNBT(ingotNBT); - ItemRing.addMetal(jt.endItem, ingotStack); - int color = jt.endItem.getItem().getColorFromItemStack(jt.endItem, 0); - float red = (float)(color >> 16 & 255) / 255.0F; - float green = (float)(color >> 8 & 255) / 255.0F; - float blue = (float)(color & 255) / 255.0F; - if(!jt.endItem.getDisplayName().contains("Ingot")) GL11.glColor4f(red, green, blue, 1F); - } - } - tessellator.startDrawingQuads(); - for(float f=0; f<=1; f+=0.001){ - tessellator.addVertexWithUV(3, 9, -5+f, minu, minv); - tessellator.addVertexWithUV(-2.2, 9, -5+f, maxu, minv); - tessellator.addVertexWithUV(-2.2, 14, -5+f, maxu, maxv); - tessellator.addVertexWithUV(3, 14, -5+f, minu, maxv); + GL11.glRotatef(180F, 0F, 1F, 0F); + RenderManager.instance.options.fancyGraphics = true; + RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderManager.instance.options.fancyGraphics = false; + } - tessellator.addVertexWithUV(-3, 9, -5+f, minu, minv); - tessellator.addVertexWithUV(2.2, 9, -5+f, maxu, minv); - tessellator.addVertexWithUV(2.2, 14, -5+f, maxu, maxv); - tessellator.addVertexWithUV(-3, 14, -5+f, minu, maxv); - } - tessellator.draw(); - GL11.glColor4f(1, 1F, 1F, 1.0F); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } + if (jt.hasModifier && jt.modifier.getIconIndex().getIconName() != "") + { + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + EntityItem entityitem = new EntityItem(te.worldObj, 0.0D, 0.0D, 0.0D, jt.modifier); + entityitem.getEntityItem().stackSize = 1; + entityitem.hoverStart = 0.0F; + + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glScalef(0.5F, 0.5F, 0.5F); + GL11.glTranslatef(0.6F, -1.5F, -0.4F); + GL11.glRotatef(jt.angle, 0F, 1F, 0F); + if(RenderManager.instance.options.fancyGraphics) + RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + else + { + GL11.glRotatef(180F, 0F, 1F, 0F); + RenderManager.instance.options.fancyGraphics = true; + RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderManager.instance.options.fancyGraphics = false; } + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); } - if (jt.hasModifier) + if (jt.hasJewel && jt.jewel.getIconIndex().getIconName() != "") { - if(jt.modifier.getIconIndex().getIconName() != "") + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + EntityItem entityitem = new EntityItem(te.worldObj, 0.0D, 0.0D, 0.0D, jt.jewel); + entityitem.getEntityItem().stackSize = 1; + entityitem.hoverStart = 0.0F; + + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glScalef(0.5F, 0.5F, 0.5F); + GL11.glTranslatef(-0.6F, -1.5F, -0.4F); + GL11.glRotatef(jt.angle, 0F, 1F, 0F); + if(RenderManager.instance.options.fancyGraphics) + RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + else { - String domain = ""; - if(jt.modifier.getIconIndex().getIconName().substring(0, jt.modifier.getIconIndex().getIconName().indexOf(":") + 1) != "") - domain = jt.modifier.getIconIndex().getIconName().substring(0, jt.modifier.getIconIndex().getIconName().indexOf(":") + 1).replace(":", " ").trim(); - else - domain = "minecraft"; - String texture = jt.modifier.getIconIndex().getIconName().substring(jt.modifier.getIconIndex().getIconName().lastIndexOf(":") + 1) + ".png"; - ResourceLocation lava = new ResourceLocation(domain, "textures/items/" + texture); - Minecraft.getMinecraft().renderEngine.bindTexture(lava); - jt.modifier.getIconIndex().getInterpolatedU(0); - double minu = jt.modifier.getIconIndex().getInterpolatedU(-64); - double minv = jt.modifier.getIconIndex().getInterpolatedV(0); - double maxu = jt.modifier.getIconIndex().getInterpolatedU(256-64); - double maxv = jt.modifier.getIconIndex().getInterpolatedV(256); - GL11.glPushMatrix(); - GL11.glScalef(1f / 16f, 1f / 16f, 1f / 16f); - GL11.glDisable(GL11.GL_LIGHTING); - tessellator.startDrawingQuads(); - for(float f=0; f<=1; f+=0.001){ - tessellator.addVertexWithUV(8, 7.5, 3+f, minu, minv); - tessellator.addVertexWithUV(2.8, 7.5, 3+f, maxu, minv); - tessellator.addVertexWithUV(2.8, 13, 3+f, maxu, maxv); - tessellator.addVertexWithUV(8, 13, 3+f, minu, maxv); - - tessellator.addVertexWithUV(2, 7.5, 3+f, minu, minv); - tessellator.addVertexWithUV(7.2, 7.5, 3+f, maxu, minv); - tessellator.addVertexWithUV(7.2, 13, 3+f, maxu, maxv); - tessellator.addVertexWithUV(2, 13, 3+f, minu, maxv); - } - tessellator.draw(); - GL11.glColor4f(1, 1F, 1F, 1.0F); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); + GL11.glRotatef(180F, 0F, 1F, 0F); + RenderManager.instance.options.fancyGraphics = true; + RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F); + RenderManager.instance.options.fancyGraphics = false; } + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); } } |
