OneLemonyBoi / MiniUtilities

https://www.curseforge.com/minecraft/mc-mods/miniutilities
MIT License
12 stars 17 forks source link

Laser System #151

Closed BobVonBob closed 2 months ago

BobVonBob commented 11 months ago

I think the laser power system could perhaps use another look.

First issue, I believe this line is preventing laser hubs from being placed, as they seemingly detect themselves. https://github.com/OneLemonyBoi/MiniUtilities/blob/cead66f1b5ffb413cf679a11285dd04b0d2c59e8/src/main/java/onelemonyboi/miniutilities/blocks/complexblocks/lasers/LaserHubBlock.java#L58 (The intention here seems to be to prevent overlapping? If so the radius is too small. If two hubs are placed 17 blocks apart they won't break, but nearly half their range will be shared)

However, this is probably a blessing in disguise. Hubs currently scan 32,768 blocks

every tick https://github.com/OneLemonyBoi/MiniUtilities/blob/cead66f1b5ffb413cf679a11285dd04b0d2c59e8/src/main/java/onelemonyboi/miniutilities/blocks/complexblocks/lasers/LaserHubTile.java#L27-L30 https://github.com/OneLemonyBoi/MiniUtilities/blob/cead66f1b5ffb413cf679a11285dd04b0d2c59e8/src/main/java/onelemonyboi/miniutilities/blocks/complexblocks/lasers/LaserHubTile.java#L57-L71
and every frame. https://github.com/OneLemonyBoi/MiniUtilities/blob/cead66f1b5ffb413cf679a11285dd04b0d2c59e8/src/main/java/onelemonyboi/miniutilities/blocks/complexblocks/lasers/LaserHubTESR.java#L25-L28 https://github.com/OneLemonyBoi/MiniUtilities/blob/cead66f1b5ffb413cf679a11285dd04b0d2c59e8/src/main/java/onelemonyboi/miniutilities/blocks/complexblocks/lasers/LaserHubTile.java#L73-L112

I'm not a modder, but I suspect that's not very performant.

Some ideas: You could take the route many wireless mods choose (LaserIO, Modular Routers, etc.) and require lasers to be linked by the player, removing automatic scanning entirely.

If you want to maintain the automatic linking functionality another option would be to have the hubs and ports scan, communicate, and save relevant positions when placed, then notify others when destroyed. I believe Powah! energizing orbs work like this.