vrwim Posted February 28, 2013 Posted February 28, 2013 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? Quote
mnn Posted February 28, 2013 Posted February 28, 2013 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 Quote mnn.getNativeLang() != English If I helped you please click on the "thank you" button.
vrwim Posted February 28, 2013 Author Posted February 28, 2013 Ok, thanks for the quick reply! That worked to get the spawning coordinates Quote
vrwim Posted March 1, 2013 Author Posted March 1, 2013 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; } Quote
vrwim Posted March 1, 2013 Author Posted March 1, 2013 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 Quote
Recommended Posts
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.