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


Java Block.getItemDropped方法代码示例

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


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

示例1: doMining

import net.minecraft.block.Block; //导入方法依赖的package包/类
void doMining(World world, EntityPlayerMP player, int x, int y, int z)	// Calling this 27 times, to blast mine a 3x3x3 area
{
	Block toBeBroken = world.getBlock(x, y, z);
	int meta = world.getBlockMetadata(x, y, z);

	if (toBeBroken.getBlockHardness(world, x, y, z) == -1) { return; }	// Unbreakable

	if (toBeBroken.getHarvestLevel(meta) > 1) { return; }
	if (toBeBroken.getMaterial() == Material.water) { return; }
	if (toBeBroken.getMaterial() == Material.lava) { return; }
	if (toBeBroken.getMaterial() == Material.air) { return; }
	if (toBeBroken.getMaterial() == Material.portal) { return; }

	// Need to do checks here against invalid blocks
	if (toBeBroken == Blocks.water) { return; }
	if (toBeBroken == Blocks.flowing_water) { return; }
	if (toBeBroken == Blocks.lava) { return; }
	if (toBeBroken == Blocks.flowing_lava) { return; }
	if (toBeBroken == Blocks.obsidian) { return; }
	if (toBeBroken == Blocks.mob_spawner) { return; }

	// Crashing blocks: Redstone Lamp, Extended Piston
	// They're likely trying to drop things that cannot be dropped (active states of themselves)

	//WorldSettings.GameType gametype = WorldSettings.GameType.getByName("survival");
	WorldSettings.GameType gametype = world.getWorldInfo().getGameType();
	BlockEvent.BreakEvent event = ForgeHooks.onBlockBreakEvent(world, gametype, player, x, y, z);

	if (event.isCanceled()) { return; }	// Not allowed to do this

	//toBeBroken.dropBlockAsItem(world, x, x, z, meta, 0);	// The last one is Fortune

	boolean removalSuccess = world.setBlockToAir(x, y, z);
	if (removalSuccess) { toBeBroken.onBlockDestroyedByPlayer(world, x, y, z, meta); }

	Item preBlockItem = toBeBroken.getItemDropped(meta, player.getRNG(), 0);

	if (preBlockItem == null) { return; }	// Item doesn't exist

	ItemStack blockItem = new ItemStack(preBlockItem);

	blockItem.setItemDamage(meta);

	EntityItem entityItem = new EntityItem(world, x, y + 0.5d, z, blockItem);
	entityItem.delayBeforeCanPickup = 10;

	world.spawnEntityInWorld(entityItem);
}
 
开发者ID:Domochevsky,项目名称:minecraft-quiverbow,代码行数:49,代码来源:PowderKnuckle_Mod.java


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