/** Will get destroyed next tick */
  public void setEntityDead() {
    label0:
    for (int i = 0; i < getSizeInventory(); i++) {
      ItemStack itemstack = getStackInSlot(i);

      if (itemstack == null) {
        continue;
      }

      float f = rand.nextFloat() * 0.8F + 0.1F;
      float f1 = rand.nextFloat() * 0.8F + 0.1F;
      float f2 = rand.nextFloat() * 0.8F + 0.1F;

      do {
        if (itemstack.stackSize <= 0) {
          continue label0;
        }

        int j = rand.nextInt(21) + 10;

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

        itemstack.stackSize -= j;
        EntityItem entityitem =
            new EntityItem(
                worldObj,
                posX + (double) f,
                posY + (double) f1,
                posZ + (double) f2,
                new ItemStack(itemstack.itemID, j, itemstack.getItemDamage()));
        float f3 = 0.05F;
        entityitem.motionX = (float) rand.nextGaussian() * f3;
        entityitem.motionY = (float) rand.nextGaussian() * f3 + 0.2F;
        entityitem.motionZ = (float) rand.nextGaussian() * f3;
        worldObj.spawnEntityInWorld(entityitem);
      } while (true);
    }

    super.setEntityDead();
  }
示例#2
0
 /** sets the dead flag. Used when you fall off the bottom of the world. */
 protected void kill() {
   setEntityDead();
 }
示例#3
0
 public void remove() {
   handle.setEntityDead();
 }