Skip to content

Commit

Permalink
Add overrides for setFluid and getFluid calls to PotionItem (#2770)
Browse files Browse the repository at this point in the history
  • Loading branch information
loving2 authored Feb 12, 2025
1 parent 4e2ffa6 commit 2d3a389
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,18 @@ public <T> LazyOptional<T> getCapability(@NotNull Capability<T> cap, @Nullable D
} else if (itemStack.getItem() instanceof PotionItem) {
LazyOptional<IFluidHandlerItem> handler = LazyOptional.of(() -> {
var fluidHandler = new FluidHandlerItemStack.SwapEmpty(itemStack, new ItemStack(Items.GLASS_BOTTLE),
PotionFluidHelper.BOTTLE_AMOUNT);
PotionFluidHelper.BOTTLE_AMOUNT) {

@Override
protected void setFluid(FluidStack fluid) {
// do nada
}

@Override
public @NotNull FluidStack getFluid() {
return PotionFluidHelper.getFluidFromPotionItem(itemStack, PotionFluidHelper.BOTTLE_AMOUNT);
}
};
fluidHandler.fill(PotionFluidHelper.getFluidFromPotionItem(itemStack, PotionFluidHelper.BOTTLE_AMOUNT),
IFluidHandler.FluidAction.EXECUTE);
return fluidHandler;
Expand Down

0 comments on commit 2d3a389

Please sign in to comment.