Jump to content

Recommended Posts

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

Posted

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

}

Posted

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.

Posted

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

Posted

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

Posted

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.

Posted

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.

Posted

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.

Posted

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

Posted

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

Posted

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

Posted

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.

Posted

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.

Posted

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.

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

    • When I first heard about Bitcoin back in 2018, I was skeptical. The idea of a decentralized, digital currency seemed too good to be true. But I was intrigued as I learned more about the technology behind it and its potential. I started small, investing just a few hundred dollars, dipping my toes into the cryptocurrency waters. At first, it was exhilarating to watch the value of my investment grow exponentially. I felt like I was part of the future, an early adopter of this revolutionary new asset. But that euphoria was short-lived. One day, I logged into my digital wallet only to find it empty - my Bitcoin had vanished without a trace. It turned out that the online exchange I had trusted had been hacked, and my funds were stolen. I was devastated, both financially and emotionally. All the potential I had seen in Bitcoin was tainted by the harsh reality that with decentralization came a lack of regulation and oversight. My hard-earned money was gone, lost to the ether of the digital world. This experience taught me a painful lesson about the price of trust in the uncharted territory of cryptocurrency. While the technology holds incredible promise, the risks can be catastrophic if you don't approach it with extreme caution. My Bitcoin investment gamble had failed, and I was left to pick up the pieces, wiser but poorer for having placed my faith in the wrong hands. My sincere appreciation goes to MUYERN TRUST HACKER. You are my hero in recovering my lost funds. Send a direct m a i l ( muyerntrusted ( @ ) mail-me ( . )c o m ) or message on whats app : + 1 ( 4-4-0 ) ( 3 -3 -5 ) ( 0-2-0-5 )
    • You could try posting a log (if there is no log at all, it may be the launcher you are using, the FAQ may have info on how to enable the log) as described in the FAQ, however this will probably need to be reported to/remedied by the mod author.
    • So me and a couple of friends are playing with a shitpost mod pack and one of the mods in the pack is corail tombstone and for some reason there is a problem with it, where on death to fire the player will get kicked out of the server and the tombstone will not spawn basically deleting an entire inventory, it doesn't matter what type of fire it is, whether it's from vanilla fire/lava, or from modded fire like ice&fire/lycanites and it's common enough to where everyone on the server has experienced at least once or twice and it doesn't give any crash log. a solution to this would be much appreciated thank you!
    • It is 1.12.2 - I have no idea if there is a 1.12 pack
  • Topics

×
×
  • Create New...

Important Information

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