本文整理汇总了Java中com.sk89q.worldedit.blocks.ItemID类的典型用法代码示例。如果您正苦于以下问题:Java ItemID类的具体用法?Java ItemID怎么用?Java ItemID使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ItemID类属于com.sk89q.worldedit.blocks包,在下文中一共展示了ItemID类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBlockInHand
import com.sk89q.worldedit.blocks.ItemID; //导入依赖的package包/类
@Override
public BaseBlock getBlockInHand() throws WorldEditException {
ItemStack itemStack = player.getItemInHand();
if (itemStack == null) {
return EditSession.nullBlock;
}
final int typeId = itemStack.getTypeId();
switch (typeId) {
case 0:
return EditSession.nullBlock;
case ItemID.INK_SACK:
final Dye materialData = (Dye) itemStack.getData();
if (materialData.getColor() == DyeColor.BROWN) {
return FaweCache.getBlock(BlockID.COCOA_PLANT, 0);
}
break;
case ItemID.HEAD:
return new SkullBlock(0, (byte) itemStack.getDurability());
default:
final BaseBlock baseBlock = BlockType.getBlockForItem(typeId, itemStack.getDurability());
if (baseBlock != null) {
return baseBlock;
}
break;
}
BaseBlock block = FaweCache.getBlock(typeId, itemStack.getType().getMaxDurability() != 0 ? 0 : Math.max(0, itemStack.getDurability()));
if (Settings.IMP.EXPERIMENTAL.PERSISTENT_BRUSHES && Fawe.<FaweBukkit>imp().getItemUtil() != null) {
return new BrushBoundBaseBlock(this, WorldEdit.getInstance().getSession(this), itemStack);
}
return block;
}
示例2: isHoldingPickAxe
import com.sk89q.worldedit.blocks.ItemID; //导入依赖的package包/类
@Override
public boolean isHoldingPickAxe() {
int item = getItemInHand();
return item == ItemID.IRON_PICK
|| item == ItemID.WOOD_PICKAXE
|| item == ItemID.STONE_PICKAXE
|| item == ItemID.DIAMOND_PICKAXE
|| item == ItemID.GOLD_PICKAXE;
}
示例3: matchItemData
import com.sk89q.worldedit.blocks.ItemID; //导入依赖的package包/类
/**
* Attempt to match item data values.
*
* @param id
* @param filter
* @return
* @throws com.sk89q.minecraft.util.commands.CommandException
*/
int matchItemData(final int id, final String filter) throws CommandException {
try {
// First let's try the filter as if it was a number
return Integer.parseInt(filter);
}
catch (final NumberFormatException ignored) {
}
// So the value isn't a number, but it may be an alias!
switch (id) {
case BlockID.WOOD:
if (filter.equalsIgnoreCase("redwood")) {
return 1;
}
else if (filter.equalsIgnoreCase("birch")) { return 2; }
throw new CommandException("Unknown wood type name of '" + filter + "'.");
case BlockID.STEP:
case BlockID.DOUBLE_STEP:
final BlockType dataType = BlockType.lookup(filter);
if (dataType != null) {
if (dataType == BlockType.STONE) {
return 0;
}
else if (dataType == BlockType.SANDSTONE) {
return 1;
}
else if (dataType == BlockType.WOOD) {
return 2;
}
else if (dataType == BlockType.COBBLESTONE) {
return 3;
}
else {
throw new CommandException("Invalid slab material of '" + filter + "'.");
}
}
else {
throw new CommandException("Unknown slab material of '" + filter + "'.");
}
case BlockID.CLOTH:
case BlockID.STAINED_CLAY:
case BlockID.STAINED_GLASS:
case BlockID.STAINED_GLASS_PANE:
final ClothColor col = ClothColor.lookup(filter);
if (col != null) { return col.getID(); }
throw new CommandException("Unknown wool color name of '" + filter + "'.");
case ItemID.INK_SACK: // Dye
final ClothColor dyeCol = ClothColor.lookup(filter);
if (dyeCol != null) { return 15 - dyeCol.getID(); }
throw new CommandException("Unknown dye color name of '" + filter + "'.");
default:
throw new CommandException("Invalid data value of '" + filter + "'.");
}
}