Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
fixed inventory drop of mass storages
Browse files Browse the repository at this point in the history
  • Loading branch information
Trinsdar committed Apr 12, 2024
1 parent f56ab15 commit 47e7462
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,23 @@ public void onDrop(BlockState state, LootContext.Builder builder, List<ItemStack
@Override
public void dropInventory(BlockState state, LootContext.Builder builder, List<ItemStack> drops) {
if (getMachineState() != MachineState.ACTIVE) {
super.dropInventory(state, builder, drops);
itemHandler.ifPresent(t -> {
ItemStack held = t.getHandler(SlotTypes.UNLIMITED).getItem(0);
int amountToExtract = held.getCount();
if (amountToExtract > 0){
if (amountToExtract > held.getMaxStackSize()){
int toExtract = amountToExtract;
while (toExtract > 0){
ItemStack toAdd = Utils.ca(Math.min(held.getMaxStackSize(), toExtract), held);
toExtract -= toAdd.getCount();
drops.add(toAdd);
}
} else {
ItemStack toAdd = Utils.ca(amountToExtract, held);
drops.add(toAdd);
}
}
});
}
}

Expand Down

0 comments on commit 47e7462

Please sign in to comment.