Posted June 21, 201510 yr I want to know if is there some function to execute code when you spawn for the first time on a new world. At the same time, is it possible to set the spawn point to a new place and make it exact point, for example X=0, Y=75, Z=0? And always be that point, and not around that area.
June 21, 201510 yr What Minecraft version? In 1.7.10, there is EntityLiving#onSpawnWithEgg, and in 1.8 it was renamed to #onInitialSpawn and takes an extra parametr. Yes, you can change the entity's position from there, but why would you want to make the entity always spawn at one specific location? http://i.imgur.com/NdrFdld.png[/img]
June 21, 201510 yr Author Hi CoolAlias thanks for the answer. Yes I forgot, I'm talking about 1.7.10 It's not an entity (Mobs), but the player. Basically when you spawn in a new world I want to "move" the player into a room, and if he dies once he is out on the world he would have to spawn in this room again. Also thinking about sending them to a new "Void" dimension containing only this room, but that's something I will work on later on.
June 21, 201510 yr I think that's not what he wanted. EDIT: OP was faster You want to do something when player spawns in world for the 1st time right? You will need IExtendedEntityProperties - assign them to EntityPlayer on EntityConstructing event and save boolean there. Then use PlayerLoggedInEvent - check if boolean is false - if it is - do stuff and change to true. Yes, this is the only way to perform one-time action (you need to save it). EDIT As you mentioned teleporting on respawn - you will need to know it: Every player has EntityPlayer. Whem player dies, his entity will be assigned to "him" until he either leaves game or server OR click respawn button - on that moment, old Entity is lost and new one is created. If you want to move player (tp) after respawn you can use EntityJoinedWorldEvent or PlayerEvent.PlayerRespawnEvent. (EDIT) Try it. 1.7.10 is no longer supported by forge, you are on your own.
June 21, 201510 yr If you want it to happen every time the player dies and respawns, use PlayerRespawnEvent. You won't need IEEP if you want it to happen every time, but like Ernio said, if you only want it to happen once, then you need to store that somehow. http://i.imgur.com/NdrFdld.png[/img]
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.