wlmy
我想让一个物品A右键消耗方块B打出方块B的实体(实体我自己创建),之前我已经会了如何打出物品(Item),现在我想弄方块(Block),该怎么办?打出物品的代码是:


打出方块应该怎么弄:



图片:



wlmy
由于论坛没有加载完成
那个方块的错误代码:
  1.     public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityplayer)
  2.     {
  3.             boolean flag = entityplayer.capabilities.isCreativeMode;
  4.             if (flag || entityplayer.inventory.hasItem(Blocks.cobblestone))
  5.             {
  6.                      itemStack.damageItem(1, entityplayer);
  7.                     entityplayer.inventory.consumeInventoryItem(Blocks.cobblestone);
  8.                     world.playSoundAtEntity(entityplayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
  9.         if (!world.isRemote)
  10.         {
  11.                 world.spawnEntityInWorld(new EntityCobblestone(world, entityplayer));
  12.             }
  13.             }
  14.                 return itemStack;
  15.     }
复制代码




时透无一年
hasItemStack(new ItemStack(Blocks.cobblestone))