Fix placing fluids into waterlogged blocks with FluidUtil::tryPlaceFluid. To behave more like vanilla MC-127110 (#9586)

This commit is contained in:
cech12 authored and GitHub committed 2023-07-05 15:01:04 -07:00
1 parent 7b833faa46
commit 97edac430d
4 files changed
+146 -6

No files matched your search

@@ -15,8 +15,6 @@ import net.minecraftforge.fluids.FluidType;
import net.minecraftforge.fluids.FluidUtil;
import net.minecraftforge.fluids.capability.templates.VoidFluidHandler;
import net.minecraftforge.fluids.capability.IFluidHandler.FluidAction;
/**
* Wrapper around any block, only accounts for fluid placement, otherwise the block acts a void.
* If the block in question inherits from the Forge implementations,
@@ -73,11 +71,11 @@ public class BlockWrapper extends VoidFluidHandler
BlockState state = world.getBlockState(blockPos);
if (liquidContainer.canPlaceLiquid(world, blockPos, state, resource.getFluid()))
{
//If we are executing try to actually fill the container, if it failed return that we failed
if (action.simulate() || liquidContainer.placeLiquid(world, blockPos, state, resource.getFluid().getFluidType().getStateForPlacement(world, blockPos, resource)))
if (action.execute())
{
return FluidType.BUCKET_VOLUME;
liquidContainer.placeLiquid(world, blockPos, state, resource.getFluid().getFluidType().getStateForPlacement(world, blockPos, resource));
}
return FluidType.BUCKET_VOLUME;
}
}
return 0;