mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 16:27:47 +00:00
New round of fluid system fixes: (#6175)
- Fix race condition lazy-initializing flowing fluid block data. - Fix typo in ItemTextureQuadConverter that prevents certain animated textures from being used in the fluid bucket. - Fix calls to onContentsChanged in FluidTank. - Fix FluidUtil.tryEmptyContainer logic when simulating. - Fix EmptyFluidHandler.fill returning the wrong number.
This commit is contained in:
1 parent
ca980a56bc
commit
b294f4d894
5 files changed
+34
-36
No files matched your search
@@ -150,7 +150,7 @@ public final class ItemTextureQuadConverter
|
||||
for (int y = 0; y < h; y++)
|
||||
{
|
||||
// current pixel
|
||||
boolean isVisible = !sprite.isPixelTransparent(0, x, y);
|
||||
boolean isVisible = !template.isPixelTransparent(0, x, y);
|
||||
|
||||
// no current quad but found a new one
|
||||
if (start < 0 && isVisible)
|
||||
@@ -168,7 +168,7 @@ public final class ItemTextureQuadConverter
|
||||
{
|
||||
for (int i = 0; i < h; i++)
|
||||
{
|
||||
if (sprite.isPixelTransparent(0, x, i) != sprite.isPixelTransparent(0, endX, i))
|
||||
if (template.isPixelTransparent(0, x, i) != template.isPixelTransparent(0, endX, i))
|
||||
{
|
||||
sameColumn = false;
|
||||
break;
|
||||
|
||||
@@ -178,31 +178,20 @@ public class FluidUtil
|
||||
ItemStack containerCopy = ItemHandlerHelper.copyStackWithSize(container, 1); // do not modify the input
|
||||
return getFluidHandler(containerCopy)
|
||||
.map(containerFluidHandler -> {
|
||||
if (doDrain)
|
||||
|
||||
// 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);
|
||||
if (transfer.isEmpty())
|
||||
return FluidActionResult.FAILURE;
|
||||
|
||||
if (doDrain && player != null)
|
||||
{
|
||||
FluidStack transfer = tryFluidTransfer(fluidDestination, containerFluidHandler, maxAmount, true);
|
||||
if (!transfer.isEmpty())
|
||||
{
|
||||
if (player != null)
|
||||
{
|
||||
SoundEvent soundevent = transfer.getFluid().getAttributes().getEmptySound(transfer);
|
||||
player.world.playSound(null, player.posX, player.posY + 0.5, player.posZ, soundevent, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
}
|
||||
ItemStack resultContainer = containerFluidHandler.getContainer();
|
||||
return new FluidActionResult(resultContainer);
|
||||
}
|
||||
SoundEvent soundevent = transfer.getFluid().getAttributes().getEmptySound(transfer);
|
||||
player.world.playSound(null, player.posX, player.posY + 0.5, player.posZ, soundevent, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
}
|
||||
else
|
||||
{
|
||||
FluidStack simulatedTransfer = tryFluidTransfer(fluidDestination, containerFluidHandler, maxAmount, false);
|
||||
if (!simulatedTransfer.isEmpty())
|
||||
{
|
||||
containerFluidHandler.drain(simulatedTransfer, IFluidHandler.FluidAction.SIMULATE);
|
||||
ItemStack resultContainer = containerFluidHandler.getContainer();
|
||||
return new FluidActionResult(resultContainer);
|
||||
}
|
||||
}
|
||||
return FluidActionResult.FAILURE;
|
||||
|
||||
ItemStack resultContainer = containerFluidHandler.getContainer();
|
||||
return new FluidActionResult(resultContainer);
|
||||
})
|
||||
.orElse(FluidActionResult.FAILURE);
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class EmptyFluidHandler implements IFluidHandler
|
||||
@Override
|
||||
public int fill(FluidStack resource, FluidAction action)
|
||||
{
|
||||
return resource.getAmount();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
||||
@@ -147,8 +147,8 @@ public class FluidTank implements IFluidHandler, IFluidTank {
|
||||
}
|
||||
if (fluid.isEmpty())
|
||||
{
|
||||
onContentsChanged();
|
||||
fluid = new FluidStack(resource, Math.min(capacity, resource.getAmount()));
|
||||
onContentsChanged();
|
||||
return fluid.getAmount();
|
||||
}
|
||||
if (!fluid.isFluidEqual(resource))
|
||||
@@ -166,6 +166,8 @@ public class FluidTank implements IFluidHandler, IFluidTank {
|
||||
{
|
||||
fluid.setAmount(capacity);
|
||||
}
|
||||
if (filled > 0)
|
||||
onContentsChanged();
|
||||
return filled;
|
||||
}
|
||||
|
||||
@@ -194,6 +196,8 @@ public class FluidTank implements IFluidHandler, IFluidTank {
|
||||
{
|
||||
fluid.shrink(drained);
|
||||
}
|
||||
if (drained > 0)
|
||||
onContentsChanged();
|
||||
return stack;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user