Jump to content

Recommended Posts

Posted

In my mod, I have created a new item for throwable spawn eggs:

ItemThrowableEgg.java

 

  Reveal hidden contents

 

And I register it and all of its forms in preInit like so:

snippet from main class preInit:

 

  Reveal hidden contents

 

All of that works fine. It appears with the correct texture in the correct inventory slot and behaves exactly as expected on right click.

However, I ran into problems trying to create an EntityItem out of it. I have another class that is an event handler for LivingDropsEvent. In this class, spawn eggs are added to the drops of various mobs. The function I use to create an itemstack is this:

 

  Reveal hidden contents

 

it is then appended to the drops with:

e.drops.add(new EntityItem(e.entity.worldObj, e.entity.posX, e.entity.posY, e.entity.posZ, throwableEggFor([appropriate id]);

 

This is where everything gets messed up. When I kill a mob, I see it drops an item with the black and purple checkered texture used for items without one. When I pick it up, the game crashes:

 

  Reveal hidden contents
Posted
  Quote
Do not create that many Items! You should use damage value or ItemStack NBT data.

 

Sorry, I'm somewhat new to Forge. What's the best way to set and retrieve the damage value? Should I put it in the constructor?

 

I see that the setDamage function takes an ItemStack as a parameter. Are damage values associated with individual items?

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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