public void setBiome(int x, int z, Biome bio) { net.minecraft.world.biome.BiomeGenBase bb = CraftBlock.biomeToBiomeBase(bio); if (this.world.blockExists(x, 0, z)) { net.minecraft.world.chunk.Chunk chunk = this.world.getChunkFromBlockCoords(x, z); if (chunk != null) { byte[] biomevals = chunk.getBiomeArray(); biomevals[((z & 0xF) << 4) | (x & 0xF)] = (byte)bb.biomeID; } } }
/** * Prevents water from being dispensed in hell biomes * * @param e */ @EventHandler(priority = EventPriority.LOW) public void onNetherDispenser(final BlockDispenseEvent e) { if (DEBUG) { plugin.getLogger().info(e.getEventName()); } if (!Util.inWorld(e.getBlock().getLocation()) || !e.getBlock().getBiome().equals(Biome.HELL)) { return; } // plugin.getLogger().info("DEBUG: Item being dispensed is " + // e.getItem().getType().toString()); if (e.getItem().getType().equals(Material.WATER_BUCKET)) { e.setCancelled(true); if (plugin.getServer().getVersion().contains("(MC: 1.8") || plugin.getServer().getVersion().contains("(MC: 1.7")) { e.getBlock().getWorld().playSound(e.getBlock().getLocation(), Sound.valueOf("FIZZ"), 1F, 2F); } else { e.getBlock().getWorld().playSound(e.getBlock().getLocation(), Sound.ENTITY_CREEPER_PRIMED, 1F, 2F); } } }
public int getSolidBlock(int x, int z, Player target) { if(target.getWorld().getBiome(target.getLocation().getBlockX(),target.getLocation().getBlockZ()).equals(Biome.HELL)) return getSolidBlockNether(x,z,target); int y = 0; if (!wild.getConfig().getBoolean("InvertYSearch")) return invertSearch(x,z,target); else { if(target.getWorld().getBiome(x,z).equals(Biome.HELL)) return getSolidBlockNether(x,z,target); for (int i = 0; i <= target.getWorld().getMaxHeight(); i++) { y = i; if (!target.getWorld().getBlockAt(x, y, z).isEmpty() && target.getWorld().getBlockAt(x, y + 1, z).isEmpty() && target.getWorld().getBlockAt(x, y + 2, z).isEmpty() && target.getWorld().getBlockAt(x, y + 3, z).isEmpty() && !checkBlocks(target, x, y, z)) return y + 3; } } return 5; }
@Test public void test() { final Object[] random = { // Java (byte) 127, (short) 2000, -1600000, 1L << 40, -1.5f, 13.37, "String", // Skript Color.BLACK, StructureType.RED_MUSHROOM, WeatherType.THUNDER, new Date(System.currentTimeMillis()), new Timespan(1337), new Time(12000), new Timeperiod(1000, 23000), new Experience(15), new Direction(0, Math.PI, 10), new Direction(new double[] {0, 1, 0}), new EntityType(new SimpleEntityData(HumanEntity.class), 300), new CreeperData(), new SimpleEntityData(Snowball.class), new HorseData(Variant.SKELETON_HORSE), new WolfData(), new XpOrbData(50), // Bukkit - simple classes only GameMode.ADVENTURE, Biome.EXTREME_HILLS, DamageCause.FALL, // there is also at least one variable for each class on my test server which are tested whenever the server shuts down. }; for (final Object o : random) { Classes.serialize(o); // includes a deserialisation test } }
private void registerDefaultProviders() { registerProvider(Boolean.class, new BooleanProvider()); registerProvider(Byte.class, new ByteProvider()); registerProvider(Character.class, new CharacterProvider()); registerProvider(Double.class, new DoubleProvider()); registerProvider(Float.class, new FloatProvider()); registerProvider(Integer.class, new IntegerProvider()); registerProvider(Long.class, new LongProvider()); registerProvider(Short.class, new ShortProvider()); registerProvider(String.class, new StringProvider()); registerProvider(Biome.class, new BiomeProvider()); registerProvider(OfflinePlayer.class, new OfflinePlayerProvider()); registerProvider(OfflinePlayers.class, new OfflinePlayersProvider()); registerProvider(Player.class, new PlayerProvider()); registerProvider(Players.class, new PlayersProvider()); registerProvider(World.class, new WorldProvider()); }
/** * Checks if this dungeon should generate in a Chunk. This will account for * the world config as well as location. * * @param chunk The chunk to check. * @return True if it should generate. */ public boolean isInChunk(Chunk chunk) { if (!chunk.getWorld().equals(this.world) || chunk.getX() != this.chunkX || chunk.getZ() != this.chunkZ) { return false; } Biome biome = this.world.getBiome((this.chunkX * 16) + 8, (this.chunkZ * 16) + 8); if (!this.worldConfig.getStringList(Config.FEATURE_DUNGEONS_BIOMES).contains(biome.name())) { return false; } if (this.getRandom().nextInt(100) > this.worldConfig.getInt(Config.FEATURE_DUNGEONS_CHANCE)) { return false; } return true; }
private void blockPrePlace(LandInfo bl, float x, float y, float z, int id) { if (f.getName().contains("Felucca"))//we are scanning felucca { // UOConverter.log.info("We are scanning felucca!"); if (bl.biomeid == Biome.EXTREME_HILLS.ordinal()) { mod = UOConverter.UOHillsMod; } if (x >= 5120) { mod = UOConverter.UOmod; } } if (f.getName().contains("Malas"))//we are scanning malas { if (bl.biomeid == Biome.EXTREME_HILLS.ordinal()) { mod = UOConverter.UOHillsMod; } } }
public static Biome biomeBaseToBiome(BiomeGenBase base) { if (base == null) { return null; } return BIOME_MAPPING[base.biomeID]; }
/** * List schematics this player can access. If @param ignoreNoPermission is true, then only * schematics with a specific permission set will be checked. I.e., no common schematics will * be returned (including the default one). * @param player * @param ignoreNoPermission * @return List of schematics this player can use based on their permission level */ public List<Schematic> getSchematics(Player player, boolean ignoreNoPermission) { List<Schematic> result = new ArrayList<>(); // Find out what schematics this player can choose from //Bukkit.getLogger().info("DEBUG: Checking schematics for " + player.getName()); for (Schematic schematic : schematics.values()) { //Bukkit.getLogger().info("DEBUG: schematic name is '"+ schematic.getName() + "'"); //Bukkit.getLogger().info("DEBUG: perm is " + schematic.getPerm()); if ((!ignoreNoPermission && schematic.getPerm().isEmpty()) || VaultHelper.hasPerm(player, schematic.getPerm())) { //Bukkit.getLogger().info("DEBUG: player can use this schematic"); // Only add if it's visible if (schematic.isVisible()) { // Check if it's a nether island, but the nether is not enables if (schematic.getBiome().equals(Biome.HELL)) { if (Settings.netherGenerate && IslandWorld.getNetherWorld() != null) { result.add(schematic); } } else { result.add(schematic); } } } } // Sort according to order Collections.sort(result, (s1, s2) -> (s2.getOrder() < s1.getOrder()) ? 1 : -1); return result; }
/** * @return if Biome is HELL, this is true */ public boolean isInNether() { if (biome == Biome.HELL) { return true; } return false; }
public int getDefaultSupply(Biome biome) { switch($SWITCH_TABLE$org$bukkit$block$Biome()[biome.ordinal()]) { case 9: // '\t' return 32; } return 0; }
public static void registerResource(OreGenResource resource) { map.put(resource.getName(), resource); System.out.println((new StringBuilder("[Slimefun - GEO] 正在注册矿物生成器: ")).append(resource.getName()).toString()); Config cfg = new Config((new StringBuilder("plugins/Slimefun/generators/")).append(resource.getName()).append(".cfg").toString()); Biome abiome[]; int j = (abiome = Biome.values()).length; for(int i = 0; i < j; i++) { Biome biome = abiome[i]; cfg.setDefaultValue(biome.toString(), Integer.valueOf(resource.getDefaultSupply(biome))); } cfg.save(); }
private static int getDefault(OreGenResource resource, Biome biome) { if(resource == null) { return 0; } else { Config cfg = new Config((new StringBuilder("plugins/Slimefun/generators/")).append(resource.getName()).append(".cfg").toString()); return cfg.getInt(biome.toString()); } }
private void setWeather() { String weather = getWeather(); final World world = SkyWarsReloaded.get().getServer().getWorld(mapName + "_" + gameNumber); if (weather.equalsIgnoreCase("sunny")) { world.setStorm(false); world.setWeatherDuration(Integer.MAX_VALUE); } else if (weather.equalsIgnoreCase("rain")) { world.setStorm(true); world.setWeatherDuration(Integer.MAX_VALUE); } else if (weather.equalsIgnoreCase("thunder storm")) { world.setStorm(true); world.setThundering(true); world.setThunderDuration(Integer.MAX_VALUE); world.setWeatherDuration(Integer.MAX_VALUE); thunderStorm = true; } else if (weather.equalsIgnoreCase("snow")) { for (int x = min; x < max; x++) { for (int z = min; z < max; z++) { world.setBiome(x, z, Biome.ICE_PLAINS); } } world.setStorm(true); world.setWeatherDuration(Integer.MAX_VALUE); List<Chunk> chunks = getChunks(); SkyWarsReloaded.getNMS().updateChunks(mapWorld, chunks); world.setStorm(true); world.setWeatherDuration(Integer.MAX_VALUE); } }
@Override public void setBiome(Biome bio) { // TODO Auto-generated method stub throw new UnimplementedOperationException(); }
public OverWorldChunkGenerator() { System.out.println( "Generating biome map" ); biomeGrid = new BufferedImage( size, size, BufferedImage.TYPE_3BYTE_BGR ); Graphics graphics = biomeGrid.getGraphics(); graphics.setColor( new Color( 1 ) ); graphics.fillRect( 0, 0, size, size ); int specialBiomes = 16 + random.nextInt( 6 ); List<Biome> biomes = new ArrayList<>(); biomes.add( Biome.FOREST ); biomes.add( Biome.DESERT ); biomes.add( Biome.TAIGA ); for ( int i = 0; i < specialBiomes; i++ ) { graphics.setColor( new Color( biomes.get( random.nextInt( biomes.size() ) ).ordinal() ) ); int x = random.nextInt( size ); int z = random.nextInt( size ); int tx = 8 * 16 + random.nextInt( 3 * 16 ); int tz = 8 * 16 + random.nextInt( 3 * 16 ); graphics.fillOval( x, z, tx, tz ); } /*try { ImageIO.write( biomeGrid, "png", new File( "biomeGrid.png" ) ); } catch ( IOException e ) { e.printStackTrace(); }*/ this.addLayer( new BlockState( Material.BEDROCK ), 1 ); this.addLayer( new BlockState( Material.STONE ), 51 ); System.out.println( "Generating height map" ); setupStage( 32, .7F ); setupStage( 16, 0.4f ); setupStage( 8, 0.22f ); setupStage( 4, 0.1f ); setupStage( 1, 0.05f ); }
@Override public Biome getBiome( int i, int i1 ) { int biome = this.getRawBiome( i, i1 ); if( biome == 127 ) { return Biome.VOID; } return Biome.values()[ biome ]; }
private double generateSea(int x, int z, ChunkGenerator.BiomeGrid grid) { double height = seaAmplitude * seaGenerator.noise(x * seaFreq, z * seaFreq); if (height < -0.05) { grid.setBiome((x % 16 + 16) % 16, (z % 16 + 16) % 16, Biome.OCEAN); if (height < -0.2) grid.setBiome((x % 16 + 16) % 16, (z % 16 + 16) % 16, Biome.DEEP_OCEAN); } return height > 0 ? 0 : height; }
@Override protected Biome[] get(Event event) { int x = xExpression.getSingle(event).intValue(); int z = zExpression.getSingle(event).intValue(); BiomeGrid grid = biomeGridExpression.getSingle(event); return new Biome[]{grid.getBiome(x, z)}; }
public static Biome getGenerationBiome(double x, double y) { return Biome.COLD_BEACH; // double dist = getDistance(x, y); // if (dist < 200) // return Biome.pl; // else if (dist > 4096) // return null; // Nation n = getResidingNation(x, y); // if (n == null) // return Biome.BEACH; // return n.getHome(); }
/** * Gets a safe Y at the location. * @param location The location to get the Y for. * @return Safe y value, plus a buffer. (2.5 = max before fall damage) */ private double getSafeY(Location location) { if(location.getWorld().getBiome(location.getBlockX(), location.getBlockZ()) == Biome.HELL) { return (nether.getSafeYNether(location)); } if(RandomCoords.getPlugin().skyBlockSave.getStringList("SkyBlockWorlds").contains(location.getWorld().getName())) { return RandomCoords.getPlugin().skyBlockSave.getInt("DefaultY") + 3.5; } return location.getWorld().getHighestBlockYAt(location) + 2.5; }
/** * Adds a buffer to the location. * @param locationTP The location we want to add the buffer too. * @return The new location, add the buffer. */ private Location addBuffer(Location locationTP) { /** * If the biome is hell, Only add 1 to the location. * Else if the biome is the sky, Get the highest block for the end coord. (May seem odd to do this here, but why not) * Else add the default 2.5 amount. */ if (locationTP.getWorld().getBiome(locationTP.getBlockX(), locationTP.getBlockZ()).equals(Biome.HELL)) { //Adds 1 to the Y value if the biome is hell. locationTP = locationTP.add(0, 1, 0); } else if (locationTP.getWorld().getBiome(locationTP.getBlockX(), locationTP.getBlockZ()).equals(Biome.SKY) && !RandomCoords.getPlugin().skyBlockSave.getStringList("SkyBlockWorlds").contains(locationTP.getWorld().getName())) { //Gets the end coord from the end class. locationTP = end.endCoord(locationTP); //Gets the highest value at this point. final int highest = locationTP.getWorld().getHighestBlockYAt(locationTP.getBlockX(), locationTP.getBlockZ()); //Sets the locationTp as the new location made from above. locationTP = new Location(locationTP.getWorld(), locationTP.getBlockX(), highest, locationTP.getBlockZ()); } else { //Add 2.5 to the location. The max amount before fall damage. if(locationTP.getY() <= 0) { locationTP.add(0, 60, 0); } locationTP = locationTP.add(0, 2.5, 0); } //Return the locationa after the buffer is added. return locationTP; }
protected static double getCurrentCtachRate(Pokemon poke, Player p) { Random rand = new Random(); float curRateBonus = getRateBonus(); if (p.getWorld().getBiome(p.getLocation().getBlockX(), p.getLocation().getBlockY()) == Biome.SAVANNA || p.getWorld().getBiome(p.getLocation().getBlockX(), p.getLocation().getBlockY()) == Biome.SAVANNA_ROCK || p.getWorld().getBiome(p.getLocation().getBlockX(), p.getLocation().getBlockY()) == Biome.PLAINS) curRateBonus = 1.5f; double rate = ((((3 * poke.getMaxHealth()) - (2 * poke .getCurrentHealth())) * (poke.getCatchRate()) * curRateBonus) / (3 * poke .getMaxHealth())) * poke.getStatus().getBonus(); return (rate + ((rand.nextDouble() / 3) * 2)); }
@Override public byte[][] generateBlockSections(World world, Random random, int cx, int cz, BiomeGrid biomes) { byte[][] result = new byte[world.getMaxHeight() / 16][]; for (int lx = 0; lx < 16; lx++) { int gx = cx * 16 + lx; for (int lz = 0; lz < 16; lz++) { int gz = cz * 16 + lz; // The biome should always be "plains". biomes.setBiome(lx, lz, Biome.PLAINS); // Set the ground level bedrock block. setBlock(result, lx, 0, lz, (byte) 7 /* bedrock */); // Add a platform if the current xz-location is part of a movie set. if (MovieSetUtils.isInsideMovieSet(new Pos2D(gx, gz))) { for (int y = 1; y < Consts.SET_HEIGHT; y++) { setBlock(result, lx, y, lz, (byte) 3 /* dirt */); } setBlock(result, lx, Consts.SET_HEIGHT, lz, (byte) 2 /* grass */); } } } return result; }
@EventHandler public void onPlayerInteract(PlayerInteractEvent e) { if (e.getAction() != Action.RIGHT_CLICK_BLOCK) { return; } if (e.getClickedBlock().getState() instanceof Sign) { CheckPerms perms = new CheckPerms(wild); Sign sign = (Sign) e.getClickedBlock().getState(); if (sign.getLine(1).equalsIgnoreCase("[§1Wild§0]") && sign.getLine(0).equalsIgnoreCase("§4====================")) { if (!Wild.cancel.contains(e.getPlayer().getUniqueId())) { if(sign.getLine(3)!=null){ try{ for(World world : Bukkit.getWorlds()){ if(world.getName().toLowerCase().equals(sign.getLine(3).toLowerCase())){ perms.check(e.getPlayer(),world.getName()); return; } } Biome biome = Biome.valueOf(sign.getLine(3).toUpperCase()); wild.biome.put(e.getPlayer().getUniqueId(),biome); }catch(IllegalArgumentException ex){ Location loc = e.getClickedBlock().getLocation(); Bukkit.getLogger().severe("Biome wild sign at " +loc.getWorld().getName()+","+loc.getBlockX() +","+loc.getBlockY()+ "," + loc.getBlockZ() +" has a biome or a world that is incorrect please fix"); } } perms.check(e.getPlayer()); } } } }
public boolean getLiquid(Location loc) { loc.setY(loc.getBlockY() - 3.0); int x = loc.getBlockX(); int z = loc.getBlockZ(); if (loc.getWorld().getBlockAt(loc).isLiquid() || loc.getWorld().getBiome(x, z).equals(Biome.OCEAN) || loc.getWorld().getBiome(x, z).equals(Biome.DEEP_OCEAN)) return true; else return false; }
public boolean inNether(Location loc, Player target) { if (loc.getWorld().getBiome(loc.getBlockX(), loc.getBlockZ()) == Biome.HELL || target.getWorld().getName().equals("DIM-1")) { inNether = true; } else { inNether = false; } return inNether; }
public int getSolidBlock(int x, int z, String w, Player p) { int y = 0; World world = Bukkit.getWorld(w); if (world.getBiome(x, z).equals(Biome.HELL)) {//95 return getSolidBlockNether(x,z,p); } else { for (int i = world.getMaxHeight(); i >= 0; i--) { y = i; if (!world.getBlockAt(x, y, z).isEmpty()) { return y+ 3; } } } return 5; }
public boolean blacklistBiome(Location loc) { List<String> biomes = wild.getConfig().getStringList("Blacklisted_Biomes"); if (biomes.size() == 0) { return false; } else { for (String biome : biomes) { biome = biome.toUpperCase(); if (loc.getBlock().getBiome() == Biome.valueOf(biome)) { return true; } } } return false; }
@Override protected Biome[] get(final Event e, final Location[] source) { return get(source, new Converter<Location, Biome>() { @SuppressWarnings("null") @Override public Biome convert(final Location l) { return l.getWorld().getBiome(l.getBlockX(), l.getBlockZ()); } }); }
@Override @Nullable public Class<?>[] acceptChange(final ChangeMode mode) { if (mode == ChangeMode.SET) return new Class[] {Biome.class}; return super.acceptChange(mode); }
private boolean checkBiome(String biomename) { for (Biome biome : Biome.values()) { if (biome.name().equals(biomename)) { return true; } } return false; }
@Override public boolean runCmd(final Command cmd, final CommandSender sender, String[] args) { if (!(sender instanceof Player)) { /* This is not possible from the server console */ sender.sendMessage(plugin.getYamlManager().getLanguage().noConsoleMode); return true; } /* Build and get all variables */ Player player = (Player) sender; /* Permission Check */ if (!player.hasPermission(this.permNode)) { sender.sendMessage(plugin.getYamlManager().getLanguage().errorNoPermission); return true; } Biome[] biomes = Biome.values(); List<String> biomeList = new ArrayList<>(); for (Biome biome : biomes) { biomeList.add(biome.name()); } sender.sendMessage(plugin.getYamlManager().getLanguage().landBiomeListHeader); sender.sendMessage(biomeList.toString().replace("[", " ").replace("]", " ")); return true; }
public boolean changeBiomeChunk(Chunk chunk, Biome biome) { try { new ChangeBiome(plugin, chunk, biome).change(); } catch (Exception e) { e.printStackTrace(); return false; } return true; }
public void setBiome(int x, int z, Biome bio) { BiomeBase bb = CraftBlock.biomeToBiomeBase(bio); if (this.world.isLoaded(new BlockPosition(x, 0, z))) { net.minecraft.server.Chunk chunk = this.world.getChunkAtWorldCoords(new BlockPosition(x, 0, z)); if (chunk != null) { byte[] biomevals = chunk.getBiomeIndex(); biomevals[((z & 0xF) << 4) | (x & 0xF)] = (byte)bb.id; } } }