I want to assign three commands to go into effect when an item is used, and also destroy that item. Anyone know how to do this?
The commands I want to add are
Ehrm... May I ask why you kill the player to teleport him to spawn? I bet there is a spawn location somewhere inside World and you can use player.teleportTo(...) for teleportation. Unfortunately, I can't look at my code to validate but its defenetly not a good style to kill someone to let him teleport to spawn
It was the easiest way I could think of. I really need an item to teleport me home to finish my mod
It is possible to teleport a player to a place within the world using an instance of the player. player.setPositionAndUpdate(x, y, z); As for getting the X Y Z of player spawn, par1NBTTagCompound.getInteger("SpawnX") can be used to the spawn coords for the player. (subsitute X with Y and Z for the others). There is likely a better way to access this, perhaps by getting the players spawn chuck.
The commands I want to add are
/gamerule keepInventory true
/kill
/gamerule keepInventory false
so that the player is teleported to their spawn point without losing anything
It was the easiest way I could think of. I really need an item to teleport me home to finish my mod
Farewell everyone o/
if (player.worldObj.provider.dimensionId != 0) { player.travelToDimension(0); }
ChunkCoordinates pxyz = player.worldObj.getSpawnPoint();
double px = pxyz.posX;
double py = pxyz.posY;
double pz = pxyz.posZ;
player.setPositionAndUpdate(px + .5, py, pz + .5);
my published mods