Пример #1
0
  @Override
  public void onInteract(Entity entity, Block block, Action type, BlockFace clickedface) {
    super.onInteract(entity, block, type, clickedface);
    if (type == Action.RIGHT_CLICK) {
      BlockMaterial clickedmat = block.getMaterial();
      Cause<Entity> cause;
      if (entity instanceof Player) {
        cause = new PlayerCause((Player) entity);
      } else {
        cause = new EntityCause(entity);
      }
      if (clickedmat.equals(VanillaMaterials.TNT)) {
        // Detonate TntBlock
        VanillaMaterials.TNT.onIgnite(block, cause);
      } else {
        // Default fire creation
        Block target = block.translate(clickedface);
        // Default fire placement
        if (VanillaMaterials.FIRE.canCreate(target, (short) 0, cause)) {
          VanillaMaterials.FIRE.onCreate(target, (short) 0, cause);
          Slot held = PlayerUtil.getHeldSlot(entity);
          if (held != null && !PlayerUtil.isCostSuppressed(entity)) {
            held.addData(1);
          }
        }

        // Handle the creation of portals
        Point pos = target.translate(BlockFace.BOTTOM).getPosition();
        VanillaObjects.NETHER_PORTAL.setActive(
            pos.getWorld(), pos.getBlockX(), pos.getBlockY(), pos.getBlockZ(), true);
      }
    }
  }
Пример #2
0
 @Command(
     aliases = {"biome"},
     usage = "",
     desc = "Print out the name of the biome at the current location",
     min = 0,
     max = 0)
 @CommandPermissions("vanilla.command.biome")
 public void getBiomeName(CommandContext args, CommandSource source) throws CommandException {
   if (!(source instanceof Player)) {
     throw new CommandException("Only a player may call this command.");
   }
   Player player = (Player) source;
   if (!(player.getTransform().getPosition().getWorld().getGenerator()
       instanceof BiomeGenerator)) {
     throw new CommandException("This map does not appear to have any biome data.");
   }
   Point pos = player.getTransform().getPosition();
   Biome biome = pos.getWorld().getBiome(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ());
   source.sendMessage(
       plugin.getPrefix(),
       ChatStyle.BRIGHT_GREEN,
       "Current biome: ",
       ChatStyle.WHITE,
       (biome != null ? biome.getName() : "none"));
 }
Пример #3
0
 public SpoutBlock(Point position, Source source) {
   this(
       position.getWorld(),
       position.getBlockX(),
       position.getBlockY(),
       position.getBlockZ(),
       source);
 }
Пример #4
0
 @Override
 public void onTick(float dt) {
   Point pos = this.getOwner().getTransform().getPosition();
   BlockMaterial material =
       pos.getWorld().getBlockMaterial(pos.getBlockX(), pos.getBlockY() - 1, pos.getBlockZ());
   if (isObstacle(material)) {
     pos.getWorld()
         .setBlockMaterial(
             pos.getBlockX(),
             pos.getBlockY(),
             pos.getBlockZ(),
             getMaterial(),
             getMaterial().getData(),
             getMaterial().toCause(pos));
     this.getOwner().remove();
   } else {
     this.getOwner().getTransform().setPosition(pos.add(0, fallSpeed, 0F));
     fallSpeed = Math.max(-1F, fallSpeed - dt);
   }
 }
  private static int[][] getColumnHeights(Point p) {
    int[][] heights = new int[Chunk.BLOCKS.SIZE][Chunk.BLOCKS.SIZE];

    World w = p.getWorld();

    for (int xx = 0; xx < Chunk.BLOCKS.SIZE; xx++) {
      for (int zz = 0; zz < Chunk.BLOCKS.SIZE; zz++) {
        heights[xx][zz] = w.getSurfaceHeight(p.getBlockX() + xx, p.getBlockZ() + zz, true);
      }
    }
    return heights;
  }
  private static BlockMaterial[][] getColumnTopmostMaterials(Point p) {
    BlockMaterial[][] materials = new BlockMaterial[Chunk.BLOCKS.SIZE][Chunk.BLOCKS.SIZE];

    World w = p.getWorld();

    for (int xx = 0; xx < Chunk.BLOCKS.SIZE; xx++) {
      for (int zz = 0; zz < Chunk.BLOCKS.SIZE; zz++) {
        materials[xx][zz] = w.getTopmostBlock(p.getBlockX() + xx, p.getBlockZ() + zz, true);
      }
    }
    return materials;
  }