当前位置: 首页>>代码示例>>Java>>正文


Java Block.canSilkHarvest方法代码示例

本文整理汇总了Java中net.minecraft.block.Block.canSilkHarvest方法的典型用法代码示例。如果您正苦于以下问题:Java Block.canSilkHarvest方法的具体用法?Java Block.canSilkHarvest怎么用?Java Block.canSilkHarvest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.block.Block的用法示例。


在下文中一共展示了Block.canSilkHarvest方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isValidPosition

import net.minecraft.block.Block; //导入方法依赖的package包/类
@Override
protected boolean isValidPosition(BlockPos pos) {
    IBlockState blockState = worldCache.getBlockState(pos);
    Block block = blockState.getBlock();
    if (!worldCache.isAirBlock(pos) && !ignoreBlock(block)) {
        NonNullList<ItemStack> droppedStacks = NonNullList.create();
        if (block.canSilkHarvest(drone.world(), pos, blockState, drone.getFakePlayer())) {
            droppedStacks.add(getSilkTouchBlock(block, blockState));
        } else {
            block.getDrops(droppedStacks, drone.world(), pos, blockState, 0);
        }
        for (ItemStack droppedStack : droppedStacks) {
            if (widget.isItemValidForFilters(droppedStack, blockState)) {
                swapBestItemToFirstSlot(pos);
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:21,代码来源:DroneAIDig.java

示例2: isBlockValidForFilter

import net.minecraft.block.Block; //导入方法依赖的package包/类
public static boolean isBlockValidForFilter(IBlockAccess worldCache, IDroneBase drone, BlockPos pos, ProgWidgetAreaItemBase widget) {
    IBlockState blockState = worldCache.getBlockState(pos);
    Block block = blockState.getBlock();

    if (!block.isAir(blockState, worldCache, pos)) {
        NonNullList<ItemStack> droppedStacks = NonNullList.create();
        if (block.canSilkHarvest(drone.world(), pos, blockState, drone.getFakePlayer())) {
            droppedStacks.add(getSilkTouchBlock(block, blockState));
        } else {
            block.getDrops(droppedStacks, drone.world(), pos, blockState, 0);
        }
        for (ItemStack droppedStack : droppedStacks) {
            if (widget.isItemValidForFilters(droppedStack, blockState)) {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:20,代码来源:DroneAIDig.java

示例3: breakBlock

import net.minecraft.block.Block; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public void breakBlock(EnumFacing facing) {
	BlockPos newPos = pos.offset(facing, 1);
	IBlockState state = this.world.getBlockState(newPos);
	Block block = state.getBlock();
	if (!block.isAir(state, this.world, newPos) && block.getBlockHardness(state, this.world, newPos) >= 0
			&& !(block instanceof BlockDynamicLiquid) && !(block instanceof BlockStaticLiquid)) {
		// Creates a fake player which will berak the block
		EntityPlayer player = new EntityPlayer(world, new GameProfile(null, "BlockBreaker")) {

			@Override
			public boolean isSpectator() {
				return true;
			}

			@Override
			public boolean isCreative() {
				return false;
			}
		};
		List<ItemStack> drops = new ArrayList<ItemStack>();
		boolean customDrops = false;
		if (this.handler.getStackInSlot(9).getItem() == Items.ENCHANTED_BOOK) {
			ItemStack enchantedBook = this.handler.getStackInSlot(9);
			Map<Enchantment, Integer> enchantments = EnchantmentHelper.getEnchantments(enchantedBook);
			if (enchantments.containsKey(Enchantments.FORTUNE)) {
				int fortune = enchantments.get(Enchantments.FORTUNE);
				drops.add(new ItemStack(block.getItemDropped(state, this.random, fortune),
						block.quantityDroppedWithBonus(fortune, this.random), block.damageDropped(state)));
				customDrops = true;
			}
			if (enchantments.containsKey(Enchantments.SILK_TOUCH)
					&& block.canSilkHarvest(world, newPos, state, player)) {
				// HARD FIX FOR LAPIS
				if (block == Blocks.LAPIS_ORE)
					drops.add(new ItemStack(block, 1));
				else
					drops.add(new ItemStack(block, 1, block.damageDropped(state)));
				customDrops = true;
			}
		}
		if (!customDrops)
			drops = block.getDrops(world, newPos, state, 0);
		for (ItemStack stack : drops) {
			Utils.addStackToInventory(this.handler, 9, stack, false);
		}
		if (!Utils.isInventoryFull(this.handler, 9)) {
			this.world.playEvent(2001, pos, Block.getStateId(state));
			this.world.playSound(null, pos, block.getSoundType(state, world, newPos, player).getBreakSound(),
					SoundCategory.BLOCKS, 1, 1);
			this.world.setBlockToAir(newPos);
			if (block == Blocks.ICE)
				this.world.setBlockState(newPos, Blocks.FLOWING_WATER.getDefaultState());
		}
	}
}
 
开发者ID:IvanSteklow,项目名称:VanillaExtras,代码行数:57,代码来源:TileEntityBlockBreaker.java


注:本文中的net.minecraft.block.Block.canSilkHarvest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。