Jump to content

Recommended Posts

Posted

Hello,

 

I am trying to imitate some items by getting their texture.

 

How can i get the texture name. like i can set it using setTextureName("") but there is no getTextureName. The only thing like it is  getIconString() but its not public.

 

Thanks for the help!

Posted

Thanks for the answer!

 

i made it like

@Override
    @SideOnly(Side.CLIENT)
    public IIcon getIconFromDamage(int par1)
    {
	if(_food != null)
		return _food.getIconFromDamage(par1);
	else 
		return super.getIconFromDamage(par1);
    }

 

sure is better way, but it works for now

 

Posted

For some reason its having issues spawning the particles when setting the icon this way

 

net.minecraft.util.ReportedException: Exception while adding particle

at net.minecraft.world.World.updateEntities(World.java:2079) ~[World.class:?]

at net.minecraft.client.Minecraft.runTick(Minecraft.java:2065) ~[Minecraft.class:?]

at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:997) ~[Minecraft.class:?]

at net.minecraft.client.Minecraft.run(Minecraft.java:912) [Minecraft.class:?]

at net.minecraft.client.main.Main.main(Main.java:112) [Main.class:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_55]

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_55]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_55]

at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_55]

at net.minecraft.launchwrapper.Launch.launch(Launch.java:134) [launchwrapper-1.9.jar:?]

at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.9.jar:?]

Caused by: java.lang.NullPointerException

at net.minecraft.client.particle.EntityBreakingFX.<init>(EntityBreakingFX.java:23) ~[EntityBreakingFX.class:?]

at net.minecraft.client.particle.EntityBreakingFX.<init>(EntityBreakingFX.java:31) ~[EntityBreakingFX.class:?]

at net.minecraft.client.renderer.RenderGlobal.doSpawnParticle(RenderGlobal.java:2205) ~[RenderGlobal.class:?]

at net.minecraft.client.renderer.RenderGlobal.spawnParticle(RenderGlobal.java:1978) ~[RenderGlobal.class:?]

at net.minecraft.world.World.spawnParticle(World.java:1445) ~[World.class:?]

at net.minecraft.entity.player.EntityPlayer.updateItemUse(EntityPlayer.java:469) ~[EntityPlayer.class:?]

at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:291) ~[EntityPlayer.class:?]

at net.minecraft.client.entity.EntityClientPlayerMP.onUpdate(EntityClientPlayerMP.java:100) ~[EntityClientPlayerMP.class:?]

at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2254) ~[World.class:?]

at net.minecraft.world.World.updateEntity(World.java:2214) ~[World.class:?]

at net.minecraft.world.World.updateEntities(World.java:2064) ~[World.class:?]

... 10 more

 

my class


public class CustomFood extends ItemFood
{
private Item _food;


public CustomFood(int health, boolean isWolfFood) {
	super(health, isWolfFood);
 	this.setUnlocalizedName("customFood");
        this.setCreativeTab(OthersMod.othersTab);
        this.setAlwaysEdible();
     
}
public CustomFood(int health,Item food)
{
	this(health, false);
	_food=food;
}

@Override
    @SideOnly(Side.CLIENT)
    public IIcon getIconFromDamage(int par1)
    {
	if(_food != null)
		return _food.getIconFromDamage(par1);
	else 
		return super.getIconFromDamage(par1);
    }
}

Posted

I got a tile entity that mixes between a potion and a food, and it goes like

 

mixerItemStacks[2] = new ItemStack((Item)new CustomFood(health,this.mixerItemStacks[1].getItem(),this.mixerItemStacks[0].getItem()));

 

to the constructor

public CustomFood(int health,Item food,Item potion)
{
	this(health, false);
	_food=food;
	//_potion=potion;
}

 

i can see that something is wrong at the moment with it as the item created (the custom food) disappears after relloging

Edit: I guess the dissapearing thing is just me not saving the _food info ;)

Posted

ahh, i see what you mean.

 

so i am suppose to make new ItemStack of the instance declared item like

 

ItemStack itemstack = new ItemStack(OthersMod.customFood);
mixerItemStacks[2] = itemstack.copy();

 

I am having some issues changing the icon after this, but i will keep trying.

Posted

I tried to do it but aint sure how.

 

my machine does

 

ItemStack itemstack = new ItemStack(OthersMod.customFood);		
mixerItemStacks[2] = itemstack.copy();

 

but that just makes the item with the status i declared on the mods class

 

customFood = new CustomFood(5,false);
GameRegistry.registerItem(customFood,customFood.getUnlocalizedName());

 

how can i change it before i copy it to have the information?

 

i dont need to make a new item for each? causse if i change the OthersMod.customFood then it changes every instance of it.

 

 

Edit:

 

i pretty sure its not the right way but i am giving it nbt data like

 

    public void createItemStackNBT(ItemStack itemStack)
    {
    	itemStack.stackTagCompound = new NBTTagCompound();
    }
public void setItemStackHealth(ItemStack itemstack, int i) 
{
	System.out.println(i);
	itemstack.stackTagCompound.setInteger("health", i);
}

 

and calling it like

 

    public void createItemStackNBT(ItemStack itemStack)
    {
    	itemStack.stackTagCompound = new NBTTagCompound();
    }
public void setItemStackHealth(ItemStack itemstack, int i) 
{
	System.out.println(i);
	itemstack.stackTagCompound.setInteger("health", i);
}

 

seems to start to work this way.

 

the only thing i didnt figure out is the icon thing, as you dont get the itemstack on the  getIconFromDamage function

 

 

EDIT:

 

After changing

 

@Override
   public int getRenderPasses(int metadata)
    {
        return requiresMultipleRenderPasses() ? 2 : 1;
    }

@Override
    @SideOnly(Side.CLIENT)
    public boolean requiresMultipleRenderPasses()
    {
        return true;
    }
   

 

i could override

@Override
    @SideOnly(Side.CLIENT)
    public IIcon getIcon(ItemStack stack, int pass)

 

that it let me use the stack nbt data!

 

the particles when eating are still weird... but meh

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



×
×
  • Create New...

Important Information

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