Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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;
}
}

  • Author

TESR's don't use the normal icons.

So what could I do instead? Because right now they all just use the icicle icon.

  • Author

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);
}

}

  • Author

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.

  • Author

:o Say what?

Do you mean the "icon" when it's rendered in your hand? In that case, you'd need to make changes in your ItemRenderer.

 

Yeah, the icon in your hand. Not the actual block texture.

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().

  • Author

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.

  • Author

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.

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.

  • Author

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

..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.

  • Author

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

 

Yeah, i just need the icons to be differenet thats all.

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.

  • Author

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.

Is the block metadata-block with custom ItemBlock implementation?

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

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

  • Author

Is the block metadata-block with custom ItemBlock implementation?

Yeah

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.