Terasology / Signalling

Module containing blocks that can send signals to other blocks
1 stars 12 forks source link

patched signal cable wire #3

Closed pollend closed 7 years ago

pollend commented 7 years ago

This resolves the placement problem with signal cables. I need access to the getArchetypeBlock() but this is not available in the ConnectionCondition so I re-implemented everything backwards from there. This is for the latest version of Terasology. This does not use the tweaks for block families, but rather works around the limitations of the current block family model.

https://github.com/MovingBlocks/Terasology/pull/3085

Cervator commented 7 years ago

@pollend what's the best way to test/validate this PR? Just run with Signalling enabled and see if the cables work? Will it get in the way of / obsolete the other PR #2? Do we still need that or would your engine PR later on make this need more changes?

No opposed to merging it right now or anything, just want to stay on top of what to do when and how to test :-)

Pinging @MarcinSc in case he's still out there and curious, maybe @SkySom for interest or @msteiger / @skaldarnar for relevance (grammar systems, world gen/setup in general, etc)

pollend commented 7 years ago

This pull request resolves the runtime problems when placing cables. At the moment cables will produce a lot of runtime errors. The old implementation will look at where the block is placed and do some additional checking where the block is being placed and is only placed after family is run. I believe it used to work where the block is placed and then the block family will correct the placed block.

This is more of a temporary fix and #2 is for the pull request on the engine. This just fixes cables for the current version of Terasology. You can run both versions and verify if the cable works correctly.

Cervator commented 7 years ago

So far so good - it does let you place the cables which didn't work before, huzzah :-)

Should placing a signal switch (also labelled signal emitter, so I think it is the block I'm remembering) + cables + lamp off let you turn on the lamp by e clicking the switch?

I saw a stacktrace when I broke a switch - anything to worry about?

00:21:46.453 [main] ERROR o.t.e.event.internal.EventSystemImpl - Failed to invoke event
java.lang.IllegalArgumentException: Trying to remove a leaf block that is not in the network.
    at org.terasology.blockNetwork.EfficientBlockNetwork.removeLeafBlocks(EfficientBlockNetwork.java:306)
    at org.terasology.blockNetwork.EfficientBlockNetwork.removeLeafBlock(EfficientBlockNetwork.java:296)
    at org.terasology.signalling.componentSystem.SignalSystem.producerRemoved(SignalSystem.java:516)
MarcinSc commented 7 years ago

A LOT of the code in the mods was a workaround for some bugs in core, I was trying to mark it as such, but the code definitely needs some cleaning up, if the bugs (associated with loading world and missing and/or duplicate events) were fixed.

pollend commented 7 years ago

@MarcinSc the only thing that doesn't quite work is when the world loads, but this at least works for the most part. I have some plans to clean the codebase up, but I'll do that after GCI.