Esempio n. 1
0
  public void expelItems() {

    if (inventory == null || inventory.getSizeInventory() == 0) return;
    for (ItemStack stack : inventory.getValues()) {
      if (stack != null) {
        Random random = new Random();
        EntityItem entityitem =
            new EntityItem(
                worldObj,
                pos.getX() + random.nextFloat() * 0.8F + 0.1F,
                pos.getY() + random.nextFloat() * 0.8F + 0.1F,
                pos.getZ() + random.nextFloat() * 0.8F + 0.1F,
                stack);
        if (stack.hasTagCompound()) {
          entityitem.getEntityItem().setTagCompound((NBTTagCompound) stack.getTagCompound().copy());
        }
        float f3 = 0.05F;
        entityitem.motionX = (double) ((float) random.nextGaussian() * f3);
        entityitem.motionY = (double) ((float) random.nextGaussian() * f3 + 0.2F);
        entityitem.motionZ = (double) ((float) random.nextGaussian() * f3);
        worldObj.spawnEntityInWorld(entityitem);
      }
    }
  }