Posted February 28, 201312 yr I want to create an item that respawns you at your current spawnpoint (bed or original spawn). Now I came across EntityPlayer.spawnLocation which is private, how can I reach this or respawn the player in another way?
February 28, 201312 yr take a look at this source code, it's exactly what you want https://github.com/ForgeEssentials/ForgeEssentialsMain/blob/master/src/FE_SRC_COMMON/com/ForgeEssentials/commands/CommandBed.java#L52 mnn.getNativeLang() != English If I helped you please click on the "thank you" button.
February 28, 201312 yr Author Ok, thanks for the quick reply! That worked to get the spawning coordinates
March 1, 201312 yr Author 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; }
March 1, 201312 yr Author 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
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.