本文整理汇总了Java中net.minecraft.item.ItemBlock.getMetadata方法的典型用法代码示例。如果您正苦于以下问题:Java ItemBlock.getMetadata方法的具体用法?Java ItemBlock.getMetadata怎么用?Java ItemBlock.getMetadata使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.item.ItemBlock
的用法示例。
在下文中一共展示了ItemBlock.getMetadata方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBlockActivated
import net.minecraft.item.ItemBlock; //导入方法依赖的package包/类
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
ItemStack stack = player.getHeldItem(hand);
boolean isBlock = stack.getItem() instanceof ItemBlock && stack.getItem() != ModItems.ANGSTROM;
if(!world.isRemote && isBlock) {
//Replace
ItemBlock item = (ItemBlock) stack.getItem();
Block block = Block.getBlockFromItem(item);
int meta = item.getMetadata(stack);
IBlockState inState = block.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, meta, player, hand);
world.setBlockState(pos, inState);
block.onBlockPlacedBy(world, pos, inState, player, stack);
SoundType sound = block.getSoundType(inState, world, pos, player);
world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), sound.getPlaceSound(), SoundCategory.BLOCKS, 0.75F, 0.8F);
//Exchange
ItemStack drop = new ItemStack(Item.getItemFromBlock(this));
ItemHandlerHelper.giveItemToPlayer(player, drop);
if(!player.capabilities.isCreativeMode) {
stack.shrink(1);
}
}
return isBlock;
}
示例2: doBlockInteraction
import net.minecraft.item.ItemBlock; //导入方法依赖的package包/类
@Override
protected boolean doBlockInteraction(BlockPos pos, double distToBlock) {
if (drone.getPathNavigator().hasNoPath()) {
EnumFacing side = ProgWidgetPlace.getDirForSides(((ISidedWidget) widget).getSides());
for (int i = 0; i < drone.getInv().getSlots(); i++) {
ItemStack droneStack = drone.getInv().getStackInSlot(i);
if (droneStack.getItem() instanceof ItemBlock && ((ItemBlock) droneStack.getItem()).getBlock().canPlaceBlockOnSide(drone.world(), pos, ProgWidgetPlace.getDirForSides(((ISidedWidget) widget).getSides()))) {
if (widget.isItemValidForFilters(droneStack)) {
ItemBlock itemBlock = (ItemBlock) droneStack.getItem();
Block block = itemBlock.getBlock();
if (drone.world().mayPlace(block, pos, false, side, drone instanceof EntityDrone ? (EntityDrone) drone : null)) {
int newMeta = itemBlock.getMetadata(droneStack.getMetadata());
setFakePlayerAccordingToDir();
IBlockState iblockstate1 = block.getStateForPlacement(drone.world(), pos, side, side.getFrontOffsetX(), side.getFrontOffsetY(), side.getFrontOffsetZ(), newMeta, drone.getFakePlayer(), EnumHand.MAIN_HAND);
if (itemBlock.placeBlockAt(droneStack, drone.getFakePlayer(), drone.world(), pos, side, side.getFrontOffsetX(), side.getFrontOffsetY(), side.getFrontOffsetZ(), iblockstate1)) {
drone.addAir(null, -PneumaticValues.DRONE_USAGE_PLACE);
SoundType soundType = block.getSoundType(iblockstate1, drone.world(), pos, drone.getFakePlayer());
drone.world().playSound(pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, soundType.getPlaceSound(), SoundCategory.BLOCKS, (soundType.getVolume() + 1.0F) / 2.0F, soundType.getPitch() * 0.8F, false);
droneStack.shrink(1);
if (droneStack.getCount() <= 0) {
drone.getInv().setStackInSlot(i, ItemStack.EMPTY);
}
}
return false;
}
}
}
}
return false;
} else {
return true;
}
}
示例3: worksWith
import net.minecraft.item.ItemBlock; //导入方法依赖的package包/类
protected boolean worksWith(final Block referenceBlock, final int referenceMetadata) {
for (ItemStack stack : blocks) {
if (stack != null && stack.getItem() instanceof ItemBlock) {
final ItemBlock item = (ItemBlock) stack.getItem();
final Block supportedBlock = item.getBlock();
final int supportedMetadata = item.getMetadata(stack.getItemDamage());
if (referenceBlock == supportedBlock && (referenceMetadata == supportedMetadata || stack.getItemDamage() == OreDictionary.WILDCARD_VALUE)) {
return true;
}
}
}
return false;
}