Skip to content

Commit

Permalink
Added workaround for architectury fluid bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
brandon3055 committed Mar 17, 2024
1 parent cd235f2 commit 3455ffb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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();
Expand Down

0 comments on commit 3455ffb

Please sign in to comment.