Jump to content

[SOLVED]Entities spawning and almost immediately vanishing on item right click


Recommended Posts

Posted

I have an item that spawns a Snowman when right clicked, however, the snowman vanishes after between 1/2 and 2 seconds.

Here is my code:

 

@Override
public ItemStack onItemRightClick(ItemStack is, World world, EntityPlayer player){
if (!world.isRemote)
        {
        	Entity entity=new EntitySnowman(world);
        	entity.posX=player.posX;
        	entity.posZ=player.posZ;
            	entity.posY=player.posY;
                world.spawnEntityInWorld(entity);
        }
        return is;
}

 

If there's any more info you need, please, let me know.

If I helped please press the Thank You button.

 

Check out my mods at http://www.curse.com/users/The_Fireplace/projects

Posted

Are you on Peaceful mode while testing this? Scratch that, I had a brain fart and forgot that EntitySnowman is the snow golem. I thought it was a custom entity for some reason.

Posted

Sorry, I'm relatively new to modding, what does world.isRemote?

Posted

Im fairly sure he just needs to use setPosition i ran into this problem when i first started messing with entitys. Im not sure why but when setting the position using entity.pos = the entity spawns at that position but immediately warps to 0, 0, 0 and falls out of the world.   

I am the author of Draconic Evolution

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.