类org.bukkit.material.Directional源码实例Demo

下面列出了怎么用org.bukkit.material.Directional的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: BedwarsRel   文件: Region.java
@SuppressWarnings("deprecation")
public void addBreakedBlock(Block bedBlock) {
  if (bedBlock.getState().getData() instanceof Directional) {
    this.breakedBlockFace.put(bedBlock,
        ((Directional) bedBlock.getState().getData()).getFacing());
  }

  this.breakedBlockTypes.put(bedBlock, bedBlock.getTypeId());
  this.breakedBlockData.put(bedBlock, bedBlock.getData());

  if (bedBlock.getState().getData() instanceof Redstone) {
    this.breakedBlockPower.put(bedBlock, ((Redstone) bedBlock.getState().getData()).isPowered());
  }

  this.breakedBlocks.add(bedBlock);
}
 
源代码2 项目: BedwarsRel   文件: Region.java
@SuppressWarnings("deprecation")
public void addPlacedUnbreakableBlock(Block placed, BlockState replaced) {
  this.placedUnbreakableBlocks.add(placed);
  if (replaced != null) {
    if (replaced.getData() instanceof Directional) {
      this.breakedBlockFace.put(replaced.getBlock(),
          ((Directional) replaced.getData()).getFacing());
    }

    this.breakedBlockTypes.put(replaced.getBlock(), replaced.getTypeId());
    this.breakedBlockData.put(replaced.getBlock(), replaced.getData().getData());
    this.breakedBlocks.add(replaced.getBlock());

    if (replaced.getData() instanceof Redstone) {
      this.breakedBlockPower.put(placed, ((Redstone) replaced.getData()).isPowered());
    }
  }
}
 
源代码3 项目: Skript   文件: Direction.java
@SuppressWarnings("deprecation")
public Vector getDirection(final Block b) {
	if (!relative)
		return new Vector(pitchOrX, yawOrY, lengthOrZ);
	final Material m = b.getType();
	if (!Directional.class.isAssignableFrom(m.getData()))
		return new Vector();
	final BlockFace f = ((Directional) m.getNewData(b.getData())).getFacing();
	return getDirection(pitchOrX == IGNORE_PITCH ? 0 : f.getModZ() * Math.PI / 2 /* only up and down have a z mod */, Math.atan2(f.getModZ(), f.getModX()));
}
 
源代码4 项目: Skript   文件: Direction.java
/**
 * @param b
 * @return The facing of the block or {@link BlockFace#SELF} if the block doesn't have a facing.
 */
@SuppressWarnings({"deprecation", "null"})
public static BlockFace getFacing(final Block b) {
	final Material m = b.getType();
	if (!Directional.class.isAssignableFrom(m.getData()))
		return BlockFace.SELF;
	return ((Directional) m.getNewData(b.getData())).getFacing();
}
 
源代码5 项目: BedwarsRel   文件: Region.java
@SuppressWarnings("deprecation")
public void addPlacedBlock(Block placeBlock, BlockState replacedBlock) {
  this.placedBlocks.add(placeBlock);
  if (replacedBlock != null) {
    if (replacedBlock.getData() instanceof Directional) {
      this.breakedBlockFace.put(replacedBlock.getBlock(),
          ((Directional) replacedBlock.getData()).getFacing());
    }

    this.breakedBlockTypes.put(replacedBlock.getBlock(), replacedBlock.getTypeId());
    this.breakedBlockData.put(replacedBlock.getBlock(), replacedBlock.getData().getData());

    this.breakedBlocks.add(replacedBlock.getBlock());
  }
}
 
源代码6 项目: DungeonsXL   文件: BlockAdapterMagicValues.java
@Override
public BlockFace getFacing(Block block) {
    MaterialData data = block.getState().getData();
    if (!(data instanceof Directional)) {
        throw new IllegalArgumentException("Block is not Directional");
    }
    return ((Directional) data).getFacing();
}
 
源代码7 项目: DungeonsXL   文件: BlockAdapterMagicValues.java
@Override
public void setFacing(Block block, BlockFace facing) {
    BlockState state = block.getState();
    MaterialData data = state.getData();
    if (!(data instanceof Directional)) {
        throw new IllegalArgumentException("Block is not Directional");
    }
    ((Directional) data).setFacingDirection(facing);
    state.setData(data);
    state.update();
}
 
 类所在包
 类方法
 同包方法