private double calculateEnchantedDamage(double basicDamage, GlowLivingEntity entity) { int level = 0; // TODO: calculate explosion protection level of entity's equipment if (level > 0) { float sub = level * 0.15f; double damage = basicDamage * sub; damage = Math.floor(damage); return basicDamage - damage; } return basicDamage; }
private boolean isProtected(Location location) { Chunk chunk = location.getChunk(); World world = location.getWorld(); WorldConfig worldConfig = plugin.getConfig(world); int gridX = (int) (Math.floor(chunk.getX() / 10.0d) * 10); int gridZ = (int) (Math.floor(chunk.getZ() / 10.0d) * 10); DungeonProperties properties = new DungeonProperties(world, worldConfig, gridX, gridZ); if (properties.isInChunk(chunk)) { int yMin = 0; int yMax = 0; for (int y = 0; y < world.getMaxHeight(); ++y) { if ((chunk.getBlock(8, y, 8).getData() & (byte) 0x8) == 0x8) { yMin = y; break; } } for (int y = world.getMaxHeight(); y > 0; --y) { if ((chunk.getBlock(8, y, 8).getData() & (byte) 0x8) == 0x8) { yMax = y; break; } } double y = location.getY(); return (y >= yMin && y <= yMax); } return false; }