Jump to content

Seperate Icon Textures on metadata block[Solved]


Lua

Recommended Posts

Hi, I've created a metadata block with 6 subtypes(0-5). The block is a tile entity with a special renderer and it uses the same model but just rotated a bit. However, I want the icon for the 0-2 blocks to be one icon and the 3-5 blocks be another. Obviously, its got to with getIcon method but I can't get them to be different and I thought this would be a really simple task.

 

Heres the relevant code:

 

 

@SideOnly(Side.CLIENT)
@Override
public void registerBlockIcons(IIconRegister iconRegister)
{
this.blockIcon = iconRegister.registerIcon(Arcticraft.MOD_ID + ":icicle_ud");
this.icicle = iconRegister.registerIcon(Arcticraft.MOD_ID + ":icicle");
}
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta)
{
if(meta == 3 || meta == 4 || meta == 5){
return this.blockIcon;
}
else{
return this.icicle;
}
}

Link to comment
Share on other sites

Show your TESR.

 

package net.arcticraft.tileentity.renderers;

import net.arcticraft.block.BlockIcicle;
import net.arcticraft.main.Arcticraft;
import net.arcticraft.tileentity.TileEntityIcicle;
import net.arcticraft.tileentity.models.ModelBlockIcicle;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;

import org.lwjgl.opengl.GL11;

import cpw.mods.fml.client.FMLClientHandler;

public class TileEntityIcicleRender extends TileEntitySpecialRenderer{

private ModelBlockIcicle model;

public TileEntityIcicleRender(){
	model = new ModelBlockIcicle();
}

public void renderAModelAt(TileEntityIcicle tileEntity, double x, double y, double z, float f)
{
	TileEntityIcicle icicle = (TileEntityIcicle) tileEntity;
	icicle = (TileEntityIcicle) tileEntity.getWorldObj().getTileEntity(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);

	int meta = 0;
	if(tileEntity.getWorldObj() != null)
	{
		meta = tileEntity.getBlockMetadata();
		icicle.rotation = meta;
	}
	FMLClientHandler.instance().getClient().renderEngine.bindTexture(new ResourceLocation(Arcticraft.MOD_ID, "textures/blocks/modeled_blocks/icicle.png"));
	GL11.glPushMatrix();
	GL11.glEnable(GL11.GL_NORMALIZE);
	GL11.glEnable(GL11.GL_BLEND);
	GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
	GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
	GL11.glScalef(1.0F, -1F, -1F);
	GL11.glRotatef(icicle.rotation * 90, 0.0F, 1.0F, 0.0F);
	if(icicle.type == 0 || icicle.type == 3)
	{
		// large
		GL11.glScalef(2.0F, 1.0F, 1F);
	}
	else if(icicle.type == 1 || icicle.type == 4)
	{
		// regular
		GL11.glScalef(1.5F, 1F, 1F);
	}
	else if(icicle.type == 2 || icicle.type == 5)
	{
		// small
		GL11.glScalef(1.0F, 1F, 1F);
	}
	if(icicle.upsideDown){
		GL11.glRotatef(180, 1, 0, 0);
		GL11.glTranslatef(0, (float) -1.5F, 0);
	}
	model.renderAll();
	GL11.glPopMatrix();
}

@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float par8)
{
	this.renderAModelAt((TileEntityIcicle) tileEntity, x, y, z, par8);
}

}

Link to comment
Share on other sites

In that TESR code you bind a specific texture. That is also where you need to have the check for which texture to bind. The icons you have are irrelevant.

 

Noooo, the texture for the actual blocks should be the same, I just want the icons to differ.

Link to comment
Share on other sites

Yeah, you'll need to make changes in your ItemRenderer class. If you don't have one yet, there are plenty of tutorials. Once you have that, you can change the way it renders based on metadata using the itemstack in renderItem().

Okay, thank you.

Link to comment
Share on other sites

Ok so I tried making a IItemRenderer and I came up with this and yes I registered it in the clientProxy.

 

package net.arcticraft.item.render;

import net.arcticraft.main.Arcticraft;
import net.minecraft.item.ItemStack;
import net.minecraftforge.client.IItemRenderer;

public class ItemIcicleRender implements IItemRenderer{

public ItemIcicleRender(){}

@Override
public boolean handleRenderType(ItemStack item, ItemRenderType type)
{
	return true;
}

@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper)
{
	return true;
}

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data)
{
	System.out.println(item.getItemDamage());
	if(item.getItemDamage() == 0 && item.getItemDamage() == 1 && item.getItemDamage() == 2)
	{
		item.getItem().setTextureName(Arcticraft.MOD_ID + ":icicle");
	}
	else
	{
		item.getItem().setTextureName(Arcticraft.MOD_ID + ":icicle_ud");
	}
}

}

 

But they just come up as the missing texture texture(the purple black squares one). Is this because I commented out the getIcon and registerIcon in the block method? Probably, but I shouldnt need em should since its a tileentity w/ model and it uses the same texture.

Link to comment
Share on other sites

You should register those icons into the 'registerIcons' and Render them on 'renderItem'.

Just setting texture name there should not work.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

You should register those icons into the 'registerIcons' and Render them on 'renderItem'.

Just setting texture name there should not work.

 

In the item class I did register em with and now theyre just invisible.

 

 @SideOnly(Side.CLIENT)
   
public static final String[] iciclesTextures = new String[]{"icicle", "icicle", "icicle", "icicle_ud","icicle_ud", "icicle_ud"};
@SideOnly(Side.CLIENT)
private IIcon[] texture;

