Fix FluidContainerRegistry interactions w/ Certus Quart Tank (#122)

The Certus Quartz Tank previously did not consider the
FluidContainerRegistry API for fluid containers, so fluid containers
that implemented that (like ic2 cells) were voided when filling the
tank.

Signed-off-by: Firenoo <49818773+firenoo@users.noreply.github.com>
This commit is contained in:
firenoo authored and GitHub committed 2023-05-01 19:37:53 +02:00
1 parent 77ec41812d
commit c29f8cf846
1 file changed
+10 -3
@@ -131,12 +131,19 @@ public class BlockCertusQuartzTank extends BaseBlockContainer implements IRegist
if (liquid != null) {
int amountFilled = tank.fill(ForgeDirection.UNKNOWN, liquid, true);
if (amountFilled != 0 && !entityplayer.capabilities.isCreativeMode && current.getItem() != null) {
ItemStack empty;
if (FluidContainerRegistry.isContainer(current)) {
empty = FluidContainerRegistry.drainFluidContainer(current);
} else {
// Try this as a fallback.
entityplayer.inventory.addItemStackToInventory(current.getItem().getContainerItem(current));
empty = current.getItem().getContainerItem(current);
}
if (current.stackSize > 1) {
entityplayer.inventory.mainInventory[entityplayer.inventory.currentItem].stackSize -= 1;
entityplayer.inventory.addItemStackToInventory(current.getItem().getContainerItem(current));
entityplayer.inventory.addItemStackToInventory(empty);
} else {
entityplayer.inventory.mainInventory[entityplayer.inventory.currentItem] = current.getItem()
.getContainerItem(current);
entityplayer.inventory.mainInventory[entityplayer.inventory.currentItem] = empty;
}
}
return true;