squeek502 / VeganOption

A Minecraft mod that seeks to add vegan alternatives to all Minecraft mob/animal products
The Unlicense
45 stars 10 forks source link

Raw Ender not working with pumps #33

Closed ghost closed 7 months ago

ghost commented 8 years ago

Raw ender does not seem to be pumpable. This has been observed with the RotaryCraft pump, as well as the ender-thermic pump from Extra Utilities (although it does replace raw ender with stone).

I was able to use the Expanded Redstone pump successfully, but this seems to be due to an exploit discovered with that pump: it will actually collect fluid flow blocks in addition to source blocks.

Because of these issues, and observations about the behavior of raw ender, I'm assuming that you don't have raw ender source blocks? Is it possible to make it configurable to whether or not raw ender has a source block instead of the current flow mechanics?

squeek502 commented 8 years ago

Interesting. Raw Ender currently uses the standard Forge BlockFluidFinite, so it would be good if those mods added proper support for that. Here's how I do it.

I could make which fluid type it uses configurable, though.

ReikaKalseki commented 8 years ago

I use the fluid registry lookup. FluidRegistry.lookupFluidForBlock or something like that. If that returns null. my machines ignore it. However, it also has to extend BlockFluidBase or BlockLiquid (the parent of the vanilla blocks) and be of metadata zero. Which fails for yours?

squeek502 commented 8 years ago

@ReikaKalseki, the only methods I overwrite of BlockFluidFinite are texture-related, so I use the default Forge implementation for everything else.

BlockFluidFinite uses metadata to determine how 'full' that particular blockspace is. Metadata 7 is 'full' (1 buckets worth), and metadata 0 is 1/8 'full' (125mb worth). There are no source blocks--each block is representative of a certain amount of fluid.

So, when consuming a BlockFluidFinite, you need to take that into account, and only consume the amount of fluid that exists in the block based on its metadata.

You might want to use the IFluidBlock.drain method: https://github.com/MinecraftForge/MinecraftForge/blob/1710ls/src/main/java/net/minecraftforge/fluids/BlockFluidFinite.java#L312-L321

ReikaKalseki commented 8 years ago

My systems deal in blocks - and only some can even handle non-bucket amounts.

squeek502 commented 8 years ago

@ReikaKalseki, okay, then your pump and BlockFluidFinite will just not be compatible, but it still might be a good idea to use the Forge interface. Something like:

if (block instanceof IFluidBlock && ((IFluidBlock) block).canDrain(world, x, y, z))
{
    IFluidBlock fluidBlock = (IFluidBlock) block;
    // dry run
    FluidStack drainedFluidStack = fluidBlock.drain(world, x, y, z, false);
    if (drainedFluidStack != null && drainedFluidStack.amount == FluidContainerRegistry.BUCKET_VOLUME)
    {
        // do the actual draining
        return fluidBlock.drain(world, x, y, z, true);
    }
    return null;
}
// pseudo-code
else if (block is lava/water)
{
    // standard drain logic for vanilla fluids
}

Not perfect, and will still fail to handle most BlockFluidFinite blocks (given that 'full' finite fluid blocks are rather rare), but that might be the most Forge-compatible way to do it.

ReikaKalseki commented 8 years ago

That code is not compatible with vanilla fluids.

squeek502 commented 8 years ago

@ReikaKalseki, you may have seen it before I edited in the else if block. Vanilla fluids will need special handling.

I feel like you think I'm doing something wacky with my mod and you want me to prove to you that 'my way' is worth supporting, but I'm not doing anything wacky at all.

It's totally up to you if you want to support BlockFluidFinite, but just be aware that it is not specific to my mod; it is native to Forge, so you need to decide whether or not you want to support a Forge thing. It's not my job to provide you a perfect implementation.

ReikaKalseki commented 8 years ago

Many modded blocks also use the BlockLiquid class, so it would need to be more than just lava in water.

Also, given that both vanilla and 95% of mod fluids use the source block system, it is in fact the Finite system that would need special handling.

squeek502 commented 8 years ago

@ReikaKalseki, I feel like you're deliberately misinterpreting me at this point. I don't have anything more to say, as nothing you're talking about has anything to do with code that I have written.

Look at the Forge source code and create an issue on their repository if you don't like it:

ReikaKalseki commented 8 years ago

@ReikaKalseki, I feel like you're deliberately misinterpreting me at this point. I don't have anything more to say, as nothing you're talking about has anything to do with code that I have written.

....?

squeek502 commented 8 years ago

....?

Perhaps I'm misinterpreting you? What's your goal here? Are you trying to collaborate with me to find a solution? If so, it doesn't feel that way to me.

ReikaKalseki commented 8 years ago

As I said, I will need to insert special handling...in several places.

I will say that I do not really approve of the existence of two separate and fundamentally incompatible systems.

squeek502 commented 8 years ago

Right, and as I said, I had nothing to do with either of those systems. I don't like it either, but that's what exists.

ReikaKalseki commented 8 years ago

There, I added support for it on my four pumps, though one of them can only handle full buckets.

squeek502 commented 8 years ago

Nice!

Leaving this open because I think the config option is still a good idea.

ReikaKalseki commented 8 years ago

Config option?

squeek502 commented 8 years ago

@ReikaKalseki, your work is done; you can safely ignore this issue now. Appreciate the quick fix.

I was talking about the config option suggested in the OP to make Raw Ender optionally use BlockFluidClassic instead of BlockFluidFinite:

Is it possible to make it configurable to whether or not raw ender has a source block instead of the current flow mechanics?

elifoster commented 7 months ago

No longer applicable. Raw Ender has been completely rewritten as fluids have changed drastically.