From 3455ffb43ae1e0f8692ae53500574b2c8ff0ca2d Mon Sep 17 00:00:00 2001 From: brandon3055 Date: Sun, 17 Mar 2024 17:32:47 +1100 Subject: [PATCH] Added workaround for architectury fluid bug. https://github.com/architectury/architectury-api/issues/484 --- .../creeperhost/polylib/inventory/fluid/FluidManager.java | 8 ++++++++ .../net/creeperhost/polylib/inventory/fluid/PolyTank.java | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/net/creeperhost/polylib/inventory/fluid/FluidManager.java b/common/src/main/java/net/creeperhost/polylib/inventory/fluid/FluidManager.java index e8ff7571..028c95eb 100644 --- a/common/src/main/java/net/creeperhost/polylib/inventory/fluid/FluidManager.java +++ b/common/src/main/java/net/creeperhost/polylib/inventory/fluid/FluidManager.java @@ -67,6 +67,14 @@ default long convert(long milliBuckets) { //###### Fluid Utilities ###### + //TODO, work around for bug in architectury + static FluidStack copyWithAmount(FluidStack stack, long amount) { + if (stack.isEmpty()) return FluidStack.empty(); + stack = stack.copy(); + stack.setAmount(amount); + return stack; + } + //=== Get Handler === static PolyFluidHandler getHandler(BlockEntity tile, @Nullable Direction side) { diff --git a/common/src/main/java/net/creeperhost/polylib/inventory/fluid/PolyTank.java b/common/src/main/java/net/creeperhost/polylib/inventory/fluid/PolyTank.java index db003777..30c64b5b 100644 --- a/common/src/main/java/net/creeperhost/polylib/inventory/fluid/PolyTank.java +++ b/common/src/main/java/net/creeperhost/polylib/inventory/fluid/PolyTank.java @@ -103,7 +103,7 @@ public long fill(FluidStack resource, boolean simulate) { return Math.min(capacity - fluid.getAmount(), resource.getAmount()); } if (fluid.isEmpty()) { - fluid = FluidStack.create(resource, Math.min(capacity, resource.getAmount())); + fluid = FluidManager.copyWithAmount(resource, Math.min(capacity, resource.getAmount())); markDirty(); return fluid.getAmount(); } @@ -129,7 +129,7 @@ public long fill(FluidStack resource, boolean simulate) { if (fluid.getAmount() < drained) { drained = fluid.getAmount(); } - FluidStack stack = FluidStack.create(fluid, drained); + FluidStack stack = FluidManager.copyWithAmount(fluid, drained); if (!simulate && drained > 0) { fluid.shrink(drained); markDirty();