Package org.spout.api.geo

Examples of org.spout.api.geo.World


  @Override
  public void onIgnite(Block block, Cause<?> cause) {
    // spawn a primed TntBlock
    Point pos = block.getPosition();
    World world = pos.getWorld();
    Tnt tnt = world.createEntity(pos, Tnt.class).add(Tnt.class);
    world.spawnEntity(tnt.getOwner());
    block.setMaterial(VanillaMaterials.AIR, cause);
  }
View Full Code Here


    ItemStack item = slot.get();
    Block facingBlock = block.translate(this.getFacing(block));
    if (item.getMaterial().equals(VanillaMaterials.TNT)) {
      //Place Activated TNT entity at direction of Dispenser
      if (facingBlock.getMaterial().getShape() != null) {
        World world = facingBlock.getWorld();
        Tnt tnt = world.createEntity(facingBlock.getPosition(), Tnt.class).add(Tnt.class);
        tnt.getOwner().getPhysics().force(new Vector3f(0.5D, 0.5D, 0.5D));
        world.spawnEntity(tnt.getOwner());
        slot.addAmount(-1);
        return true;
      }
    } else if (item.getMaterial() instanceof SpawnEgg) {
      if (facingBlock.getMaterial().getShape() != null) {
View Full Code Here

  public void setEyeOfTheEnder(Block block, boolean eyeOfTheEnder) {
    if (hasEyeOfTheEnder(block) == eyeOfTheEnder) {
      return;
    }
    block.setDataBits(0x4, eyeOfTheEnder);
    final World w = block.getWorld();
    final int x = block.getX();
    final int y = block.getY();
    final int z = block.getZ();
    if (eyeOfTheEnder && VanillaObjects.THE_END_PORTAL.isActive(w, x, y, z)) {
      VanillaObjects.THE_END_PORTAL.setActive(w, x, y, z, true);
View Full Code Here

  public synchronized void execute(Point position, float size, boolean fire, Cause<?> cause) {
    int xoff = position.getBlockX();
    int yoff = position.getBlockY();
    int zoff = position.getBlockZ();
    World world = position.getWorld();

    this.blocksToDestroy.clear();
    this.root.sourcedamage = size * (0.7F + (float) Math.random() * 0.6F);

    //recursively operate on all blocks
    float damageFactor;
    boolean hasDamage = true;
    ExplosionLayer layer;
    for (int i = 0; i < this.layers.size() && hasDamage; i++) {
      hasDamage = false;
      layer = this.layers.get(i);
      for (ExplosionSlot slot : layer.slots) {
        //prepare the block information
        if (!slot.block.isSet) {
          slot.block.prepare(world, xoff, yoff, zoff, GenericMath.getRandom());
        }

        //subtract damage factor
        damageFactor = slot.sourcedamage - slot.block.damageFactor;
        slot.sourcedamage = 0f;
        if (damageFactor <= 0f) {
          continue;
        }

        //this block has been destroyed
        if (!slot.block.destroy) {
          slot.block.destroy = true;
          Block block = world.getBlock(slot.block.realx, slot.block.realy, slot.block.realz);
          blocksToDestroy.add(block);
        }

        //one block layer further...
        if ((damageFactor -= 0.225f) <= 0.0f) {
View Full Code Here

  @Override
  public void populate(Chunk chunk, Random random) {
    if (chunk.getY() != 4) {
      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(elevationRandomness) + minimumElevation;
      final int z = chunk.getBlockZ(random);
      final Block block = world.getBlock(x, y, z);
      if (block.isMaterial(VanillaMaterials.STONE)) {
        block.setMaterial(VanillaMaterials.EMERALD_ORE);
      }
    }
  }
View Full Code Here

  @Override
  public void populate(Chunk chunk, Random random) {
    if (chunk.getY() != 4) {
      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 z = chunk.getBlockZ(random);
      for (byte size = 30; 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, zz);
        if (yy != -1 && world.getBlockMaterial(xx, yy, zz) == VanillaMaterials.AIR
            && canTallGrassStay(world.getBlock(xx, yy, zz))) {
          final TallGrass grass = factory.make(random);
          world.setBlockMaterial(xx, yy, zz, grass, grass.getData(), null);
        }
      }
    }
  }
View Full Code Here

import org.spout.vanilla.protocol.msg.player.pos.PlayerSpawnMessage;

public class PlayerSpawnHandler extends MessageHandler<PlayerSpawnMessage> {
  @Override
  public void handleClient(ClientSession session, PlayerSpawnMessage message) {
    World w = session.getEngine().getDefaultWorld();
    final Point pos = new Point(w, message.getX(), message.getY(), message.getZ());

    // Create a new Player Entity with a Human Entity Component
    Entity entity = w.createEntity(pos, Human.class);
    entity.setSavable(true);
    entity.add(Human.class).setName(message.getName());
    EntityPrefab humanPrefab = session.getEngine().getFileSystem().getResource("entity://Vanilla/entities/human/human.sep");
    entity = humanPrefab.createEntity(pos);

    // Load in Metadata
    MetadataComponent metadata = entity.get(MetadataComponent.class);
    if (metadata != null) {
      metadata.setParameters(message.getParameters());
    }

    w.spawnEntity(entity);
    System.out.println(message.toString());
  }
View Full Code Here

  @Override
  public void populate(Chunk chunk, Random random) {
    if (chunk.getY() != 4) {
      return;
    }
    final World world = chunk.getWorld();
    final HugeMushroomObject mushroom;
    if (random.nextBoolean()) {
      mushroom = new HugeMushroomObject(HugeMushroomType.RED);
    } else {
      mushroom = new HugeMushroomObject(HugeMushroomType.BROWN);
View Full Code Here

    int x = rmInverse.convertX(message.getX());
    int y = rmInverse.convertY(message.getY());
    int z = rmInverse.convertZ(message.getZ());
    int state = message.getState();

    World w = player.getWorld();
    Point point = new Point(w, x, y, z);
    Block block = w.getBlock(point);
    BlockMaterial blockMaterial = block.getMaterial();

    short minecraftID = VanillaMaterials.getMinecraftId(blockMaterial);
    BlockFace clickedFace = message.getFace();
    Human human = player.get(Human.class);
View Full Code Here

    totalHeight = (byte) (baseHeight + random.nextInt(randomHeight));
  }

  public static void growTree(Sapling sapling, Block pos, Random random) {
    final TreeObject tree;
    final World world = pos.getWorld();
    final int y = pos.getY();
    if (sapling == Sapling.JUNGLE) {
      final int x = pos.getX();
      final int z = pos.getZ();
      byte saplingCount = 0;
      Block firstSapling = null;
      for (byte xx = -1; xx < 2; xx++) {
        for (byte zz = -1; zz < 2; zz++) {
          if (world.getBlockMaterial(x + xx, y, z + zz) == Sapling.JUNGLE) {
            saplingCount++;
            if (saplingCount == 1) {
              firstSapling = world.getBlock(x + xx, y, z + zz);
            }
          }
        }
      }
      if (saplingCount > 3 && firstSapling.translate(1, 0, 1).isMaterial(Sapling.JUNGLE)
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.