Skip to content

Commit

Permalink
Rename AllAdvancementsStructureType
Browse files Browse the repository at this point in the history
  • Loading branch information
Ninjabrain1 committed Sep 12, 2024
1 parent d2ccd75 commit 177d1fe
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import ninjabrainbot.model.datastate.alladvancements.AllAdvancementsPosition;
import ninjabrainbot.model.datastate.alladvancements.IAllAdvancementsDataState;
import ninjabrainbot.model.datastate.alladvancements.IAllAdvancementsPosition;
import ninjabrainbot.model.datastate.alladvancements.StructureType;
import ninjabrainbot.model.datastate.alladvancements.AllAdvancementsStructureType;
import ninjabrainbot.model.datastate.common.IDetailedPlayerPosition;
import ninjabrainbot.model.domainmodel.IDataComponent;

Expand All @@ -24,52 +24,52 @@ public TryAddAllAdvancementsStructureAction(IDataState dataState, IDetailedPlaye

@Override
public void execute() {
StructureType structureType = getAllAdvancementStructureTypeFromPlayerPosition(playerPosition);
if (structureType == StructureType.Unknown)
AllAdvancementsStructureType structureType = getAllAdvancementStructureTypeFromPlayerPosition(playerPosition);
if (structureType == AllAdvancementsStructureType.Unknown)
return;

IAllAdvancementsPosition structurePosition = getStructurePosition(structureType);

IDataComponent<IAllAdvancementsPosition> dataComponent = getDataComponentFromStructureType(structureType);
// Cities can be queried multiple times, so overwrite the position.
if (structureType != StructureType.CityQuery && dataComponent.get() != null)
if (structureType != AllAdvancementsStructureType.CityQuery && dataComponent.get() != null)
return;

dataComponent.set(structurePosition);
}

private StructureType getAllAdvancementStructureTypeFromPlayerPosition(IDetailedPlayerPosition t) {
private AllAdvancementsStructureType getAllAdvancementStructureTypeFromPlayerPosition(IDetailedPlayerPosition t) {
if (t.isInNether())
return StructureType.Unknown;
return AllAdvancementsStructureType.Unknown;

if (t.isInEnd())
return preferences.oneDotTwentyPlusAA.get() ? StructureType.ShulkerTransport : StructureType.Unknown;
return preferences.oneDotTwentyPlusAA.get() ? AllAdvancementsStructureType.ShulkerTransport : AllAdvancementsStructureType.Unknown;

if (Math.abs(t.xInOverworld()) <= 300 && Math.abs(t.zInOverworld()) <= 300 && Math.abs(Math.round(t.yInPlayerDimension()) - t.yInPlayerDimension()) < 0.001)
return StructureType.Spawn;
return AllAdvancementsStructureType.Spawn;

if (t.yInPlayerDimension() < 63) {
if (preferences.oneDotTwentyPlusAA.get()) {
if (t.yInPlayerDimension() > 30 && t.isInOverworld()) {
return StructureType.Monument;
return AllAdvancementsStructureType.Monument;
}
} else {
return StructureType.Monument;
return AllAdvancementsStructureType.Monument;
}
}

if (preferences.oneDotTwentyPlusAA.get()) {
if (t.yInPlayerDimension() <= 30 && t.isInOverworld())
return StructureType.DeepDark;
return AllAdvancementsStructureType.DeepDark;

if (t.yInPlayerDimension() > 160 && t.isInOverworld())
return StructureType.CityQuery;
return AllAdvancementsStructureType.CityQuery;
}

return StructureType.Outpost;
return AllAdvancementsStructureType.Outpost;
}

private IAllAdvancementsPosition getStructurePosition(StructureType structureType) {
private IAllAdvancementsPosition getStructurePosition(AllAdvancementsStructureType structureType) {
switch (structureType) {
case Outpost:
return getOutpostPosition(playerPosition);
Expand Down Expand Up @@ -101,7 +101,7 @@ private IAllAdvancementsPosition getCityRegionCentre(IDetailedPlayerPosition t)
return new AllAdvancementsPosition(cityRegionCentreX * 16 + 8, cityRegionCentreZ * 16 + 8);
}

private IDataComponent<IAllAdvancementsPosition> getDataComponentFromStructureType(StructureType structureType) {
private IDataComponent<IAllAdvancementsPosition> getDataComponentFromStructureType(AllAdvancementsStructureType structureType) {
switch (structureType) {
case Spawn:
return allAdvancementsDataState.spawnPosition();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package ninjabrainbot.model.datastate.alladvancements;

public enum StructureType {
public enum AllAdvancementsStructureType {
Spawn, Outpost, Monument, Stronghold, DeepDark, CityQuery, ShulkerTransport, GeneralLocation, Unknown
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ninjabrainbot.gui.mainwindow.main;

import ninjabrainbot.gui.mainwindow.alladvancements.StructurePanel;
import ninjabrainbot.model.datastate.alladvancements.StructureType;
import ninjabrainbot.model.datastate.alladvancements.AllAdvancementsStructureType;
import ninjabrainbot.util.I18n;
import org.junit.jupiter.api.Assertions;

Expand Down Expand Up @@ -38,7 +38,7 @@ public void assertDetailedTriangulationTopNetherCoordsIsEqualTo(int x, int z) {
Assertions.assertEquals(expectedNetherText, getDetailedTriangulationPanel_netherCoords(0));
}

public String getAllAdvancementsStructurePanelCoordinates(StructureType structureType) {
public String getAllAdvancementsStructurePanelCoordinates(AllAdvancementsStructureType structureType) {
switch (structureType) {
case Stronghold:
return ((StructurePanel) mainTextArea.allAdvancements.getComponent(1)).getLocationText();
Expand All @@ -52,7 +52,7 @@ public String getAllAdvancementsStructurePanelCoordinates(StructureType structur
throw new RuntimeException("Unsupported structure type: " + structureType);
}

public void assertAllAdvancementsStructureCoordsAre(int x, int z, StructureType structureType) {
public void assertAllAdvancementsStructureCoordsAre(int x, int z, AllAdvancementsStructureType structureType) {
String expectedStructureText = String.format("(%s, %s)", x, z);
Assertions.assertTrue(mainTextArea.allAdvancements.isVisible(), "AllAdvancementsPanel is not visible.");
Assertions.assertEquals(expectedStructureText, getAllAdvancementsStructurePanelCoordinates(structureType));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import ninjabrainbot.gui.mainwindow.main.MainTextAreaTestAdapter;
import ninjabrainbot.model.datastate.alladvancements.IAllAdvancementsDataState;
import ninjabrainbot.model.datastate.alladvancements.StructureType;
import ninjabrainbot.model.datastate.alladvancements.AllAdvancementsStructureType;
import ninjabrainbot.model.datastate.common.ResultType;
import ninjabrainbot.util.TestUtils;
import org.junit.jupiter.api.Assertions;
Expand Down Expand Up @@ -39,30 +39,30 @@ void uiUpdatesAsExpected_TypicalAASpeedrun(String f3c1, String f3c2, String f3c3
TestUtils.awaitSwingEvents();
Assertions.assertTrue(aaDataState.allAdvancementsModeEnabled().get());
Assertions.assertSame(testBuilder.dataState.resultType().get(), ResultType.ALL_ADVANCEMENTS);
mainTextArea.assertAllAdvancementsStructureCoordsAre(strongholdChunkX * 16 + 4, strongholdChunkZ * 16 + 4, StructureType.Stronghold);
Assertions.assertTrue(mainTextArea.getAllAdvancementsStructurePanelCoordinates(StructureType.Spawn).isEmpty());
Assertions.assertTrue(mainTextArea.getAllAdvancementsStructurePanelCoordinates(StructureType.Outpost).isEmpty());
Assertions.assertTrue(mainTextArea.getAllAdvancementsStructurePanelCoordinates(StructureType.Monument).isEmpty());
mainTextArea.assertAllAdvancementsStructureCoordsAre(strongholdChunkX * 16 + 4, strongholdChunkZ * 16 + 4, AllAdvancementsStructureType.Stronghold);
Assertions.assertTrue(mainTextArea.getAllAdvancementsStructurePanelCoordinates(AllAdvancementsStructureType.Spawn).isEmpty());
Assertions.assertTrue(mainTextArea.getAllAdvancementsStructurePanelCoordinates(AllAdvancementsStructureType.Outpost).isEmpty());
Assertions.assertTrue(mainTextArea.getAllAdvancementsStructurePanelCoordinates(AllAdvancementsStructureType.Monument).isEmpty());

testBuilder.setClipboard(f3cSpawn);
TestUtils.awaitSwingEvents();
mainTextArea.assertAllAdvancementsStructureCoordsAre(spawnX, spawnZ, StructureType.Spawn);
mainTextArea.assertAllAdvancementsStructureCoordsAre(spawnX, spawnZ, AllAdvancementsStructureType.Spawn);

testBuilder.setClipboard(f3cOutpost);
TestUtils.awaitSwingEvents();
mainTextArea.assertAllAdvancementsStructureCoordsAre(outpostX, outpostZ, StructureType.Outpost);
mainTextArea.assertAllAdvancementsStructureCoordsAre(outpostX, outpostZ, AllAdvancementsStructureType.Outpost);

testBuilder.setClipboard(f3cMonument);
TestUtils.awaitSwingEvents();
mainTextArea.assertAllAdvancementsStructureCoordsAre(monumentX, monumentZ, StructureType.Monument);
mainTextArea.assertAllAdvancementsStructureCoordsAre(monumentX, monumentZ, AllAdvancementsStructureType.Monument);

testBuilder.resetCalculator();
TestUtils.awaitSwingEvents();
Assertions.assertFalse(mainTextArea.isAllAdvancementsPanelVisible());
Assertions.assertTrue(mainTextArea.getAllAdvancementsStructurePanelCoordinates(StructureType.Stronghold).isEmpty());
Assertions.assertTrue(mainTextArea.getAllAdvancementsStructurePanelCoordinates(StructureType.Spawn).isEmpty());
Assertions.assertTrue(mainTextArea.getAllAdvancementsStructurePanelCoordinates(StructureType.Outpost).isEmpty());
Assertions.assertTrue(mainTextArea.getAllAdvancementsStructurePanelCoordinates(StructureType.Monument).isEmpty());
Assertions.assertTrue(mainTextArea.getAllAdvancementsStructurePanelCoordinates(AllAdvancementsStructureType.Stronghold).isEmpty());
Assertions.assertTrue(mainTextArea.getAllAdvancementsStructurePanelCoordinates(AllAdvancementsStructureType.Spawn).isEmpty());
Assertions.assertTrue(mainTextArea.getAllAdvancementsStructurePanelCoordinates(AllAdvancementsStructureType.Outpost).isEmpty());
Assertions.assertTrue(mainTextArea.getAllAdvancementsStructurePanelCoordinates(AllAdvancementsStructureType.Monument).isEmpty());
}

@ParameterizedTest
Expand All @@ -77,13 +77,13 @@ void uiUpdatesAsExpected_HotkeysAreDisabledInAaMode(String f3c1, String f3c2, St
testBuilder.enterEnd();
testBuilder.inputSubpixelCorrections(10);
TestUtils.awaitSwingEvents();
mainTextArea.assertAllAdvancementsStructureCoordsAre(strongholdChunkX * 16 + 4, strongholdChunkZ * 16 + 4, StructureType.Stronghold);
mainTextArea.assertAllAdvancementsStructureCoordsAre(strongholdChunkX * 16 + 4, strongholdChunkZ * 16 + 4, AllAdvancementsStructureType.Stronghold);
testBuilder.inputSubpixelCorrections(-10);
TestUtils.awaitSwingEvents();
mainTextArea.assertAllAdvancementsStructureCoordsAre(strongholdChunkX * 16 + 4, strongholdChunkZ * 16 + 4, StructureType.Stronghold);
mainTextArea.assertAllAdvancementsStructureCoordsAre(strongholdChunkX * 16 + 4, strongholdChunkZ * 16 + 4, AllAdvancementsStructureType.Stronghold);
testBuilder.inputStandardDeviationToggle();
TestUtils.awaitSwingEvents();
mainTextArea.assertAllAdvancementsStructureCoordsAre(strongholdChunkX * 16 + 4, strongholdChunkZ * 16 + 4, StructureType.Stronghold);
mainTextArea.assertAllAdvancementsStructureCoordsAre(strongholdChunkX * 16 + 4, strongholdChunkZ * 16 + 4, AllAdvancementsStructureType.Stronghold);
}

private void doAnyPercentSplit(IntegrationTestBuilder testBuilder, IAllAdvancementsDataState aaDataState, MainTextAreaTestAdapter mainTextArea,
Expand Down

0 comments on commit 177d1fe

Please sign in to comment.