-
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?
Changes from 4 commits
6f12ebe
c45f704
2882031
56ad3c2
c8d7675
b8ad49a
44bc860
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -428,7 +428,7 @@ public void setGateAddress(SymbolTypeEnum symbolType, StargateAddress stargateAd | |
|
|
||
| markDirty(); | ||
| } | ||
|
|
||
| public StargateAddressDynamic getDialedAddress() { | ||
| return dialedAddress; | ||
| } | ||
|
|
@@ -661,28 +661,8 @@ public void onLoad() { | |
| network = StargateNetwork.get(world); | ||
|
|
||
| targetPoint = new TargetPoint(world.provider.getDimension(), pos.getX(), pos.getY(), pos.getZ(), 512); | ||
| Random random = new Random(pos.hashCode() * 31 + world.provider.getDimension()); | ||
|
|
||
| for (SymbolTypeEnum symbolType : SymbolTypeEnum.values()) { | ||
|
|
||
| StargatePos stargatePos; | ||
|
|
||
| if (gateAddressMap.get(symbolType) == null) { | ||
| StargateAddress address = new StargateAddress(symbolType); | ||
| address.generate(random); | ||
|
|
||
| stargatePos = new StargatePos(world.provider.getDimension(), pos, address); | ||
| network.addStargate(address, stargatePos); | ||
| gateAddressMap.put(symbolType, address); | ||
| // Aunis.info(address.toString()); | ||
| } | ||
|
|
||
| else { | ||
| stargatePos = new StargatePos(world.provider.getDimension(), pos, gateAddressMap.get(symbolType)); | ||
| } | ||
|
|
||
| gatePosMap.put(symbolType, stargatePos); | ||
| } | ||
| generateAddresses(false); | ||
|
|
||
| if (stargateState.engaged()) { | ||
| verifyConnection(); | ||
|
|
@@ -693,6 +673,21 @@ public void onLoad() { | |
| AunisPacketHandler.INSTANCE.sendToServer(new StateUpdateRequestToServer(pos, StateTypeEnum.RENDERER_STATE)); | ||
| } | ||
| } | ||
|
|
||
| public void generateAddresses(boolean reset) { | ||
| Random random = new Random(pos.hashCode() * 31 + world.provider.getDimension()); | ||
|
|
||
| for (SymbolTypeEnum symbolType : SymbolTypeEnum.values()) { | ||
| StargateAddress address = getStargateAddress(symbolType); | ||
|
|
||
| if (gateAddressMap.get(symbolType) == null || reset) { | ||
| address = new StargateAddress(symbolType); | ||
| address.generate(random); | ||
| } | ||
|
|
||
| this.setGateAddress(symbolType, address); | ||
| } | ||
| } | ||
|
|
||
| private boolean addedToNetwork; | ||
|
|
||
|
|
@@ -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. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
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. |
||
| if (this.isMerged == shouldBeMerged) { | ||
| if (shouldBeMerged) { | ||
| getMergeHelper().updateMembersBasePos(world, pos, facing); | ||
| } | ||
| return; | ||
| } | ||
|
|
||
| this.isMerged = shouldBeMerged; | ||
| IBlockState actualState = world.getBlockState(pos); | ||
|
|
||
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
nullThere 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
onLoadThere 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
setGateAddressrepeated.