Use
```Inventory inv = ((InventoryHolder) target).getInventory();//get target inventory```

This will make it not class cast exception. Also allow for targetting entities that hold inventories.