private void handleLowPower(Integer id, int power, boolean doEffects) { if (power <= 0) { // We ran out of power! WorldServer world = DimensionManager.getWorld(id); if (world != null) { List<EntityPlayer> players = new ArrayList<EntityPlayer>(world.playerEntities); if (DimletConfiguration.dimensionDifficulty >= 1) { for (EntityPlayer player : players) { if (!RfToolsDimensionManager.checkValidPhasedFieldGenerator(player, true)) { player.attackEntityFrom(new DamageSourcePowerLow("powerLow"), 1000000.0f); } else { if (doEffects && DimletConfiguration.phasedFieldGeneratorDebuf) { player.addPotionEffect( new PotionEffect(Potion.moveSlowdown.getId(), EFFECTS_MAX * MAXTICKS, 4, true)); player.addPotionEffect( new PotionEffect(Potion.digSlowdown.getId(), EFFECTS_MAX * MAXTICKS, 2, true)); player.addPotionEffect( new PotionEffect(Potion.hunger.getId(), EFFECTS_MAX * MAXTICKS, 2, true)); } } } } else { Random random = new Random(); for (EntityPlayer player : players) { if (!RfToolsDimensionManager.checkValidPhasedFieldGenerator(player, true)) { WorldServer worldServerForDimension = MinecraftServer.getServer() .worldServerForDimension(DimletConfiguration.spawnDimension); int x = random.nextInt(2000) - 1000; int z = random.nextInt(2000) - 1000; int y = worldServerForDimension.getTopSolidOrLiquidBlock(x, z); if (y == -1) { y = 63; } TeleportationTools.teleportToDimension( player, DimletConfiguration.spawnDimension, x, y, z); } else { if (doEffects) { player.addPotionEffect( new PotionEffect(Potion.moveSlowdown.getId(), EFFECTS_MAX * MAXTICKS, 4, true)); player.addPotionEffect( new PotionEffect(Potion.digSlowdown.getId(), EFFECTS_MAX * MAXTICKS, 4, true)); player.addPotionEffect( new PotionEffect(Potion.hunger.getId(), EFFECTS_MAX * MAXTICKS, 2, true)); } } } } } } }