ISSUE FIXED
So i am making an Item in tribute to the Terrarian Magic Mirror that teleports you to either your spawn point or your bed depending if you have slept in the bed else if your bed is missing/obstructed, or just for reasons you cannot spawn at your bed, just spawn at the world's spawn location.
I got it working for a while but it would only spawn me to the spawn chunks but now since i have added if(!world.isRemote), it doesnt want to teleport at all.
NEW ISSUE
Hello i got my old issue fixed but to bring up a new issue now. The inverse is happening now to where if i havnt slept in a bed at all, the item flat out doesnt work but if i sleep in a bed then destroy it, it shall teleport me to spawn like it should.
Basically: if i start a new world, use the item, i get an error and it doesnt teleport me to my original spawn. If i sleep, it will teleport me to my bed. If i destroy the bed, It teleports me to spawn.
issue to fix is the item not working if you have not used a bed at all.
I updated the code down below for eyes to view.
UPDATED CODE:
ERROR:
I get this with the new stated issue above.
My System.out statement doesn't seem to output so i am quite worried where the code is actually messing up.
Possible solution would be to use a try catch statement for null pointers in my if statement checking for bed spawn point for null.
will that work?
Any other suggestions?
OLD OUTPUT
with an output of:
World: net.minecraft.world.WorldServer@74fababf
WorldtoString: net.minecraft.world.WorldServer@74fababf
EntityPlayer: EntityPlayerMP['Player61'/164, l='New World', x=-133.69, y=66.00, z=-52.32]
Player: EntityPlayerMP['Player61'/164, l='New World', x=-133.69, y=66.00, z=-52.32]
Bed Location: null
Spawn Location: BlockPos{x=-124, y=64, z=-45}
Spawn top point: 64