コード例 #1
0
ファイル: BlockHopper.java プロジェクト: Miner239/TFCraft
  @Override
  public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
    if (world.getTileEntity(x, y, z) instanceof TEHopper) {
      TEHopper te = (TEHopper) world.getTileEntity(x, y, z);

      for (int i1 = 0; i1 < te.getSizeInventory(); ++i1) {
        ItemStack itemstack = te.getStackInSlot(i1);

        if (itemstack != null) {
          while (itemstack.stackSize > 0) {
            int j1 = this.random.nextInt(21) + 10;

            if (j1 > itemstack.stackSize) {
              j1 = itemstack.stackSize;
            }

            itemstack.stackSize -= j1;
            EntityItem entityitem =
                new EntityItem(
                    world,
                    x + 0.5f,
                    y + 0.5f,
                    z + 0.5f,
                    new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));

            if (itemstack.hasTagCompound()) {
              entityitem
                  .getEntityItem()
                  .setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
            }

            // float f3 = 0.05F;
            world.spawnEntityInWorld(entityitem);
          }
        }
      }
      if (te.pressBlock != null) {
        EntityItem entityitem = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, te.pressBlock);
        world.spawnEntityInWorld(entityitem);
      }
      world.func_147453_f(x, y, z, block);
    }

    super.breakBlock(world, x, y, z, block, meta);
  }