public void registerIcons(IIconRegister iconRegister)
    {
        this.texture = new IIcon[iciclesTextures.length];

        for (int i = 0; i < iciclesTextures.length; ++i)
        {
            this.texture[i] = iconRegister.registerIcon(Arcticraft.MOD_ID + ":" + iciclesTextures[i]);
        }
    }

 

Im not quite sure how I would just render em on RenderItem

Link to comment
Share on other sites

..Wait, do you only changes the texture via item metadata? Then ItemRenderer is not appropriate.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

Then just use Item#getIconFromDamage(int damage).

EDIT: Wait, you are just using metadata for tileentity! Then you should bind your texture yourself, in the TileEntitySpecialRenderer!

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

Then just use Item#getIconFromDamage(int damage).

EDIT: Wait, you are just using metadata for tileentity! Then you should bind your texture yourself, in the TileEntitySpecialRenderer!

 

I bind the texture to the model in TESR but I just wanted the icons to be different and now they are. getIconFromDamage was exactly what I needed.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Baba  Serege [[+27-73 590 8989]] has experience of 27 years in helping and guiding many people from all over the world. His psychic abilities may help you answer and resolve many unanswered questions. He specialize in helping women and men from all walks of life.. 1) – Bring back lost lover. even if lost for a long time. 2) – My lover is abusing alcohol, partying and cheating on me I urgently need help” 3) – Divorce or court issues. 4) – Is your love falling apart? 5) – Do you want your love to grow stronger? 6) – Is your partner losing interest in you? 7) – Do you want to catch your partner cheating on you? – We help to keep your partner faithful and loyal to you. 9) – We recover love and happiness when relationship breaks down. 10) – Making your partner loves you alone. 11) – We create loyalty and everlasting love between couples. 12) – Get a divorce settlement quickly from your ex-partner. 13) – We create everlasting love between couples. 14) – We help you look for the best suitable partner. 15) – We bring back lost lover even if lost for a long time. 16) – We strengthen bonds in all love relationship and marriages 17) – Are you an herbalist who wants to get more powers? 18) – Buy a house or car of your dream. 19) – Unfinished jobs by other doctors come to me. 20) – I help those seeking employment. 21) – Pensioners free treatment. 22) – Win business tenders and contracts. 23) – Do you need to recover your lost property? 24) – Promotion at work and better pay. 25) – Do you want to be protected from bad spirits and nightmares? 26) – Financial problems. 27) – Why you can’t keep money or lovers? 28) – Why you have a lot of enemies? 29) – Why you are fired regularly on jobs? 30) – Speed up money claim spell, delayed payments, pension and accident funds 31) – I help students pass their exams/interviews. 33) – Removal of bad luck and debts. 34) – Are struggling to sleep because of a spiritual wife or husband. 35- ) Recover stolen property
    • OLXTOTO adalah situs bandar togel online resmi terbesar dan terpercaya di Indonesia. Bergabunglah dengan OLXTOTO dan nikmati pengalaman bermain togel yang aman dan terjamin. Koleksi toto 4D dan togel toto terlengkap di OLXTOTO membuat para member memiliki pilihan taruhan yang lebih banyak. Sebagai situs togel terpercaya, OLXTOTO menjaga keamanan dan kenyamanan para membernya dengan sistem keamanan terbaik dan enkripsi data. Transaksi yang cepat, aman, dan terpercaya merupakan jaminan dari OLXTOTO. Nikmati layanan situs toto terbaik dari OLXTOTO dengan tampilan yang user-friendly dan mudah digunakan. Layanan pelanggan tersedia 24/7 untuk membantu para member. Bergabunglah dengan OLXTOTO sekarang untuk merasakan pengalaman bermain togel yang menyenangkan dan menguntungkan.
    • Baba  Serege [[+27-73 590 8989]] has experience of 27 years in helping and guiding many people from all over the world. His psychic abilities may help you answer and resolve many unanswered questions. He specialize in helping women and men from all walks of life.. 1) – Bring back lost lover. even if lost for a long time. 2) – My lover is abusing alcohol, partying and cheating on me I urgently need help” 3) – Divorce or court issues. 4) – Is your love falling apart? 5) – Do you want your love to grow stronger? 6) – Is your partner losing interest in you? 7) – Do you want to catch your partner cheating on you? – We help to keep your partner faithful and loyal to you. 9) – We recover love and happiness when relationship breaks down. 10) – Making your partner loves you alone. 11) – We create loyalty and everlasting love between couples. 12) – Get a divorce settlement quickly from your ex-partner. 13) – We create everlasting love between couples. 14) – We help you look for the best suitable partner. 15) – We bring back lost lover even if lost for a long time. 16) – We strengthen bonds in all love relationship and marriages 17) – Are you an herbalist who wants to get more powers? 18) – Buy a house or car of your dream. 19) – Unfinished jobs by other doctors come to me. 20) – I help those seeking employment. 21) – Pensioners free treatment. 22) – Win business tenders and contracts. 23) – Do you need to recover your lost property? 24) – Promotion at work and better pay. 25) – Do you want to be protected from bad spirits and nightmares? 26) – Financial problems. 27) – Why you can’t keep money or lovers? 28) – Why you have a lot of enemies? 29) – Why you are fired regularly on jobs? 30) – Speed up money claim spell, delayed payments, pension and accident funds 31) – I help students pass their exams/interviews. 33) – Removal of bad luck and debts. 34) – Are struggling to sleep because of a spiritual wife or husband. 35- ) Recover stolen property
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.