ProjectRed icon indicating copy to clipboard operation
ProjectRed copied to clipboard

PropagationRun uses incorrect neighbour position

Open SquidDev opened this issue 5 years ago • 1 comments

Mod versions

  • Forge: 14.23.5.2825 (1.12.2)
  • CodeChickenLib: 1.12.2-3.2.2.353
  • ForgeMultipart: 1.12.2-2.6.1.81
  • MrTJPCore: 1.12.2-2.1.3.35
  • ProjectRed Core, Compat, Integration: 1.12.2-4.9.1.92

Details

PropagationRun calls Block.neighborChanges with a neighbour position of the updated block, rather than the position of the wire. It's not a major issue, but may confuse mods which expect the neighbour position to be in one of the cardinal directions.

https://github.com/MrTJP/ProjectRed/blob/376cd68f7cff980a1caca51528dd760e72438187/src/mrtjp/projectred/core/propagation.scala#L137

SquidDev avatar Apr 08 '19 13:04 SquidDev

Will investigate possible repercussions of making this change.

MrTJP avatar Jun 18 '19 10:06 MrTJP

Got back to this today. After some thought, decided to implement using first-change position. The propagator keeps track of the neighbor that caused the update (850b9268d43585d0e0669d14ddc1d152cdab53d0)

Note that since wires propagate fully and alert neighbors in bulk, there could be times were multiple wires in different positions update the same block. We bulk these updates together for performance (i.e. each unique neighbor will only receive a single notification). Therefore, we can only do the neighbor update notification with a single source position. The source position used is the very first wire in a chain that requests to have a neighbor updated.

For example, in the below picture, if the lever is flipped, the signal will propagate around clockwise from wires 1 - 5. While wires 2, 4, and 6 are all changing, the lamp block will receive only a single neighbor changed event from wire 2

Image

MrTJP avatar Nov 28 '23 16:11 MrTJP