@SubscribeEvent public static void onPlayerSleepInBed(PlayerSleepInBedEvent event) { if(event.getEntityPlayer().world.provider.getDimension() != ConfigurationHandler.Settings.dimensionId) { return; } if (!ConfigurationHandler.MachineSettings.allowRespawning) { event.setResult(EntityPlayer.SleepResult.NOT_POSSIBLE_HERE); event.getEntityPlayer().sendStatusMessage(new TextComponentTranslation("hint.compactmachines3.cant_sleep_here", new Object[0]), true); return; } if (event.getEntityPlayer().isPlayerSleeping() || !event.getEntityPlayer().isEntityAlive()) { event.setResult(EntityPlayer.SleepResult.OTHER_PROBLEM); return; } event.getEntityPlayer().sendStatusMessage(new TextComponentTranslation("hint.compactmachines3.bed_position_set", new Object[0]), true); WorldSavedDataMachines.INSTANCE.setBedCoords(event.getEntityPlayer()); event.setResult(EntityPlayer.SleepResult.NOT_POSSIBLE_HERE); }
@SubscribeEvent public void handleSleepInBed(PlayerSleepInBedEvent event) { EntityPlayer p = event.getEntityPlayer(); final IPlayerExtendedProperties sleep = p.getCapability(ModCyclic.CAPABILITYSTORAGE, null); if (sleep != null && sleep.isSleeping()) { event.setResult(EntityPlayer.SleepResult.OK); } }
@SubscribeEvent public void onSleepInBed(PlayerSleepInBedEvent event) { if (enabled) { event.setResult(EntityPlayer.SleepResult.NOT_POSSIBLE_NOW); event.getEntityPlayer().sendStatusMessage(new TextComponentString("You cannot sleep on Halloween!"), false); } }
@SubscribeEvent public void onPlayerSleep(PlayerSleepInBedEvent event) { if (HFCore.SLEEP_ONLY_AT_NIGHT) { World world = event.getEntityPlayer().world; long time = CalendarHelper.getTime(world); Season season = HFApi.calendar.getDate(world).getSeason(); SeasonData data = CalendarAPI.INSTANCE.getDataForSeason(season); if (time >= 6000 && time <= data.getSunset()) { event.setResult(SleepResult.NOT_POSSIBLE_NOW); return; } } if (HFCore.SLEEP_ANYTIME) event.setResult(trySleep(event.getEntityPlayer(), event.getPos())); }
@SubscribeEvent() public void onPlayerSleepInBedEvent(PlayerSleepInBedEvent event) { EntityPlayer player = event.getEntityPlayer(); BlockPos pos = event.getPos(); PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(player.world, pos); if (wrapper != null) { if (player instanceof EntityPlayerMP) { EntityPlayerMP playerMP = (EntityPlayerMP) player; player.sendMessage(new TextComponentString("Spawn Point Set!")); player.setSpawnPoint(pos, true); event.setResult(SleepResult.NOT_POSSIBLE_HERE); } } }
@SubscribeEvent public void onPlayerSleepInBedEvent(PlayerSleepInBedEvent event) { if (LostCityConfiguration.DIMENSION_ID == -1) { return; } World world = event.getEntityPlayer().getEntityWorld(); if (world.isRemote) { return; } BlockPos bedLocation = event.getPos(); if (!isValidSpawnBed(world, bedLocation)) { return; } if (world.provider.getDimension() == LostCityConfiguration.DIMENSION_ID) { event.setResult(Event.Result.DENY); WorldServer destWorld = DimensionManager.getWorld(0); BlockPos location = findLocation(bedLocation, destWorld); CustomTeleporter.teleportToDimension(event.getEntityPlayer(), 0, location); } else { event.setResult(Event.Result.DENY); WorldServer destWorld = event.getEntity().getEntityWorld().getMinecraftServer().getWorld(LostCityConfiguration.DIMENSION_ID); BlockPos location = findLocation(bedLocation, destWorld); CustomTeleporter.teleportToDimension(event.getEntityPlayer(), LostCityConfiguration.DIMENSION_ID, location); } }