Package org.bukkit.block

Examples of org.bukkit.block.BlockState


  }
 
  @Override
  public final void setBlock(int x, int y, int z, Material material) {
    if (doClearData) {
      BlockState state = getActualBlock(x, y, z).getState();
      state.setType(material);
      state.setData(new MaterialData(material));
      state.update(true, doPhysics);
    } else
      getActualBlock(x, y, z).setType(material);
  }
View Full Code Here


  public final boolean isNonstackableBlock(int x, int y, int z) {
    return isNonstackableBlock(getActualBlock(x, y, z));
  }
 
  private void setBlockTypeAndColor(int x, int y, int z, Material material, DyeColor color) {
    BlockState state = getActualBlock(x, y, z).getState();
    state.setType(material);
    MaterialData data = state.getData();
    if (data instanceof Colorable)
      ((Colorable)state.getData()).setColor(color);
    else
      BlackMagic.setBlockStateColor(state, color); //BUKKIT: none of the newly colorable blocks materials are colorable
    state.update(true, doPhysics);
  }
View Full Code Here

      BlackMagic.setBlockStateColor(state, color); //BUKKIT: none of the newly colorable blocks materials are colorable
    state.update(true, doPhysics);
  }
 
  private void setBlockIfTypeThenColor(int x, int y, int z, Material material, DyeColor color) {
    BlockState state = getActualBlock(x, y, z).getState();
    if (state.getType() == material) {
      MaterialData data = state.getData();
      if (data instanceof Colorable)
        ((Colorable)state.getData()).setColor(color);
      else
        BlackMagic.setBlockStateColor(state, color); //BUKKIT: none of the newly colorable blocks materials are colorable
      state.update(true, doPhysics);
    }
  }
View Full Code Here

      }
    }
  }
 
  public void setBlockTypeAndDirection(int x, int y, int z, Material material, BlockFace facing) {
    BlockState state = getActualBlock(x, y, z).getState();
    state.setType(material);
    MaterialData data = state.getData();
    if (data instanceof Directional)
      ((Directional)state.getData()).setFacingDirection(facing);
    state.update(true, doPhysics);
  }
View Full Code Here

      }
    }
  }
 
  public void setBlockTypeAndTexture(int x, int y, int z, Material material, Material texture) {
    BlockState state = getActualBlock(x, y, z).getState();
    state.setType(material);
    MaterialData data = state.getData();
    if (data instanceof TexturedMaterial)
      ((TexturedMaterial)state.getData()).setMaterial(texture);
    state.update(true, doPhysics);
  }
View Full Code Here

  public final void setVines(int x, int y1, int y2, int z, BlockFace... faces) {
    Vine data = new Vine(faces);
    for (int y = y1; y < y2; y++) {
      Block block = getActualBlock(x, y, z);
      if (block.getType() == Material.VINE) {
        BlockState state = block.getState();
        Vine vines = (Vine)(state.getData());
        for (BlockFace face: faces)
          vines.putOnFace(face);
        state.update();
      } else
        setBlock(getActualBlock(x, y, z), Material.VINE, data);
    }
  }
View Full Code Here

  public static final boolean setBlockType(Block block, Material material, int rawdata) {
    return setBlockType(block, material, rawdata, true, true);
  }
 
  public static final boolean setBlockType(Block block, Material material, int rawdata, boolean update, boolean physics) {
    BlockState state = block.getState();
    state.setType(material);
    if (rawdata != 0)
      state.setRawData((byte) (rawdata & 0xff));
    return state.update(update, physics);
  }
View Full Code Here

  public static final void setBlockStateColor(BlockState state, DyeColor color) {
    state.setRawData(color.getWoolData());
  }
 
  public static final boolean setBlockType(Block block, int typeId, int rawdata) {
    BlockState state = block.getState();
    state.setTypeId(typeId);
    if (rawdata != 0)
      state.setRawData((byte) (rawdata & 0xff));
    return state.update(true);
  }
View Full Code Here

    //Only interested in liquids flowing
    if (!event.getBlock().isLiquid()) return;

    Location loc = event.getToBlock().getLocation();
    BlockState from = event.getBlock().getState();
    BlockState to = event.getToBlock().getState();
    MaterialData data = from.getData();

    //Lava
    if (from.getTypeId() == 10 || from.getTypeId() == 11) {

      //Flowing into a normal block
      if (fluidBlocks.contains(to.getTypeId())) {
        data.setData((byte)(from.getRawData() + 1));
        from.setData(data);
      }

      //Flowing into water
      else if (to.getTypeId() == 8 || to.getTypeId() == 9) {
        from.setTypeId(event.getFace() == BlockFace.DOWN?10:4);
        data.setData((byte)0);
        from.setData(data);
      }
      DataManager.addEntry(new BlockChangeEntry("Environment", DataType.LAVA_FLOW, loc, to, from));

    }

    //Water
    else if (from.getTypeId() == 8 || from.getTypeId() == 9) {

      //Normal block
      if (fluidBlocks.contains(to.getTypeId())) {
        data.setData((byte)(from.getRawData() + 1));
        from.setData(data);
        DataManager.addEntry(new BlockChangeEntry("Environment", DataType.WATER_FLOW, loc, to, from));
      }

      //If we are flowing over lava, cobble or obsidian will form
      BlockState lower = event.getToBlock().getRelative(BlockFace.DOWN).getState();
      if (lower.getTypeId() == 10 || lower.getTypeId() == 11) {
        from.setTypeId(lower.getData().getData() == 0?49:4);
        loc.setY(loc.getY() - 1);
        DataManager.addEntry(new BlockChangeEntry("Environment", DataType.WATER_FLOW, loc, lower, from));
      }

    }
View Full Code Here

        DataManager.addEntry(new SignEntry("Environment", DataType.SIGN_BREAK, event.getBlock()));
      DataManager.addEntry(new BlockEntry("Environment", DataType.ENDERMAN_PICKUP, block));
    } else if (Config.isLogged(DataType.ENDERMAN_PLACE)) {
      // Enderman placing block
      Enderman enderman = (Enderman) event.getEntity();
      BlockState newState = block.getState();
      if (enderman.getCarriedMaterial() != null) {
        try {
          newState.setData(enderman.getCarriedMaterial());
        } catch (Exception e) { }
        newState.setType(enderman.getCarriedMaterial().getItemType());
      }

      DataManager.addEntry(new BlockChangeEntry("Environment", DataType.ENDERMAN_PLACE, block.getLocation(), block.getState(), newState));
    }
  }
View Full Code Here

TOP

Related Classes of org.bukkit.block.BlockState

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.