Example #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);
      }
    }
  }
Example #2
0
 @Override
 public void setInventorySlotContents(int index, ItemStack stack) {
   inventory.setStackInSlot(stack, index);
 }
Example #3
0
 @Override
 public ItemStack getStackInSlot(int index) {
   return inventory.getStackInSlot(index);
 }
Example #4
0
 @Override
 public int getSizeInventory() {
   return inventory.getSizeInventory();
 }
Example #5
0
 @Override
 public void clear() {
   for (int i = 0; i < inventory.getSizeInventory(); i++) {
     inventory.setStackInSlot(null, i);
   }
 }