Fix Player spawning wrongly

This commit is contained in:
Ellpeck 2015-12-20 22:33:44 +01:00
parent e77aee70de
commit e0b9099ca2

View file

@ -11,12 +11,9 @@
package ellpeck.actuallyadditions.world; package ellpeck.actuallyadditions.world;
import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import ellpeck.actuallyadditions.items.InitItems;
import ellpeck.actuallyadditions.util.Util; import ellpeck.actuallyadditions.util.Util;
import ellpeck.actuallyadditions.util.playerdata.PersistentServerData;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks; import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ChunkCoordinates; import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
@ -40,17 +37,13 @@ public class ActAddCavesEvents{
cavesData.setBoolean("CavesCreated", true); cavesData.setBoolean("CavesCreated", true);
} }
//Spawn the player int x = cavesData.getInteger("StartX");
NBTTagCompound playerData = PersistentServerData.getDataFromPlayer(player); int y = cavesData.getInteger("StartY");
if(!playerData.getBoolean("SpawnedInCaves")){ int z = cavesData.getInteger("StartZ");
int x = cavesData.getInteger("StartX");
int y = cavesData.getInteger("StartY");
int z = cavesData.getInteger("StartZ");
player.setSpawnChunk(new ChunkCoordinates(x, y, z), true);
player.setPositionAndUpdate(x+0.5, y+1, z+0.5);
player.inventory.addItemStackToInventory(new ItemStack(InitItems.itemBooklet));
playerData.setBoolean("SpawnedInCaves", true); //Fix the player's location upon respawn
if(player.posY >= 255){
player.setPositionAndUpdate(x+0.5, y+1, z+0.5);
} }
} }
} }