Package org.spout.api.geo

Examples of org.spout.api.geo.World


  @Override
  public void populate(Chunk chunk, Random random) {
    if (chunk.getY() != 4) {
      return;
    }
    final World world = chunk.getWorld();
    final GlowstonePatchObject glowstone = new GlowstonePatchObject();
    glowstone.setRandom(random);
    for (int amount = getAmount(random); amount > 0; amount--) {
      final int x = chunk.getBlockX(random);
      final int y = random.nextInt(NetherGenerator.HEIGHT);
View Full Code Here


      return;
    }
    if (random.nextInt(odd) != 0) {
      return;
    }
    final World world = chunk.getWorld();
    final int amount = getAmount(random);
    for (byte count = 0; count < amount; count++) {
      final int x = chunk.getBlockX(random);
      final int y = random.nextInt(NetherGenerator.HEIGHT);
      final int z = chunk.getBlockZ(random);
      final Mushroom mushroom = random.nextInt(4) == 0 ? VanillaMaterials.RED_MUSHROOM : VanillaMaterials.BROWN_MUSHROOM;
      for (byte size = 6; size > 0; size--) {
        final int xx = x - 7 + random.nextInt(15);
        final int zz = z - 7 + random.nextInt(15);
        final int yy = getHighestWorkableBlock(world, xx, y, zz);
        if (yy != -1 && world.getBlockMaterial(xx, yy, zz) == VanillaMaterials.AIR
            && mushroom.isValidPosition(world.getBlock(xx, yy, zz), BlockFace.BOTTOM, false)) {
          world.setBlockMaterial(xx, yy, zz, mushroom, (short) 0, null);
        }
      }
    }
  }
