fix: regenerate addressess and update merge state when gate position changes#310
fix: regenerate addressess and update merge state when gate position changes#310sentialx wants to merge 7 commits intoMrJake222:masterfrom
Conversation
|
Won't it spam You can query those with |
|
My |
|
Okay, didn't remember that one |
MrJake222
left a comment
There was a problem hiding this comment.
You probably shouldn't do sth like this. Find the cause that's passing null there. Or at least handle it higher.
| if (!world.isRemote) { | ||
| if (!lastPos.equals(pos)) { | ||
| lastPos = pos; | ||
| generateAddresses(!hasUpgrade(StargateClassicBaseTile.StargateUpgradeEnum.CHEVRON_UPGRADE)); |
There was a problem hiding this comment.
So if there's no chevron upgrade stargate will reset address after chunk will be unloaded and loaded again? Because lastPos field will be null. Custom stargate address will not work without chevron upgrade
There was a problem hiding this comment.
What would you recommend to check whether the tile has moved?
There was a problem hiding this comment.
Btw, does it actually matter? The address will stay the same, since the generator is using the position as seed.
There was a problem hiding this comment.
Slava mentions custom Stargate addresses, so someone using commands won't be happy with those changes.
There was a problem hiding this comment.
Maybe save a boolean to NBT like addressOverriddenByCommand or just fixedAddress with a docstring indicating it handles address persistence when used with commands?
There was a problem hiding this comment.
Ah, I missed that command. I've added lastPos assignment in onLoad, and I think it works now.
There was a problem hiding this comment.
Did you check that? With command and with Warp drive or other gate-moving mods?
There was a problem hiding this comment.
Not sure about that. I think now code inside !lastPos.equals(pos) condition will not be called at all. Because position will be set in onLoad method after TileEntity creation and it's not possible that this position will not be equal to the current gate position
There was a problem hiding this comment.
That's what I'm thinking. onLoad executes before update and whole effort of making this mod WarpDrive compatible is worthless.
|
|
||
| // -------------------------------------------------------------------------------- | ||
| // Dialing | ||
There was a problem hiding this comment.
It's recommended to do code optimisations in different commits/PRs. Because it's a bit harder to review PR with this
There was a problem hiding this comment.
I tried to keep these files as they were, but IntelliJ doesn't have an option to disable formatting on save, sorry for that.
There was a problem hiding this comment.
Yes it does. If you're making commits via Intellij Idea there is checkmark Do you want to optimise code before commit?. And there's no automatic optimisations on save unless you turned this on by yourself. Check IDE settings and look at this checkmark on commit
There was a problem hiding this comment.
I'm not doing commits via intellij, but it's formatting on save, which doesn't seem to have an option to disable that.
There was a problem hiding this comment.
I've read there is a macro bound to Ctrl+S by default in intellij
| } | ||
|
|
||
| // If the gate has already been merged, there is no need to merge it again. | ||
| // However, when the gate position changes, the members base pos should be updated as well. |
There was a problem hiding this comment.
when the gate position changes
But it will be updated every time when updateMergeState will be called with (shouldBeMerged && this.isMerged) == true. Should be fine anyway? :I
Also you can move this stuff higher probably (above if (!shouldBeMerged) condition, line 1029)
There was a problem hiding this comment.
But it will be updated every time when updateMergeState will be called with (shouldBeMerged && this.isMerged) == true. Should be fine anyway? :I
If that's the case, this means that the gate changed its position. There is no other code path that could trigger the if statement.
| address.generate(random); | ||
| } | ||
|
|
||
| this.setGateAddress(symbolType, address); |
There was a problem hiding this comment.
Also there is so much code stripped of this method compared to the original code from onLoad
There was a problem hiding this comment.
Yeah beacause it was basically setGateAddress repeated.
|
I would be willing to test, but idk how to turn this into a .class file. I have figured out that's what I need to do, but it always errors. I apologize if it's rude to comment here, and will delete if so |
Run |
This PR should fix issues when moving the gate by using mods like WarpDrive, Valkyrien etc.
Nine chevron address stays the same when the gate moves and seven chevron address regenerates.
Fixes #253