tristankechlo / AdditionalRedstone

Minecraft Mod: Additional Redstone | adds more content to the redstone mechanics
https://www.curseforge.com/minecraft/mc-mods/additional-redstone
Other
4 stars 2 forks source link

[Bug]: Logic Gates Not Updating Properly When Multiple Input Changes Occur Simultaneously #8

Closed dsmng54 closed 1 week ago

dsmng54 commented 8 months ago

What happened?

I have noticed a bug in the Additional Redstone mod that affects all logic gate blocks.The issue is that when there are multiple changes in the input signals of a logic gate (greater than or equal to 2 changes happening simultaneously), the gate fails to update properly.

To illustrate this problem, let's take the XOR gate as an example. When I connect any two input lines using redstone and then attach a lever to them, the output line of the XOR gate should stay low when the lever is toggled on or off. However, in the current state of the mod, the output line produces a high pulse.

1 2

After discovering this problem, I downloaded the source code and added logging statements to ThreeInputLogic.java. static boolean xor(boolean a, boolean b, boolean c) { Constants.LOGGER.info("XOR a, b, c: " + a + ", " + b + ", " + c); return a ^ b ^ c; } when I pulled down the lever, the output log showed the following.

[14:26:10] [Server thread/INFO]: XOR a, b, c: false, false, false [14:26:10] [Server thread/INFO]: XOR a, b, c: false, false, false [14:26:11] [Server thread/INFO]: XOR a, b, c: false, false, true [14:26:11] [Server thread/INFO]: XOR a, b, c: false, false, true [14:26:11] [Server thread/INFO]: XOR a, b, c: false, false, true [14:26:11] [Server thread/INFO]: XOR a, b, c: false, true, true [14:26:11] [Server thread/INFO]: XOR a, b, c: false, true, true

Based on the logs, it can be observed that the states of input terminals b and c are not updated simultaneously.

Minecraft Version

1.20.1

Modversion

additionalredstone-fabric-1.20.1-1.2.0.jar(Self-Compiled)

Modloader

Fabric

Additional context

3 At the moment the lever is toggled off

I think this issue should be addressed as it prevents the mod from functioning correctly. I hope this information helps in fixing the bug.

Before submitting

tristankechlo commented 8 months ago

Thank you for the detailed description of the problem, if I see this correctly it only affects XOR and XNOR gates.
This bug happens because the gate will receive two blockupdates (from left and right) that are independent from another. The gate itself does not know that these blockupdates are connected to each other, and will update itself twice.
This will be a tough one to fix (if even possible).

tristankechlo commented 1 week ago

Closing this issue, as it is unlikely that this will be fixable. From my understanding minecraft would need to change how the block-updates are handled.