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 int height = NormalGenerator.HEIGHT;
    final List<Block> liquids = new ArrayList<Block>();
    for (byte count = 0; count < waterAttempts; count++) {
      final int x = chunk.getBlockX(random);
      final int y = random.nextInt(height - 8) + 8;
      final int z = chunk.getBlockZ(random);
      final Block block = world.getBlock(x, y, z);
      if (isValidSourcePoint(block)) {
        block.setMaterial(VanillaMaterials.WATER);
        liquids.add(block);
      }
    }
    for (byte count = 0; count < lavaAttempts; count++) {
      final int x = chunk.getBlockX(random);
      final int y = random.nextInt(height - 8) + 8;
      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


    if (random.nextInt(odd) != 0) {
      return;
    }
    final Temple temple = new Temple();
    temple.setRandom(random);
    final World world = chunk.getWorld();
    final int x = chunk.getBlockX(random);
    final int z = chunk.getBlockZ(random);
    if (temple.canPlaceObject(world, x, 0, z)) {
      temple.placeObject(world, x, 0, z);
    }
View Full Code Here

  @Override
  public void populate(Chunk chunk, Random random) {
    if (chunk.getY() != 4) {
      return;
    }
    final World world = chunk.getWorld();
    for (OreType oreType : oreTypes) {
      final OreObject ore = new OreObject(oreType);
      ore.setRandom(random);
      for (byte i = 0; i < oreType.getClusterCount(); i++) {
        final int x = chunk.getBlockX(random);
View Full Code Here

  @Override
  public void populate(Chunk chunk, Random random) {
    if (chunk.getY() != 4) {
      return;
    }
    final World world = chunk.getWorld();
    HEIGHTS.setSeed((int) world.getSeed() * 51);
    final int x = chunk.getBlockX();
    final int z = chunk.getBlockZ();
    final double[][] heights = WorldGeneratorUtils.fastNoise(SNOW_HEIGHTS, 16, 16, 4, x, 0, z);
    for (byte xx = 0; xx < 16; xx++) {
      for (byte zz = 0; zz < 16; zz++) {
        if (((VanillaBiome) world.getBiome(x + xx, 63, z + zz)).getClimate().hasSnowfall()) {
          final int y = getHighestWorkableBlock(world, x + xx, z + zz);
          if (y != -1 && ((VanillaBlockMaterial) world.getBlockMaterial(x + xx, y - 1, z + zz)).
              canSupport(VanillaMaterials.SNOW, BlockFace.TOP)) {
            // normalize [-1, 1] to [0, 1] then scale to [0, 7]
            final short height = (short) GenericMath.floor((heights[xx][zz] * 0.5 + 0.5) * 7);
            world.setBlockMaterial(x + xx, y, z + zz, Snow.SNOW[height], height, null);
          }
        }
      }
    }
  }
View Full Code Here

    final int blockZ = chunk.getBlockZ();
    if (Math.abs(blockX % DISTANCE) >= Chunk.BLOCKS.SIZE
        || Math.abs(blockZ % DISTANCE) >= Chunk.BLOCKS.SIZE) {
      return;
    }
    final World world = chunk.getWorld();
    if (random.nextInt(ODD) == 0) {
      final Mineshaft mineshaft = new Mineshaft(random);
      final int x = blockX + random.nextInt(VARIATION * 2 + 1) - VARIATION;
      final int y = random.nextInt(RAND_Y) + BASE_Y;
      final int z = blockZ + random.nextInt(VARIATION * 2 + 1) - VARIATION;
View Full Code Here

  @Override
  public void populate(Chunk chunk, Random random) {
    if (chunk.getY() != 4) {
      return;
    }
    final World world = chunk.getWorld();
    if (random.nextInt(waterOdd) == 0) {
      final int x = chunk.getBlockX(random);
      final int z = chunk.getBlockZ(random);
      final int y = random.nextInt(128);
      if (!LogicUtil.equalsAny(world.getBiome(x, y, z), VanillaBiomes.DESERT, VanillaBiomes.DESERT_HILLS)) {
        final PondObject pond = new PondObject(random, PondObject.PondType.WATER);
        if (pond.canPlaceObject(world, x, y, z)) {
          pond.placeObject(world, x, y, z);
        }
      }
View Full Code Here

public class EntityMetadataHandler extends MessageHandler<EntityMetadataMessage> {
  @Override
  public void handleClient(ClientSession session, EntityMetadataMessage message) {
    Player player = session.getPlayer();
    World world = player.getWorld();

    int entityId = message.getEntityId();

    Entity entity = world.getEntity(entityId);
    if (entity == null) {
      player.getEngine().getLogger().warning("EntityMetadataHandler entity doesn't exist");
      return;
    }
View Full Code Here

    final int absBlockZ = Math.abs(blockZ);
    if (absBlockX <= distance || absBlockX > distance + Chunk.BLOCKS.SIZE
        || absBlockZ <= distance || absBlockZ > distance + Chunk.BLOCKS.SIZE) {
      return;
    }
    final World world = chunk.getWorld();
    final int excludedQuadrant = new Random(world.getSeed()).nextInt(4);
    switch (excludedQuadrant) {
      case 0:
        if (blockX > 0 && blockZ > 0) {
          return;
        }
View Full Code Here

    if (chunk.getY() != 4) {
      return;
    }
    final DungeonObject dungeon = new DungeonObject();
    dungeon.setRandom(random);
    final World world = chunk.getWorld();
    for (byte count = 0; count < attempts; count++) {
      final int x = chunk.getBlockX(random);
      final int z = chunk.getBlockZ(random);
      final int y = random.nextInt(128);
      dungeon.randomize();
View Full Code Here

public class ChunkDataHandler extends MessageHandler<ChunkDataMessage> {
  @Override
  public void handleClient(ClientSession session, ChunkDataMessage message) {
    Player player = session.getPlayer();
    World world = player.getEngine().getDefaultWorld();//player.getWorld();
    RepositionManager rm = player.getNetwork().getRepositionManager();

    int baseX = message.getX() << Chunk.BLOCKS.BITS;
    int baseZ = message.getZ() << Chunk.BLOCKS.BITS;

    final byte[][] data = message.getData();

    for (int i = 0; i < 16; i++) {
      int baseY = i << Chunk.BLOCKS.BITS;

      if (data[i] == null) {
        continue;
      }

      int index = 0;
      for (int xx = 0; xx < Chunk.BLOCKS.SIZE; xx++) {
        for (int yy = 0; yy < Chunk.BLOCKS.SIZE; yy++) {
          for (int zz = 0; zz < Chunk.BLOCKS.SIZE; zz++) {
            int x = rm.convertX(xx + baseX);
            int y = rm.convertY(yy + baseY);
            int z = rm.convertZ(zz + baseZ);

            short type = data[i][index];
            byte dat;
            if (index % 2 == 0) {
              dat = (byte) (data[i][(index / 2) + 4096] >> 4);
            } else {
              dat = (byte) (data[i][(index / 2) + 4096] & 0xF);
            }
            index++;

            if (type > 0) {
              BlockMaterial material = (BlockMaterial) VanillaMaterials.getMaterial(type, dat);
              world.getChunkFromBlock(x, y, z).getBlock(x, y, z).setMaterial(material);
            }
          }
        }
      }
    }
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.