private void renderIcon(TextureAtlasSprite icon) { float f = icon.getMinU(); float f1 = icon.getMaxU(); float f2 = icon.getMinV(); float f3 = icon.getMaxV(); IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); }
@Override @SideOnly(Side.CLIENT) public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks) { if(type == RenderType.BODY) { Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); Helper.rotateIfSneaking(player); boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty(); GlStateManager.rotate(180F, 1F, 0F, 0F); GlStateManager.translate(-0.26F, -0.4F, armor ? 0.2F : 0.15F); GlStateManager.scale(0.5F, 0.5F, 0.5F); for(TextureAtlasSprite icon : new TextureAtlasSprite[] { MiscellaneousIcons.INSTANCE.bloodPendantChain, MiscellaneousIcons.INSTANCE.bloodPendantGem }) { float f = icon.getMinU(); float f1 = icon.getMaxU(); float f2 = icon.getMinV(); float f3 = icon.getMaxV(); IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 32F); Color color = new Color(Minecraft.getMinecraft().getItemColors().colorMultiplier(stack, 1)); GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue()); int light = 15728880; int lightmapX = light % 65536; int lightmapY = light / 65536; OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapX, lightmapY); } GL11.glColor3ub((byte) 255, (byte) 255, (byte) 255); } }
@Override @SideOnly(Side.CLIENT) public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks) { if(type == RenderType.BODY) { Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); Helper.rotateIfSneaking(player); boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty(); GlStateManager.rotate(180F, 1F, 0F, 0F); GlStateManager.translate(-0.2F, -0.45F, armor ? 0.2F : 0.15F); GlStateManager.scale(0.5F, 0.5F, 0.5F); TextureAtlasSprite gemIcon = MiscellaneousIcons.INSTANCE.nimbusGem; float f = gemIcon.getMinU(); float f1 = gemIcon.getMaxU(); float f2 = gemIcon.getMinV(); float f3 = gemIcon.getMaxV(); IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getIconWidth(), gemIcon.getIconHeight(), 1F / 32F); } }
private static void renderGoldfish(EntityPlayer player) { GlStateManager.pushMatrix(); TextureAtlasSprite icon = MiscellaneousIcons.INSTANCE.goldfishIcon; float f = icon.getMinU(); float f1 = icon.getMaxU(); float f2 = icon.getMinV(); float f3 = icon.getMaxV(); Helper.rotateIfSneaking(player); GlStateManager.rotate(180F, 0F, 0F, 1F); GlStateManager.rotate(90F, 0F, 1F, 0F); GlStateManager.scale(0.4F, 0.4F, 0.4F); GlStateManager.translate(-0.5F, 1.6F, 0F); Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); GlStateManager.popMatrix(); }
float f2 = gemIcon.getMinV(); float f3 = gemIcon.getMaxV(); IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getIconWidth(), gemIcon.getIconHeight(), width); GlStateManager.popMatrix();
@Override @SideOnly(Side.CLIENT) public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks) { if(type == RenderType.BODY) { Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); Helper.rotateIfSneaking(player); boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty(); GlStateManager.scale(0.5, 0.5, 0.5); GlStateManager.rotate(180, 0, 0, 1); GlStateManager.translate(-0.5, -0.90, armor ? -0.4 : -0.25); TextureAtlasSprite gemIcon = MiscellaneousIcons.INSTANCE.pyroclastGem; float f = gemIcon.getMinU(); float f1 = gemIcon.getMaxU(); float f2 = gemIcon.getMinV(); float f3 = gemIcon.getMaxV(); IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getIconWidth(), gemIcon.getIconHeight(), 1F / 32F); } }
@Override @SideOnly(Side.CLIENT) public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks) { if(type == RenderType.BODY) { Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); Helper.rotateIfSneaking(player); boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty(); GlStateManager.scale(0.5, 0.5, 0.5); GlStateManager.rotate(180, 0, 0, 1); GlStateManager.translate(-0.5, -0.90, armor ? -0.4 : -0.25); TextureAtlasSprite gemIcon = MiscellaneousIcons.INSTANCE.crimsonGem; float f = gemIcon.getMinU(); float f1 = gemIcon.getMaxU(); float f2 = gemIcon.getMinV(); float f3 = gemIcon.getMaxV(); IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getIconWidth(), gemIcon.getIconHeight(), 1F / 32F); } } }
@Override @SideOnly(Side.CLIENT) public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks) { if(type == RenderType.BODY) { Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); Helper.rotateIfSneaking(player); boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty(); GlStateManager.rotate(180F, 1F, 0F, 0F); GlStateManager.translate(-0.2F, -0.3F, armor ? 0.2F : 0.15F); GlStateManager.scale(0.5F, 0.5F, 0.5F); TextureAtlasSprite gemIcon = MiscellaneousIcons.INSTANCE.cirrusGem; float f = gemIcon.getMinU(); float f1 = gemIcon.getMaxU(); float f2 = gemIcon.getMinV(); float f3 = gemIcon.getMaxV(); IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getIconWidth(), gemIcon.getIconHeight(), 1F / 32F); } }
@Override @SideOnly(Side.CLIENT) public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks) { if(type == RenderType.BODY) { Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); Helper.rotateIfSneaking(player); boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty(); GlStateManager.rotate(180F, 1F, 0F, 0F); GlStateManager.translate(-0.36F, -0.3F, armor ? 0.2F : 0.15F); GlStateManager.rotate(-45F, 0F, 0F, 1F); GlStateManager.scale(0.5F, 0.5F, 0.5F); TextureAtlasSprite gemIcon = MiscellaneousIcons.INSTANCE.snowflakePendantGem; float f = gemIcon.getMinU(); float f1 = gemIcon.getMaxU(); float f2 = gemIcon.getMinV(); float f3 = gemIcon.getMaxV(); IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getIconWidth(), gemIcon.getIconHeight(), 1F / 32F); } }
@Override @SideOnly(Side.CLIENT) public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks) { TextureAtlasSprite gemIcon = MiscellaneousIcons.INSTANCE.itemFinderGem; if(type == RenderType.HEAD) { float f = gemIcon.getMinU(); float f1 = gemIcon.getMaxU(); float f2 = gemIcon.getMinV(); float f3 = gemIcon.getMaxV(); boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.HEAD).isEmpty(); Helper.translateToHeadLevel(player); Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); GlStateManager.rotate(90F, 0F, 1F, 0F); GlStateManager.rotate(180F, 1F, 0F, 0F); GlStateManager.translate(-0.4F, -1.4F, armor ? -0.3F : -0.25F); GlStateManager.scale(0.75F, 0.75F, 0.75F); IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getIconWidth(), gemIcon.getIconHeight(), 1F / 16F); } }
GlStateManager.rotate(ry, 0F, 1F, 0F); GlStateManager.scale(s, s, s); IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 32F); GlStateManager.scale(sr, sr, sr); GlStateManager.rotate(-ry, 0F, 1F, 0F); GlStateManager.rotate(ry, 0F, 1F, 0F); GlStateManager.scale(s, s, s); IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 32F); GlStateManager.scale(sr, sr, sr); GlStateManager.rotate(-ry, 1F, 0F, 0F);
@SideOnly(Side.CLIENT) public static void renderOnPlayer(ItemStack stack, EntityPlayer player) { if(hasAnyWill(stack) && !((ItemTerrasteelArmor) stack.getItem()).hasPhantomInk(stack)) { GlStateManager.pushMatrix(); float f = MiscellaneousIcons.INSTANCE.terrasteelHelmWillIcon.getMinU(); float f1 = MiscellaneousIcons.INSTANCE.terrasteelHelmWillIcon.getMaxU(); float f2 = MiscellaneousIcons.INSTANCE.terrasteelHelmWillIcon.getMinV(); float f3 = MiscellaneousIcons.INSTANCE.terrasteelHelmWillIcon.getMaxV(); IBaubleRender.Helper.translateToHeadLevel(player); Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); GlStateManager.rotate(90F, 0F, 1F, 0F); GlStateManager.rotate(180F, 1F, 0F, 0F); GlStateManager.translate(-0.26F, -1.45F, -0.39F); GlStateManager.scale(0.5F, 0.5F, 0.5F); IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, MiscellaneousIcons.INSTANCE.terrasteelHelmWillIcon.getIconWidth(), MiscellaneousIcons.INSTANCE.terrasteelHelmWillIcon.getIconHeight(), 1F / 16F); GlStateManager.popMatrix(); } }
IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, icon.getIconWidth(), icon.getIconHeight(), 1F / 16F); GlStateManager.popMatrix();
@Nullable private static BufferedImage getBufferedImage(TextureAtlasSprite textureAtlasSprite) { final int iconWidth = textureAtlasSprite.getIconWidth(); final int iconHeight = textureAtlasSprite.getIconHeight(); final int frameCount = textureAtlasSprite.getFrameCount(); if (iconWidth <= 0 || iconHeight <= 0 || frameCount <= 0) { return null; } BufferedImage bufferedImage = new BufferedImage(iconWidth, iconHeight * frameCount, BufferedImage.TYPE_4BYTE_ABGR); for (int i = 0; i < frameCount; i++) { int[][] frameTextureData = textureAtlasSprite.getFrameTextureData(i); int[] largestMipMapTextureData = frameTextureData[0]; bufferedImage.setRGB(0, i * iconHeight, iconWidth, iconHeight, largestMipMapTextureData, 0, iconWidth); } return bufferedImage; }
for(int j = -shift; j < shift; j++) { GlStateManager.translate(0F, gap * j, 0F); IconHelper.renderIconIn3D(Tessellator.getInstance(), minU + stepU * (i + shift), minV + stepV * (j + shift + 1), minU + stepU * (i + shift + 1), minV + stepV * (j + shift), icon.getIconWidth() / pieces, icon.getIconHeight() / pieces, 1F / 8F); GlStateManager.translate(0F, -gap * j, 0F);
public static Icon adaptSprite(TextureAtlasSprite icon) { return new Icon(TextureMap.LOCATION_BLOCKS_TEXTURE, icon.getMinU(), icon.getMaxU(), icon.getMinV(), icon.getMaxV(), icon.getIconWidth(), icon.getIconHeight()); }
public void addSprite(TextureAtlasSprite sprite) { Holder holder = new Holder(sprite, mipmapLevels); if (maxSpriteSize > 0) { holder.setNewDimension(maxSpriteSize); } Slot slot = allocateSlot(holder); if (slot == null) { throw new StitcherException(null, String.format("Unable to fit %s (size %dx%d)", sprite.getIconName(), sprite.getIconWidth(), sprite.getIconHeight())); } sprite.initSprite(BASE_WIDTH, BASE_HEIGHT, slot.getOriginX(), slot.getOriginY(), holder.isRotated()); }
private Slot allocateSlot(Holder holder) { TextureAtlasSprite sprite = holder.getAtlasSprite(); boolean notSquare = sprite.getIconWidth() != sprite.getIconHeight(); for (Slot stitchSlot : slots) { Slot slot = stitchSlot.addSlot(holder); if (slot != null) { return slot; } if (notSquare) { holder.rotate(); slot = stitchSlot.addSlot(holder); if (slot != null) { return slot; } holder.rotate(); } } return expandAndAllocateSlot(holder); }
private boolean hasTransparency(TabulaCubeContainer cube, TextureAtlasSprite sprite) { int textureWidth = this.model.getTextureWidth(); int textureHeight = this.model.getTextureHeight(); int width = sprite.getIconWidth(); int height = sprite.getIconHeight(); int frameCount = sprite.getFrameCount(); if (frameCount > 0) { for (int i = 0; i < frameCount; i++) { int[] pixels = sprite.getFrameTextureData(i)[0]; int[] textureOffset = cube.getTextureOffset(); int[] dimensions = cube.getDimensions(); int textureX = (textureOffset[0] * width) / textureWidth; int textureY = (textureOffset[1] * height) / textureHeight; int dimensionX = (dimensions[0] * width) / textureWidth; int dimensionY = (dimensions[1] * height) / textureHeight; int dimensionZ = (dimensions[2] * width) / textureWidth; boolean hasTransparencyTop = this.hasTransparency(pixels, textureX + dimensionZ, textureY, dimensionX * 2, dimensionZ, width, height); boolean hasTransparencyBottom = this.hasTransparency(pixels, textureX, textureY + dimensionZ, (dimensionX + dimensionZ) * 2, dimensionY, width, height); if (hasTransparencyTop || hasTransparencyBottom) { return true; } } } return false; }
private boolean hasTransparency(TabulaCubeContainer cube, TextureAtlasSprite sprite) { int textureWidth = this.model.getTextureWidth(); int textureHeight = this.model.getTextureHeight(); int width = sprite.getIconWidth(); int height = sprite.getIconHeight(); int frameCount = sprite.getFrameCount(); if (frameCount > 0) { for (int i = 0; i < frameCount; i++) { int[] pixels = sprite.getFrameTextureData(i)[0]; int[] textureOffset = cube.getTextureOffset(); int[] dimensions = cube.getDimensions(); int textureX = (textureOffset[0] * width) / textureWidth; int textureY = (textureOffset[1] * height) / textureHeight; int dimensionX = (dimensions[0] * width) / textureWidth; int dimensionY = (dimensions[1] * height) / textureHeight; int dimensionZ = (dimensions[2] * width) / textureWidth; boolean hasTransparencyTop = this.hasTransparency(pixels, textureX + dimensionZ, textureY, dimensionX * 2, dimensionZ, width, height); boolean hasTransparencyBottom = this.hasTransparency(pixels, textureX, textureY + dimensionZ, (dimensionX + dimensionZ) * 2, dimensionY, width, height); if (hasTransparencyTop || hasTransparencyBottom) { return true; } } } return false; }