From 9e4f2df4ea9ebfad235c24ce52daab2e4dce1eac Mon Sep 17 00:00:00 2001 From: Lizbeth Rika Date: Thu, 4 Dec 2014 16:40:28 +0000 Subject: [PATCH] Baubles now render on the player. In this commit: Seperation of tiara render code to a framework, The Spectator and Tiny Planet render code --- .../botania/api/item/IBaubleRender.java | 77 ++++++++ .../java/vazkii/botania/api/package-info.java | 2 +- .../core/handler/BaubleRenderHandler.java | 65 ++++++ .../core/handler/TiaraWingRenderHandler.java | 185 ------------------ .../client/core/proxy/ClientProxy.java | 4 +- .../equipment/bauble/ItemFlightTiara.java | 152 +++++++++++++- .../item/equipment/bauble/ItemItemFinder.java | 41 +++- .../item/equipment/bauble/ItemTinyPlanet.java | 20 +- .../botania/textures/items/itemFinderGem.png | Bin 0 -> 3027 bytes 9 files changed, 355 insertions(+), 191 deletions(-) create mode 100644 src/main/java/vazkii/botania/api/item/IBaubleRender.java create mode 100644 src/main/java/vazkii/botania/client/core/handler/BaubleRenderHandler.java delete mode 100644 src/main/java/vazkii/botania/client/core/handler/TiaraWingRenderHandler.java create mode 100644 src/main/resources/assets/botania/textures/items/itemFinderGem.png diff --git a/src/main/java/vazkii/botania/api/item/IBaubleRender.java b/src/main/java/vazkii/botania/api/item/IBaubleRender.java new file mode 100644 index 000000000..b0034b6b9 --- /dev/null +++ b/src/main/java/vazkii/botania/api/item/IBaubleRender.java @@ -0,0 +1,77 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Dec 4, 2014, 3:28:43 PM (GMT)] + */ +package vazkii.botania.api.item; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.client.event.RenderPlayerEvent; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/** + * A Bauble Item that implements this will be have hooks to render something on + * the player while its equipped. + * This class doesn't extend IBauble to make the API not depend on the Baubles + * API, but the item in question still needs to implement IBauble. + */ +@SideOnly(Side.CLIENT) +public interface IBaubleRender { + + /** + * Called for the rendering of the bauble on the player. The player instance can be + * acquired through the event parameter. Transformations are already applied for + * the RenderType passed in. Make sure to check against the type parameter for + * rendering. + */ + @SideOnly(Side.CLIENT) + public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type); + + /** + * A few helper methods for the render. + */ + public static class Helper { + + public static void rotateIfSneaking(EntityPlayer player) { + if(player.isSneaking()) + applySneakingRotation(); + } + + public static void applySneakingRotation() { + GL11.glRotatef(28.64789F, 1.0F, 0.0F, 0.0F); + } + + public static void translateToHeadLevel(EntityPlayer player) { + GL11.glTranslated(0, -player.getDefaultEyeHeight() + (player.isSneaking() ? 0.0625 : 0), 0); + } + + } + + public static enum RenderType { + /** + * Render Type for the player's body, translations apply on the player's rotation. + * Sneaking is not handled and should be done during the render. + * @see IBaubleRender.Helper + */ + BODY, + + /** + * Render Type for the player's body, translations apply on the player's head rotations. + * Sneaking is not handled and should be done during the render.~ + * @see IBaubleRender.Helper + */ + HEAD; + } + +} diff --git a/src/main/java/vazkii/botania/api/package-info.java b/src/main/java/vazkii/botania/api/package-info.java index 11cfbe61c..d70e0c109 100644 --- a/src/main/java/vazkii/botania/api/package-info.java +++ b/src/main/java/vazkii/botania/api/package-info.java @@ -1,4 +1,4 @@ -@API(owner = "Botania", apiVersion = "23", provides = "BotaniaAPI") +@API(owner = "Botania", apiVersion = "24", provides = "BotaniaAPI") package vazkii.botania.api; import cpw.mods.fml.common.API; diff --git a/src/main/java/vazkii/botania/client/core/handler/BaubleRenderHandler.java b/src/main/java/vazkii/botania/client/core/handler/BaubleRenderHandler.java new file mode 100644 index 000000000..72942ad10 --- /dev/null +++ b/src/main/java/vazkii/botania/client/core/handler/BaubleRenderHandler.java @@ -0,0 +1,65 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Aug 27, 2014, 8:55:00 PM (GMT)] + */ +package vazkii.botania.client.core.handler; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.ItemRenderer; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.event.RenderPlayerEvent; + +import org.lwjgl.opengl.GL11; + +import vazkii.botania.api.item.IBaubleRender; +import vazkii.botania.api.item.IBaubleRender.RenderType; +import vazkii.botania.client.core.helper.ShaderHelper; +import vazkii.botania.client.lib.LibResources; +import vazkii.botania.common.item.equipment.bauble.ItemFlightTiara; +import baubles.common.container.InventoryBaubles; +import baubles.common.lib.PlayerHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; + +public final class BaubleRenderHandler { + + @SubscribeEvent + public void onPlayerRender(RenderPlayerEvent.Specials.Post event) { + EntityPlayer player = event.entityPlayer; + InventoryBaubles inv = PlayerHandler.getPlayerBaubles(player); + + dispatchRenders(inv, event, RenderType.BODY); + + float yaw = player.prevRotationYawHead + (player.rotationYawHead - player.prevRotationYawHead) * event.partialRenderTick; + float yawOffset = player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * event.partialRenderTick; + float pitch = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * event.partialRenderTick; + + GL11.glPushMatrix(); + GL11.glRotatef(yawOffset, 0, -1, 0); + GL11.glRotatef(yaw - 270, 0, 1, 0); + GL11.glRotatef(pitch, 0, 0, 1); + dispatchRenders(inv, event, RenderType.HEAD); + GL11.glPopMatrix(); + } + + private void dispatchRenders(InventoryBaubles inv, RenderPlayerEvent event, RenderType type) { + for(int i = 0; i < inv.getSizeInventory(); i++) { + ItemStack stack = inv.getStackInSlot(i); + if(stack != null && stack.getItem() instanceof IBaubleRender) + ((IBaubleRender) stack.getItem()).onPlayerBaubleRender(stack, event, type); + } + } + +} diff --git a/src/main/java/vazkii/botania/client/core/handler/TiaraWingRenderHandler.java b/src/main/java/vazkii/botania/client/core/handler/TiaraWingRenderHandler.java deleted file mode 100644 index 443ca77ef..000000000 --- a/src/main/java/vazkii/botania/client/core/handler/TiaraWingRenderHandler.java +++ /dev/null @@ -1,185 +0,0 @@ -/** - * This class was created by . It's distributed as - * part of the Botania Mod. Get the Source Code in github: - * https://github.com/Vazkii/Botania - * - * Botania is Open Source and distributed under a - * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License - * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) - * - * File Created @ [Aug 27, 2014, 8:55:00 PM (GMT)] - */ -package vazkii.botania.client.core.handler; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.ItemRenderer; -import net.minecraft.client.renderer.OpenGlHelper; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.IIcon; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.client.event.RenderPlayerEvent; - -import org.lwjgl.opengl.GL11; - -import vazkii.botania.client.core.helper.ShaderHelper; -import vazkii.botania.client.lib.LibResources; -import vazkii.botania.common.item.equipment.bauble.ItemFlightTiara; -import baubles.common.container.InventoryBaubles; -import baubles.common.lib.PlayerHandler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; - -public final class TiaraWingRenderHandler { - - private static ResourceLocation textureHalo = new ResourceLocation(LibResources.MISC_HALO); - - @SubscribeEvent - public void onPlayerRender(RenderPlayerEvent.Specials.Post event) { - InventoryBaubles inv = PlayerHandler.getPlayerBaubles(event.entityPlayer); - if(inv.getStackInSlot(0) != null && inv.getStackInSlot(0).getItem() instanceof ItemFlightTiara) { - int meta = inv.getStackInSlot(0).getItemDamage(); - if(meta > 0 && meta <= ItemFlightTiara.wingIcons.length) { - IIcon icon = ItemFlightTiara.wingIcons[meta - 1]; - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - - boolean flying = event.entityPlayer.capabilities.isFlying; - - float rz = 120F; - float rx = 20F + (float) ((Math.sin((double) (event.entityPlayer.ticksExisted + event.partialRenderTick) * (flying ? 0.4F : 0.2F)) + 0.5F) * (flying ? 30F : 5F)); - float ry = 0F; - float h = 0.2F; - float i = 0.15F; - float s = 1F; - - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glColor4f(1F, 1F, 1F, 1F); - - switch(meta) { - case 1 : { // Jibril - h = 0.4F; - break; - } - case 2 : { // Sephiroth - s = 1.3F; - break; - } - case 3 : { // Cirno - h = -0.1F; - rz = 0F; - rx = 0F; - i = 0.3F; - break; - } - case 4 : { // Fire - int light = 15728880; - int lightmapX = light % 65536; - int lightmapY = light / 65536; - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); - break; - } - case 5 : { // Kuroyukihime - h = 0.8F; - rz = 180F; - ry = -rx; - rx = 0F; - s = 2F; - break; - } - case 6 : { // Random Devil - rz = 150F; - break; - } - case 7 : { // Lyfa - h = -0.1F; - rz = 0F; - ry = -rx; - rx = 0F; - GL11.glColor4f(1F, 1F, 1F, 0.5F + (float) Math.cos((double) (event.entityPlayer.ticksExisted + event.partialRenderTick) * 0.3F) * 0.2F); - break; - } - } - - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - float sr = 1F / s; - - if(event.entityPlayer.isSneaking()) - GL11.glRotatef(28.64789F, 1.0F, 0.0F, 0.0F); - - GL11.glTranslatef(0F, h, i); - - GL11.glRotatef(rz, 0F, 0F, 1F); - GL11.glRotatef(rx, 1F, 0F, 0F); - GL11.glRotatef(ry, 0F, 1F, 0F); - GL11.glScalef(s, s, s); - ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 32F); - GL11.glScalef(sr, sr, sr); - GL11.glRotatef(-ry, 0F, 1F, 0F); - GL11.glRotatef(-rx, 1F, 0F, 0F); - GL11.glRotatef(-rz, 0F, 0F, 1F); - - if(meta != 2) { // Sephiroth - GL11.glScalef(-1F, 1F, 1F); - GL11.glRotatef(rz, 0F, 0F, 1F); - GL11.glRotatef(rx, 1F, 0F, 0F); - GL11.glRotatef(ry, 0F, 1F, 0F); - GL11.glScalef(s, s, s); - ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 32F); - GL11.glScalef(sr, sr, sr); - GL11.glRotatef(-ry, 1F, 0F, 0F); - GL11.glRotatef(-rx, 1F, 0F, 0F); - GL11.glRotatef(-rz, 0F, 0F, 1F); - } - - GL11.glColor3f(1F, 1F, 1F); - GL11.glPopMatrix(); - - // Jibril's Halo - if(meta == 1) - renderHalo(event.entityPlayer, event.partialRenderTick); - } - } - } - - private void renderHalo(EntityPlayer player, float partialTicks) { - float yaw = player.prevRotationYawHead + (player.rotationYawHead - player.prevRotationYawHead) * partialTicks; - float yawOffset = player.prevRenderYawOffset + (player.renderYawOffset - player.prevRenderYawOffset) * partialTicks; - float pitch = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * partialTicks; - - GL11.glPushMatrix(); - GL11.glRotatef(yawOffset, 0, -1, 0); - GL11.glRotatef(yaw - 270, 0, 1, 0); - GL11.glRotatef(pitch, 0, 0, 1); - - GL11.glShadeModel(GL11.GL_SMOOTH); - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glColor4f(1F, 1F, 1F, 1F); - - Minecraft.getMinecraft().renderEngine.bindTexture(textureHalo); - - GL11.glTranslated(0, -player.getDefaultEyeHeight() + (player.isSneaking() ? 0.0625 : 0), 0); - GL11.glRotated(30, 1, 0, -1); - GL11.glTranslatef(-0.1F, -0.5F, -0.1F); - GL11.glRotatef(player.ticksExisted + partialTicks, 0, 1, 0); - - Tessellator tes = Tessellator.instance; - ShaderHelper.useShader(ShaderHelper.halo); - tes.startDrawingQuads(); - tes.addVertexWithUV(-0.75, 0, -0.75, 0, 0); - tes.addVertexWithUV(-0.75, 0, 0.75, 0, 1); - tes.addVertexWithUV(0.75, 0, 0.75, 1, 1); - tes.addVertexWithUV(0.75, 0, -0.75, 1, 0); - tes.draw(); - ShaderHelper.releaseShader(); - - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glShadeModel(GL11.GL_FLAT); - GL11.glPopMatrix(); - } -} diff --git a/src/main/java/vazkii/botania/client/core/proxy/ClientProxy.java b/src/main/java/vazkii/botania/client/core/proxy/ClientProxy.java index 48e6a4c56..fb9d1f3a8 100644 --- a/src/main/java/vazkii/botania/client/core/proxy/ClientProxy.java +++ b/src/main/java/vazkii/botania/client/core/proxy/ClientProxy.java @@ -38,7 +38,7 @@ import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.core.handler.DebugHandler; import vazkii.botania.client.core.handler.HUDHandler; import vazkii.botania.client.core.handler.LightningHandler; -import vazkii.botania.client.core.handler.TiaraWingRenderHandler; +import vazkii.botania.client.core.handler.BaubleRenderHandler; import vazkii.botania.client.core.handler.TooltipHandler; import vazkii.botania.client.core.helper.ShaderHelper; import vazkii.botania.client.fx.FXSparkle; @@ -123,7 +123,7 @@ public class ClientProxy extends CommonProxy { if(ConfigHandler.boundBlockWireframe) MinecraftForge.EVENT_BUS.register(new BoundTileRenderer()); MinecraftForge.EVENT_BUS.register(new TooltipHandler()); - MinecraftForge.EVENT_BUS.register(new TiaraWingRenderHandler()); + MinecraftForge.EVENT_BUS.register(new BaubleRenderHandler()); MinecraftForge.EVENT_BUS.register(new DebugHandler()); if(ConfigHandler.versionCheckEnabled) diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemFlightTiara.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemFlightTiara.java index 6d634c26f..cfff28896 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemFlightTiara.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemFlightTiara.java @@ -14,18 +14,30 @@ package vazkii.botania.common.item.equipment.bauble; import java.util.ArrayList; import java.util.List; +import org.lwjgl.opengl.GL11; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.ItemRenderer; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; import net.minecraft.util.StatCollector; +import net.minecraftforge.client.event.RenderPlayerEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; +import vazkii.botania.api.item.IBaubleRender; import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; import vazkii.botania.client.core.helper.IconHelper; +import vazkii.botania.client.core.helper.ShaderHelper; +import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.Botania; import vazkii.botania.common.lib.LibItemNames; import baubles.api.BaubleType; @@ -36,8 +48,10 @@ import cpw.mods.fml.common.gameevent.PlayerEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; -public class ItemFlightTiara extends ItemBauble implements IManaUsingItem { +public class ItemFlightTiara extends ItemBauble implements IManaUsingItem, IBaubleRender { + private static ResourceLocation textureHalo = new ResourceLocation(LibResources.MISC_HALO); + public static List playersWithFlight = new ArrayList(); private static final int COST = 35; @@ -175,5 +189,141 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem { return true; } + @Override + @SideOnly(Side.CLIENT) + public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { + int meta = stack.getItemDamage(); + if(type == RenderType.BODY) { + if(meta > 0 && meta <= ItemFlightTiara.wingIcons.length) { + IIcon icon = ItemFlightTiara.wingIcons[meta - 1]; + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + + boolean flying = event.entityPlayer.capabilities.isFlying; + + float rz = 120F; + float rx = 20F + (float) ((Math.sin((double) (event.entityPlayer.ticksExisted + event.partialRenderTick) * (flying ? 0.4F : 0.2F)) + 0.5F) * (flying ? 30F : 5F)); + float ry = 0F; + float h = 0.2F; + float i = 0.15F; + float s = 1F; + + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glColor4f(1F, 1F, 1F, 1F); + + switch(meta) { + case 1 : { // Jibril + h = 0.4F; + break; + } + case 2 : { // Sephiroth + s = 1.3F; + break; + } + case 3 : { // Cirno + h = -0.1F; + rz = 0F; + rx = 0F; + i = 0.3F; + break; + } + case 4 : { // Fire + int light = 15728880; + int lightmapX = light % 65536; + int lightmapY = light / 65536; + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); + break; + } + case 5 : { // Kuroyukihime + h = 0.8F; + rz = 180F; + ry = -rx; + rx = 0F; + s = 2F; + break; + } + case 6 : { // Random Devil + rz = 150F; + break; + } + case 7 : { // Lyfa + h = -0.1F; + rz = 0F; + ry = -rx; + rx = 0F; + GL11.glColor4f(1F, 1F, 1F, 0.5F + (float) Math.cos((double) (event.entityPlayer.ticksExisted + event.partialRenderTick) * 0.3F) * 0.2F); + break; + } + } + + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + float sr = 1F / s; + + Helper.rotateIfSneaking(event.entityPlayer); + + GL11.glTranslatef(0F, h, i); + + GL11.glRotatef(rz, 0F, 0F, 1F); + GL11.glRotatef(rx, 1F, 0F, 0F); + GL11.glRotatef(ry, 0F, 1F, 0F); + GL11.glScalef(s, s, s); + ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 32F); + GL11.glScalef(sr, sr, sr); + GL11.glRotatef(-ry, 0F, 1F, 0F); + GL11.glRotatef(-rx, 1F, 0F, 0F); + GL11.glRotatef(-rz, 0F, 0F, 1F); + + if(meta != 2) { // Sephiroth + GL11.glScalef(-1F, 1F, 1F); + GL11.glRotatef(rz, 0F, 0F, 1F); + GL11.glRotatef(rx, 1F, 0F, 0F); + GL11.glRotatef(ry, 0F, 1F, 0F); + GL11.glScalef(s, s, s); + ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 32F); + GL11.glScalef(sr, sr, sr); + GL11.glRotatef(-ry, 1F, 0F, 0F); + GL11.glRotatef(-rx, 1F, 0F, 0F); + GL11.glRotatef(-rz, 0F, 0F, 1F); + } + + GL11.glColor3f(1F, 1F, 1F); + GL11.glPopMatrix(); + } + } else if(meta == 1) // Jibril's Halo + renderHalo(event.entityPlayer, event.partialRenderTick); + } + + @SideOnly(Side.CLIENT) + private void renderHalo(EntityPlayer player, float partialTicks) { + GL11.glShadeModel(GL11.GL_SMOOTH); + OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glColor4f(1F, 1F, 1F, 1F); + + Minecraft.getMinecraft().renderEngine.bindTexture(textureHalo); + + Helper.translateToHeadLevel(player); + GL11.glRotated(30, 1, 0, -1); + GL11.glTranslatef(-0.1F, -0.5F, -0.1F); + GL11.glRotatef(player.ticksExisted + partialTicks, 0, 1, 0); + + Tessellator tes = Tessellator.instance; + ShaderHelper.useShader(ShaderHelper.halo); + tes.startDrawingQuads(); + tes.addVertexWithUV(-0.75, 0, -0.75, 0, 0); + tes.addVertexWithUV(-0.75, 0, 0.75, 0, 1); + tes.addVertexWithUV(0.75, 0, 0.75, 1, 1); + tes.addVertexWithUV(0.75, 0, -0.75, 1, 0); + tes.draw(); + ShaderHelper.releaseShader(); + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glShadeModel(GL11.GL_FLAT); + } + } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemItemFinder.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemItemFinder.java index 67e8092c4..cc5df2719 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemItemFinder.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemItemFinder.java @@ -14,6 +14,13 @@ package vazkii.botania.common.item.equipment.bauble; import java.util.ArrayList; import java.util.List; +import org.lwjgl.opengl.GL11; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.ItemRenderer; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; @@ -26,8 +33,12 @@ import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.IIcon; import net.minecraft.util.MathHelper; import net.minecraft.village.MerchantRecipe; +import net.minecraftforge.client.event.RenderPlayerEvent; +import vazkii.botania.api.item.IBaubleRender; +import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.common.Botania; import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.lib.LibItemNames; @@ -38,15 +49,24 @@ import baubles.common.lib.PlayerHandler; import baubles.common.network.PacketHandler; import baubles.common.network.PacketSyncBauble; import cpw.mods.fml.relauncher.ReflectionHelper; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; -public class ItemItemFinder extends ItemBauble { +public class ItemItemFinder extends ItemBauble implements IBaubleRender { + IIcon gemIcon; private static final String TAG_POSITIONS = "highlightPositions"; public ItemItemFinder() { super(LibItemNames.ITEM_FINDER); } + @Override + public void registerIcons(IIconRegister par1IconRegister) { + super.registerIcons(par1IconRegister); + gemIcon = IconHelper.forItem(par1IconRegister, this, "Gem"); + } + @Override public void onWornTick(ItemStack stack, EntityLivingBase player) { super.onWornTick(stack, player); @@ -194,4 +214,23 @@ public class ItemItemFinder extends ItemBauble { return BaubleType.AMULET; } + @Override + @SideOnly(Side.CLIENT) + public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { + if(type == RenderType.HEAD) { + float f = gemIcon.getMinU(); + float f1 = gemIcon.getMaxU(); + float f2 = gemIcon.getMinV(); + float f3 = gemIcon.getMaxV(); + boolean armor = event.entityPlayer.getCurrentArmor(3) != null; + Helper.translateToHeadLevel(event.entityPlayer); + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + GL11.glRotatef(90F, 0F, 1F, 0F); + GL11.glRotatef(180F, 1F, 0F, 0F); + GL11.glTranslatef(-0.4F, 0.1F, armor ? -0.3F : -0.25F); + GL11.glScalef(0.75F, 0.75F, 0.75F); + ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, gemIcon.getIconWidth(), gemIcon.getIconHeight(), 1F / 16F); + } + } + } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemTinyPlanet.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemTinyPlanet.java index bab64e409..23d8b0ce9 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemTinyPlanet.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemTinyPlanet.java @@ -13,19 +13,27 @@ package vazkii.botania.common.item.equipment.bauble; import java.util.List; +import org.lwjgl.opengl.GL11; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; +import net.minecraftforge.client.event.RenderPlayerEvent; import vazkii.botania.api.internal.IManaBurst; +import vazkii.botania.api.item.IBaubleRender; import vazkii.botania.api.mana.ITinyPlanetExcempt; +import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.core.helper.Vector3; import vazkii.botania.common.lib.LibItemNames; import baubles.api.BaubleType; -public class ItemTinyPlanet extends ItemBauble { +public class ItemTinyPlanet extends ItemBauble implements IBaubleRender { public static final String TAG_ORBIT = "orbit"; @@ -94,4 +102,14 @@ public class ItemTinyPlanet extends ItemBauble { cmp.setInteger(TAG_ORBIT, time + 1); } + @Override + public void onPlayerBaubleRender(ItemStack stack, RenderPlayerEvent event, RenderType type) { + if(type == RenderType.HEAD) { + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); + GL11.glTranslatef(0.25F, -0.5F, 0F); + GL11.glScalef(0.5F, 0.5F, 0.5F); + RenderBlocks.getInstance().renderBlockAsItem(ModBlocks.tinyPlanet, 0, 1F); + } + } + } diff --git a/src/main/resources/assets/botania/textures/items/itemFinderGem.png b/src/main/resources/assets/botania/textures/items/itemFinderGem.png new file mode 100644 index 0000000000000000000000000000000000000000..5acb34550cb4c5c895615c868f11e074415b72cb GIT binary patch literal 3027 zcmV;^3oP`BP)pPPiaF#P*7-ZbZ>KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTm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