Created
February 4, 2016 12:18
-
-
Save mossyblog/bf5313c1e6596142edff to your computer and use it in GitHub Desktop.
Render 3D Icon in Minecraft of a Item/Block - 1.8.9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void RenderFloatingItemIcon(float x, float y, float z, Item item, float partialTickTime, boolean animate) { | |
BlockPos pos = new BlockPos(x,y,z); | |
// Create Empty EntityItem to help with Rendering Positionining. | |
EntityItem entity = new EntityItem(mc.theWorld,pos.getX(),pos.getY(), pos.getZ()); | |
if (entity.ticksExisted == 0) | |
{ | |
entity.lastTickPosX = entity.posX; | |
entity.lastTickPosY = entity.posY; | |
entity.lastTickPosZ = entity.posZ; | |
} | |
double d0 = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * (double)partialTickTime; | |
double d1 = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * (double)partialTickTime; | |
double d2 = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * (double)partialTickTime; | |
// TODO: Keep local version of the renderXYZ positions | |
double renderPosX = HaxeUtil.GetFieldByReflection(RenderManager.class, mc.getRenderManager(),"renderPosX"); | |
double renderPosY = HaxeUtil.GetFieldByReflection(RenderManager.class, mc.getRenderManager(),"renderPosY"); | |
double renderPosZ = HaxeUtil.GetFieldByReflection(RenderManager.class, mc.getRenderManager(),"renderPosZ"); | |
GlStateManager.pushMatrix(); | |
renderPosX = (double)pos.getX() - entity.posX + (d0 - renderPosX); | |
renderPosY = (double)pos.getY() - entity.posY + (d1 - renderPosY); | |
renderPosZ = (double)pos.getZ() - entity.posZ + (d2 - renderPosZ); | |
GlStateManager.translate(renderPosX + 0.5D, renderPosY + 1.3, renderPosZ + 0.5D); | |
float time = (mc.thePlayer.ticksExisted % 360); | |
GL11.glScaled(0.8D,0.8D,0.8D); | |
if(animate) | |
GL11.glRotatef(-mc.getRenderManager().playerViewY-time*20, 0.0F,1F, 0.0F); | |
else | |
GL11.glRotatef(-mc.getRenderManager().playerViewY, 0.0F,1F, 0.0F); | |
mc.getRenderItem().renderItem(new ItemStack(item), ItemCameraTransforms.TransformType.FIXED); | |
GlStateManager.popMatrix(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment