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


Java Block.getDrops方法代码示例

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


在下文中一共展示了Block.getDrops方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: harvestAndPickup

import net.minecraft.block.Block; //导入方法依赖的package包/类
@Override
public boolean harvestAndPickup(BlockPos pos) {
    World world = entity.getEntityWorld();
    if (world.isAirBlock(pos)) {
        return true;
    }
    IBlockState state = world.getBlockState(pos);
    if (!allowedToHarvest(state, world, pos, GeneralTools.getHarvester())) {
        return false;
    }
    Block block = state.getBlock();
    List<ItemStack> drops = block.getDrops(world, pos, state, 0);
    net.minecraftforge.event.ForgeEventFactory.fireBlockHarvesting(drops, world, pos, state, 0, 1.0f, false, GeneralTools.getHarvester());
    SoundTools.playSound(world, block.getSoundType().getBreakSound(), pos.getX(), pos.getY(), pos.getZ(), 1.0f, 1.0f);
    block.onBlockHarvested(world, pos, state, GeneralTools.getHarvester());
    entity.getEntityWorld().setBlockToAir(pos);
    giveDropsToMeeCreeps(drops);
    return true;
}
 
开发者ID:McJty,项目名称:MeeCreeps,代码行数:20,代码来源:WorkerHelper.java

示例4: harvestAndDrop

import net.minecraft.block.Block; //导入方法依赖的package包/类
@Override
public boolean harvestAndDrop(BlockPos pos) {
    World world = entity.getEntityWorld();
    if (world.isAirBlock(pos)) {
        return true;
    }
    IBlockState state = world.getBlockState(pos);
    if (!allowedToHarvest(state, world, pos, GeneralTools.getHarvester())) {
        return false;
    }

    Block block = state.getBlock();

    List<ItemStack> drops = block.getDrops(world, pos, state, 0);
    net.minecraftforge.event.ForgeEventFactory.fireBlockHarvesting(drops, world, pos, state, 0, 1.0f, false, GeneralTools.getHarvester());
    SoundTools.playSound(world, block.getSoundType().getBreakSound(), pos.getX(), pos.getY(), pos.getZ(), 1.0f, 1.0f);
    block.onBlockHarvested(world, pos, state, GeneralTools.getHarvester());
    entity.getEntityWorld().setBlockToAir(pos);
    for (ItemStack stack : drops) {
        entity.entityDropItem(stack, 0.0f);
    }
    return true;
}
 
开发者ID:McJty,项目名称:MeeCreeps,代码行数:24,代码来源:WorkerHelper.java

示例5: test_getDrops

import net.minecraft.block.Block; //导入方法依赖的package包/类
@Test
public void test_getDrops()
{
    ContentBlockSnow content = new ContentBlockSnow();
    content.id = "test_getDrops";
    content.snowball = new WrappedItemStackConstant(new ItemStack(Items.APPLE, 3));
    content.drop = Attribute.constant(new BlockDrop[] {new BlockDrop(new WrappedItemStackConstant(new ItemStack(Items.STICK)), IntRange.create(2, 2))});

    Block block = content.createBlock();

    NonNullList<ItemStack> drops = NonNullList.create();
    block.getDrops(drops, null, null, block.getDefaultState().withProperty(BlockSnow.LAYERS, 5), 0);
    ItemStack drop1 = drops.get(0);
    ItemStack drop2 = drops.get(1);

    assertEquals(2, drops.size());

    assertSame(Items.APPLE, drop1.getItem());
    assertEquals(18, drop1.getCount());

    assertSame(Items.STICK, drop2.getItem());
    assertEquals(2, drop2.getCount());
}
 
开发者ID:cubex2,项目名称:customstuff4,代码行数:24,代码来源:BlockSnowTest.java

示例6: harvest

import net.minecraft.block.Block; //导入方法依赖的package包/类
protected void harvest(BlockPos pos) {
    IMeeCreep entity = helper.getMeeCreep();
    World world = entity.getWorld();
    IBlockState state = world.getBlockState(pos);
    Block block = state.getBlock();
    List<ItemStack> drops = block.getDrops(world, pos, state, 0);
    net.minecraftforge.event.ForgeEventFactory.fireBlockHarvesting(drops, world, pos, state, 0, 1.0f, false, GeneralTools.getHarvester());
    SoundTools.playSound(world, block.getSoundType().getBreakSound(), pos.getX(), pos.getY(), pos.getZ(), 1.0f, 1.0f);
    entity.getWorld().setBlockToAir(pos);
    helper.giveDropsToMeeCreeps(drops);
}
 
开发者ID:McJty,项目名称:MeeCreeps,代码行数:12,代码来源:HarvestActionWorker.java

示例7: harvest

import net.minecraft.block.Block; //导入方法依赖的package包/类
protected void harvest(BlockPos pos) {
    IMeeCreep entity = helper.getMeeCreep();
    World world = entity.getWorld();
    IBlockState state = world.getBlockState(pos);
    Block block = state.getBlock();
    List<ItemStack> drops = block.getDrops(world, pos, state, 0);
    net.minecraftforge.event.ForgeEventFactory.fireBlockHarvesting(drops, world, pos, state, 0, 1.0f, false, GeneralTools.getHarvester());
    SoundTools.playSound(world, block.getSoundType().getBreakSound(), pos.getX(), pos.getY(), pos.getZ(), 1.0f, 1.0f);
    world.setBlockToAir(pos);
    helper.giveDropsToMeeCreeps(drops);
}
 
开发者ID:McJty,项目名称:MeeCreeps,代码行数:12,代码来源:MineOresActionWorker.java

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