-
Notifications
You must be signed in to change notification settings - Fork 20
fix: regenerate addressess and update merge state when gate position changes #310
base: master
Are you sure you want to change the base?
Conversation
Won't it spam You can query those with |
My |
Okay, didn't remember that one |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably shouldn't do sth like this. Find the cause that's passing null
there. Or at least handle it higher.
|
||
@Override | ||
public void update() { | ||
super.update(); | ||
|
||
if (!world.isRemote) { | ||
if (!lastPos.equals(pos)) { | ||
lastPos = pos; | ||
generateAddresses(!hasUpgrade(StargateClassicBaseTile.StargateUpgradeEnum.CHEVRON_UPGRADE)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would you recommend to check whether the tile has moved?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slava mentions custom Stargate addresses, so someone using commands won't be happy with those changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you check that? With command and with Warp drive or other gate-moving mods?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what I'm thinking. onLoad
executes before update
and whole effort of making this mod WarpDrive compatible is worthless.
@@ -42,105 +42,103 @@ | |||
|
|||
// -------------------------------------------------------------------------------- | |||
// Dialing | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've read there is a macro bound to Ctrl+S by default in intellij
@@ -1043,6 +1038,15 @@ public final void updateMergeState(boolean shouldBeMerged, EnumFacing facing) { | |||
else { | |||
onGateMerged(); | |||
} | |||
|
|||
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Address might be null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also there is so much code stripped of this method compared to the original code from onLoad
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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