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

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

源代码1 项目: Kettle   文件: CraftBlockState.java
public boolean update(boolean force, boolean applyPhysics) {
    if (!isPlaced()) {
        return true;
    }
    Block block = getBlock();

    if (block.getType() != getType()) {
        if (!force) {
            return false;
        }
    }

    BlockPos pos = new BlockPos(x, y, z);
    IBlockState newBlock = CraftMagicNumbers.getBlock(getType()).getStateFromMeta(this.getRawData());
    block.setTypeIdAndData(getTypeId(), getRawData(), applyPhysics);
    world.getHandle().notifyBlockUpdate(
            pos,
            CraftMagicNumbers.getBlock(block).getStateFromMeta(block.getData()),
            newBlock,
            3
    );

    // Update levers etc
    if (applyPhysics && getData() instanceof Attachable) {
        world.getHandle().notifyNeighborsOfStateChange(pos.offset(CraftBlock.blockFaceToNotch(((Attachable) getData()).getAttachedFace())), newBlock.getBlock(), false);
    }

    if (nbt != null) {
        TileEntity te = world.getHandle().getTileEntity(new BlockPos(this.x, this.y, this.z));
        if (te != null) {
            te.readFromNBT(nbt);
        }
    }
    return true;
}
 
源代码2 项目: Shopkeepers   文件: SignShop.java
private BlockFace getSignFacingFromWorld() {
	// try getting the current sign facing from the sign in the world:
	Sign sign = this.getSign();
	if (sign != null) {
		return ((Attachable) sign.getData()).getFacing();
	}
	return null;
}
 
源代码3 项目: Shopkeepers   文件: SignShop.java
@Override
public boolean spawn() {
	Location signLocation = this.getActualLocation();
	if (signLocation == null) return false;

	Block signBlock = signLocation.getBlock();
	if (signBlock.getType() != Material.AIR) {
		return false;
	}

	// place sign: // TODO maybe also allow non-wall signs?
	// cancel block physics for this placed sign if needed:
	ShopkeepersPlugin.getInstance().cancelNextBlockPhysics(signLocation);
	signBlock.setType(Material.WALL_SIGN);
	// cleanup state if no block physics were triggered:
	ShopkeepersPlugin.getInstance().cancelNextBlockPhysics(null);

	// in case sign placement has failed for some reason:
	if (!Utils.isSign(signBlock.getType())) {
		return false;
	}

	// set sign facing:
	if (signFacing != null) {
		Sign signState = (Sign) signBlock.getState();
		((Attachable) signState.getData()).setFacingDirection(signFacing);
		// apply facing:
		signState.update();
	}

	// init sign content:
	updateSign = false;
	this.updateSign();

	return true;
}
 
源代码4 项目: HeavySpleef   文件: ExtensionLobbyWall.java
private static Block getAttached(Sign sign) {
	Attachable data = (Attachable) sign.getData();
	BlockFace attachingBlockFace = data.getFacing().getOppositeFace();
	
	return sign.getBlock().getRelative(attachingBlockFace);
}
 
 类所在包
 类方法
 同包方法