MysticMods / Roots

Home of the Roots Minecraft Mod
GNU Lesser General Public License v3.0
44 stars 33 forks source link

Redstone updates forcing crops on elemental soil to grow very fast #815

Open stef-c1 opened 7 months ago

stef-c1 commented 7 months ago

Hello, not sure if you consider this a bug, but I do.

Describe the bug: Crops on elemental soil (all kinds, but tested with aqueous) are forced to grow by redstone updates. With a redstone update I mean the changing of a redstone signal.

To Reproduce: First construct a standard farm with elemental soil with crops planted on the soil. Then put redstone next to the crops. Construct a redstone clock (any variant will do) to rapidly change the redstone signal. Hook the clock up to the redstone next to the crops, you will see the crops grow much faster than they should (best is to put some other crops a bit away from the redstone to compare with). This behaviour does not happen when using normal minecraft soil (tilled with hoe), which is why I am reporting it here, it seems to occur due to the elemental soil.

Environment Versions

I am using Roots-1.12.2-3.1.9.1.jar

Mystic Mods Versions

Other Versions:

2024-02-04_17 11 18

Please let me know if you need any further clarification. Would love to be of help.

noobanidus commented 7 months ago

So, this definitely seems like a bug. I'm guessing it's the additional growth ticks that get added to crops; the updateTick method is probably being forcibly called via the redstone change, so I'm guessing that's the issue there.

    @Override
    public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
        super.updateTick(world, pos, state, rand);

        if (world.isAirBlock(pos.up())) {
            return;
        }

        IBlockState upState = world.getBlockState(pos.up());
        Block upBlock = upState.getBlock();
        doHarvest(world, pos.up(), world.getBlockState(pos), upState);

        if (!(upBlock instanceof IGrowable))
            return;

        // TODO: Who knows if this value is any good
        if (rand.nextInt(5) == 0) {
            upBlock.randomTick(world, pos.up(), upState, rand);
        }
    }

Probably that entire section for randomly ticking the upBlock needs to be removed or adjusted in some way, or it should be moved to a separate method that isn't going to be accelerated by redstone ticks. Don't currently have a functional build environment for 1.12.2, but I'm working on it at the minute hopefully.

stef-c1 commented 7 months ago

Thank you for the fast response! I am glad you agree it is a bug and are working on a fix, thank you very much for your time :)

ByThePowerOfScience commented 7 months ago

@noobanidus This bug was around long before I ever got here, so I assumed it was intended. Guess not.

Elemental soil was already in desperate need of a rework, as it has a ton of things happening every single tick. I took a stab at optimizing it a long time ago, but there was just too much spaghetti there. I guess another look is about due if both of us work on it.