Jump to content

How to respawn a player at his/her bed?


vrwim

Recommended Posts

I am now getting the error: net.minecraft.client.entity.EntityClientPlayerMP cannot be cast to net.minecraft.entity.player.EntityPlayerMP, but not everytime when I rightclick with this item, most of the times it just doesn't do anything...

 

 

Code:

public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer player, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)

    {

    ChunkCoordinates spawn = player.getBedLocation();

    ((EntityPlayerMP) player).playerNetServerHandler.setPlayerLocation(spawn.posX, spawn.posY, spawn.posZ, player.rotationYaw, player.rotationPitch);

    return true;

    }

Link to comment
Share on other sites

tyvm, now this part of my mod is fully functional, and I'd like to add, for anyone that reads this topic to find the same answer I was looking for:

onItemUse(...) is only called when you right-click on a block,

I fixed this by using onItemRightClick(...) and returning the same ItemStack you got from the parameters, just browse the Item class for it :P

Link to comment
Share on other sites

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.



×
×
  • Create New...

Important Information

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