public PSEventHandler() { try { sleepTimer = EntityPlayer.class.getDeclaredField(MCPNames.field("field_71076_b")); sleepTimer.setAccessible(true); sleeping = EntityPlayer.class.getDeclaredField(MCPNames.field("field_71083_bS")); sleeping.setAccessible(true); } catch (NoSuchFieldException nsf) { nsf.printStackTrace(); } }
public static void setSpawnPoint(int dimension, int spawnX, int spawnY, int spawnZ) { World dimensionWorld = DimensionManager.getWorld(dimension); if (dimensionWorld instanceof WorldServerMulti) { WorldServerMulti w = (WorldServerMulti) DimensionManager.getWorld(dimension); DerivedWorldInfo worldInfo = (DerivedWorldInfo) w.getWorldInfo(); try { Field f = DerivedWorldInfo.class.getDeclaredField(MCPNames.field("field_76115_a")); f.setAccessible(true); WorldInfo info = (WorldInfo) f.get(worldInfo); info.setSpawnPosition(spawnX, spawnY, spawnZ); } catch (Exception e) { PerfectSpawn.instance.logger.log(Level.ERROR, "Couldn't set spawn position"); e.printStackTrace(); } } else { WorldInfo info = dimensionWorld.getWorldInfo(); info.setSpawnPosition(spawnX, spawnY, spawnZ); } }