View Full Code Here

  @Override
  public void populate(Chunk chunk, Random random) {
    if (chunk.getY() != 4) {
      return;
    }
    final World world = chunk.getWorld();
    final List<Block> liquids = new ArrayList<Block>();
    for (byte count = 0; count < lavaAttempts; count++) {
      final int x = chunk.getBlockX(random);
      final int y = random.nextInt(NetherGenerator.HEIGHT);
      final int z = chunk.getBlockZ(random);
      final Block block = world.getBlock(x, y, z);
      if (isValidSourcePoint(block)) {
        block.setMaterial(VanillaMaterials.LAVA);
        liquids.add(block);
      }
    }
View Full Code Here

  @Override
  public void populate(Chunk chunk, Random random) {
    if (chunk.getY() != 4) {
      return;
    }
    final World world = chunk.getWorld();
    for (int amount = getAmount(random); amount > 0; amount--) {
      final int x = chunk.getBlockX(random);
      final int y = random.nextInt(NetherGenerator.HEIGHT);
      final int z = chunk.getBlockZ(random);
      for (byte size = 8; size > 0; size--) {
        final int xx = x - 7 + random.nextInt(15);
        final int zz = z - 7 + random.nextInt(15);
        final int yy = getHighestWorkableBlock(world, xx, y, zz);
        if (yy != -1 && world.getBlockMaterial(xx, yy, zz).isMaterial(VanillaMaterials.AIR)) {
          world.setBlockMaterial(xx, yy, zz, VanillaMaterials.FIRE, (short) 0, null);
        }
      }
    }
  }
View Full Code Here

      args.success("object", object);
    }
    args.assertCompletelyParsed();

    final Point loc = player.getPhysics().getPosition();
    final World world = loc.getWorld();
    final int x = loc.getBlockX();
    final int y = loc.getBlockY();
    final int z = loc.getBlockZ();
    final boolean force = args.has("force");
    if (!object.canPlaceObject(world, x, y, z)) {
View Full Code Here

  }

  @CommandDescription (aliases = {"killall", "ka"}, desc = "Kill all non-player or world entities within a world")
  @Permissible ("vanilla.command.debug")
  public void killall(CommandSource source, CommandArguments args) throws CommandException {
    World world = args.popWorld("world", source);
    args.assertCompletelyParsed();

    List<Entity> entities = world.getAll();
    int count = 0;
    for (Entity entity : entities) {
      if (entity instanceof Player || (entity.get(VanillaEntityComponent.class) == null)) {
        continue;
      }
View Full Code Here

      biomeColors = (TFloatList) buffers.get(5);
    }
    // This colors whole block faces at once. Doing it for each vertex is too expensive.
    // 24 vertex coords per face (2 mesh face per block face, 3 vertices per mesh face, 4 coords per vertices)
    // This expects vertices to be grouped by block face.
    final World world = chunkModel.getCenter().getWorld();
    for (int i = 0; i < vertexCount; i += 24) {
      float r = 0;
      float g = 0;
      float b = 0;
      final int x = GenericMath.floor(vertices.get(i));
      final int y = GenericMath.floor(vertices.get(i + 1));
      final int z = GenericMath.floor(vertices.get(i + 2));
      for (byte xx = -1; xx <= 1; xx++) {
        for (byte zz = -1; zz <= 1; zz++) {
          VanillaBiome biome = (VanillaBiome) world.getBiome(x + xx, y, z + zz);
          // Default to forest if no biome is set
          if (biome == null) {
            biome = VanillaBiomes.FOREST;
          }
          final Color color = getBiomeColor(biome);
View Full Code Here

        String generatorName = worldNode.GENERATOR.getString();
        VanillaGenerator generator = VanillaGenerators.byName(generatorName);
        if (generator == null) {
          throw new IllegalArgumentException("Invalid generator name for world '" + worldNode.getWorldName() + "': " + generatorName);
        }
        World world = ((Server) getEngine()).loadWorld(worldNode.getWorldName(), generator);

        // Apply general settings
        final ManagedMap data = world.getData();
        data.put(VanillaData.GAMEMODE, GameMode.get(worldNode.GAMEMODE.getString()));
        data.put(VanillaData.DIFFICULTY, Difficulty.get(worldNode.DIFFICULTY.getString()));
        data.put(VanillaData.DIMENSION, Dimension.get(worldNode.SKY_TYPE.getString()));

        world.addLightingManager(VanillaLighting.BLOCK_LIGHT);
        world.addLightingManager(VanillaLighting.SKY_LIGHT);

        // Add to worlds
        worlds.add(world);
      }
    }

    final int radius = VanillaConfiguration.SPAWN_RADIUS.getInt();
    final int protectionRadius = VanillaConfiguration.SPAWN_PROTECTION_RADIUS.getInt();

    if (worlds.isEmpty()) {
      return;
    }
    //Register protection service used for spawn protection.
    getEngine().getServiceManager().register(ProtectionService.class, new VanillaProtectionService(), this, ServiceManager.ServicePriority.Highest);

    for (World world : worlds) {

      // Keep spawn loaded
      WorldConfigurationNode worldConfig = VanillaConfiguration.WORLDS.get(world);
      final WorldGenerator generator = world.getGenerator();
      boolean newWorld = world.getAge() <= 0;

      if (worldConfig.LOADED_SPAWN.getBoolean() || newWorld) {

        final Point spawn;

        // Grab safe spawn if newly created world and generator is vanilla generator, else get old one.
        if (newWorld && generator instanceof VanillaGenerator) {
          spawn = ((VanillaGenerator) generator).getSafeSpawn(world);
          world.setSpawnPoint(new Transform(spawn, Quaternionf.IDENTITY, Vector3f.ONE));
        } else {
          spawn = world.getSpawnPoint().getPosition();
        }

        // Start the protection for the spawn
        ((VanillaProtectionService) getEngine().getServiceManager().getRegistration(ProtectionService.class).getProvider()).addProtection(new SpawnProtection(world.getName() + " Spawn Protection", world, spawn, protectionRadius));

        // Chunks coords of the spawn
        int cx = spawn.getBlockX() >> Chunk.BLOCKS.BITS;
        int cz = spawn.getBlockZ() >> Chunk.BLOCKS.BITS;

        // Load or generate spawn area
        int effectiveRadius = newWorld ? (2 * radius) : radius;

        // Add observer to spawn to keep loaded if desired
        if (worldConfig.LOADED_SPAWN.getBoolean()) {
          @SuppressWarnings ("unchecked")
          Entity e = world.createAndSpawnEntity(spawn, LoadOption.LOAD_GEN, NetworkComponent.class);
          e.get(NetworkComponent.class).setObserver(new FlatIterator(cx, 0, cz, 16, effectiveRadius));
        }
      }

      // Set the appropriate sky for the world type
      if (generator instanceof NetherGenerator) {
        world.add(NetherSky.class).setHasWeather(false);
      } else if (generator instanceof TheEndGenerator) {
        world.add(TheEndSky.class).setHasWeather(false);
      } else if (generator instanceof SkylandsGenerator) {
        world.add(NormalSky.class).setHasWeather(false);
      } else {
        world.add(NormalSky.class);
      }
    }
  }
View Full Code Here

            if (strikes > 0) {
              adjustX += (ra.nextBoolean() ? -1 : 1) * ra.nextInt(2);
              adjustY += (ra.nextBoolean() ? -1 : 1) * ra.nextInt(8);
              adjustZ += (ra.nextBoolean() ? -1 : 1) * ra.nextInt(2);
            }
            World world = getWorld();
            Point point = new Point(world, x + adjustX, y + adjustY, z + adjustZ);
            world.createAndSpawnEntity(point, LoadOption.NO_LOAD, Lightning.class);
            for (Player p : GeneralEffects.LIGHTNING_THUNDER.getNearbyPlayers(point, null, 600)) {
              double dist = p.getPhysics().getPosition().distanceSquared(point);
              float volume = (float) (10000F - Math.pow(dist, 0.73));
              if (volume > 0) {
                GeneralEffects.LIGHTNING_THUNDER.adjust(volume, 0.7F).play(p, point);
View Full Code Here

  public boolean find(Point center, int radius) {
    return find(center, radius, radius, radius);
  }

  public boolean find(Point center, int xRadius, int yRadius, int zRadius) {
    final World world = center.getWorld();
    for (int y = center.getBlockY() - xRadius; y < center.getBlockY() + xRadius; y++) {
      for (int x = center.getBlockX() - yRadius; x < center.getBlockX() + yRadius; x++) {
        for (int z = center.getBlockZ() - zRadius; z < center.getBlockZ() + zRadius; z++) {
          if (find(world.getBlock(x, y, z))) {
            return true;
          }
        }
      }
    }
View Full Code Here

TOP

Related Classes of org.spout.api.geo.World

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.