Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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

Featured Replies

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

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.

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

Maybe you could try world.joinEntityInSurroundings(entity). Try to replace world.spawnEntity(entity) with this.

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.

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.