Topic category: Advanced modding
Hello, I need some help with my entity throwable and entity living. I know very little about NBT data and how it works and was wondering if someone could help me. What I plan to happen is for a player to throw an entity throwable at an item. That projectile will "collect" the item and will die when it hit the item. Then a entity living will spawn. When you kill this entity living it will drop the item the projectile hit. So Far I have the projectile hitting the item mechanics worked out but am unable to figure out how to transfer the projectile's NBT to the entity living.
protected void onImpact(MovingObjectPosition par1MovingObjectPosition)
{
if (par1MovingObjectPosition.entityHit == null){
List itemList = this.worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(this.posX - 1, this.posY -1, this.posZ -1, this.posX + 1, this.posY + 1, this.posZ + 1));
if(!itemList.isEmpty()){
System.out.println("ITEM HIT");
EntityItem entity = (EntityItem)itemList.get(0); //this is the item thats in it
ItemStack itemStack = entity.getEntityItem();
mcreator_sBubble.EntitysBubble result = new mcreator_sBubble.EntitysBubble(this.worldObj); //the bubble item
result.setTagCompound(new NBTTagCompound()); // sets NBT for bubble
//sets the bubbles answer to empy
Item item = itemStack.getItem(); //item's id
int id = Item.getIdFromItem(item); //getting the id
NBTTagCompound compound = new NBTTagCompound();
entity.writeToNBT(compound); //item written to NBT
stack.getTagCompound().setTag("ItemData" , compound);
if (!this.worldObj.isRemote)
{
entity.setDead();
this.setDead();
}
}
}
Thats what I have so far. As of the entity living I have the basis of it but no actual code for the NBT transfer. Any help would be appreciated.
Bump. Any help with code would be greatly appreciated.