mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-13 00:37:52 +00:00
Fix tryEmptyContainerAndStow duping fluids with stackable containers (#9004)
This commit is contained in:
1 parent
22d2740725
commit
bf1194ec75
4 files changed
+127
-3
No files matched your search
@@ -2,6 +2,7 @@
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.client.event;
|
||||
|
||||
import net.minecraft.world.item.Item;
|
||||
|
||||
@@ -173,11 +173,15 @@ public class FluidUtil
|
||||
ItemStack containerCopy = ItemHandlerHelper.copyStackWithSize(container, 1); // do not modify the input
|
||||
return getFluidHandler(containerCopy)
|
||||
.map(containerFluidHandler -> {
|
||||
|
||||
// We are acting on a COPY of the stack, so performing changes is acceptable even if we are simulating.
|
||||
FluidStack transfer = tryFluidTransfer(fluidDestination, containerFluidHandler, maxAmount, true);
|
||||
FluidStack transfer = tryFluidTransfer(fluidDestination, containerFluidHandler, maxAmount, doDrain);
|
||||
if (transfer.isEmpty())
|
||||
return FluidActionResult.FAILURE;
|
||||
if (!doDrain)
|
||||
{
|
||||
// We are acting on a COPY of the stack, so performing changes on the source is acceptable even if we are simulating.
|
||||
// We need to perform the change otherwise the call to getContainer() will be incorrect.
|
||||
containerFluidHandler.drain(transfer, IFluidHandler.FluidAction.EXECUTE);
|
||||
}
|
||||
|
||||
if (doDrain && player != null)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user