Skip to content

Commit befa1e5

Browse files
committed
Merge pull request #18 from toolbox4minecraft/bug-fixing
Bug fixing
2 parents d044d2e + 0b830a3 commit befa1e5

40 files changed

+429
-224
lines changed

biome-color-profiles/default.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
[ "Swampland", { "r":7, "g":249, "b":178 } ],
99
[ "River", { "r":0, "g":0, "b":255 } ],
1010
[ "Hell", { "r":255, "g":0, "b":0 } ],
11-
[ "Sky", { "r":128, "g":128, "b":255 } ],
11+
[ "The End", { "r":128, "g":128, "b":255 } ],
1212
[ "Frozen Ocean", { "r":144, "g":144, "b":160 } ],
1313
[ "Frozen River", { "r":160, "g":160, "b":255 } ],
1414
[ "Ice Plains", { "r":255, "g":255, "b":255 } ],

biome-color-profiles/test.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
[ "Swampland", { "r":7, "g":249, "b":178 } ],
99
[ "River", { "r":0, "g":0, "b":255 } ],
1010
[ "Hell", { "r":255, "g":0, "b":0 } ],
11-
[ "Sky", { "r":128, "g":128, "b":255 } ],
11+
[ "The End", { "r":128, "g":128, "b":255 } ],
1212
[ "Frozen Ocean", { "r":144, "g":144, "b":160 } ],
1313
[ "Frozen River", { "r":160, "g":160, "b":255 } ],
1414
[ "Ice Plains", { "r":255, "g":255, "b":255 } ],

src/main/java/amidst/Application.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ private Settings createSettings() {
5656
private MojangApi createMojangApi() throws FileNotFoundException,
5757
LocalMinecraftInterfaceCreationException {
5858
return new MojangApiBuilder(new WorldBuilder(
59-
new PlayerInformationCache(), new SeedHistoryLogger(
60-
parameters.historyFile)), parameters).construct();
59+
new PlayerInformationCache(),
60+
SeedHistoryLogger.from(parameters.historyFile)), parameters)
61+
.construct();
6162
}
6263

6364
@CalledOnlyBy(AmidstThread.EDT)

src/main/java/amidst/fragment/FragmentQueueProcessor.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import amidst.fragment.layer.LayerIds;
1010
import amidst.fragment.layer.LayerLoader;
1111
import amidst.gui.main.viewer.DimensionSelection;
12+
import amidst.mojangapi.world.Dimension;
1213
import amidst.threading.TaskQueue;
1314

1415
@NotThreadSafe
@@ -37,12 +38,12 @@ public FragmentQueueProcessor(
3738
}
3839

3940
@CalledByAny
40-
public void selectDimension(final int dimensionId) {
41+
public void selectDimension(final Dimension dimension) {
4142
taskQueue.invoke(new Runnable() {
4243
@CalledOnlyBy(AmidstThread.FRAGMENT_LOADER)
4344
@Override
4445
public void run() {
45-
dimensionSelection.setDimensionId(dimensionId);
46+
dimensionSelection.setDimension(dimension);
4647
doInvalidateLayer(LayerIds.BACKGROUND);
4748
}
4849
});

src/main/java/amidst/fragment/colorprovider/BackgroundColorProvider.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
import amidst.documentation.ThreadSafe;
44
import amidst.fragment.Fragment;
5-
import amidst.fragment.dimension.DimensionIds;
65
import amidst.gui.main.viewer.DimensionSelection;
6+
import amidst.logging.Log;
7+
import amidst.mojangapi.world.Dimension;
8+
import amidst.mojangapi.world.biome.BiomeColor;
79

810
@ThreadSafe
911
public class BackgroundColorProvider implements ColorProvider {
@@ -22,12 +24,15 @@ public BackgroundColorProvider(BiomeColorProvider biomeColorProvider,
2224
@Override
2325
public int getColorAt(Fragment fragment, long cornerX, long cornerY, int x,
2426
int y) {
25-
if (dimensionSelection.isDimensionId(DimensionIds.THE_END)) {
27+
if (dimensionSelection.isDimension(Dimension.OVERWORLD)) {
28+
return biomeColorProvider.getColorAt(fragment, cornerX, cornerY, x,
29+
y);
30+
} else if (dimensionSelection.isDimension(Dimension.END)) {
2631
return theEndColorProvider.getColorAt(fragment, cornerX, cornerY,
2732
x, y);
2833
} else {
29-
return biomeColorProvider.getColorAt(fragment, cornerX, cornerY, x,
30-
y);
34+
Log.w("unsupported dimension");
35+
return BiomeColor.unknown().getRGB();
3136
}
3237
}
3338
}

src/main/java/amidst/fragment/dimension/DimensionIds.java

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/main/java/amidst/fragment/dimension/DimensionSelector.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import amidst.documentation.ThreadSafe;
44
import amidst.fragment.FragmentQueueProcessor;
5+
import amidst.mojangapi.world.Dimension;
56

67
@ThreadSafe
78
public class DimensionSelector {
@@ -11,7 +12,7 @@ public DimensionSelector(FragmentQueueProcessor fragmentQueueProcessor) {
1112
this.fragmentQueueProcessor = fragmentQueueProcessor;
1213
}
1314

14-
public void selectDimension(int dimensionId) {
15-
fragmentQueueProcessor.selectDimension(dimensionId);
15+
public void selectDimension(Dimension dimension) {
16+
fragmentQueueProcessor.selectDimension(dimension);
1617
}
1718
}

src/main/java/amidst/fragment/drawer/FragmentDrawer.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ public boolean isEnabled() {
2121
return declaration.isVisible();
2222
}
2323

24+
@CalledOnlyBy(AmidstThread.EDT)
25+
public boolean isDrawUnloaded() {
26+
return declaration.isDrawUnloaded();
27+
}
28+
2429
@CalledOnlyBy(AmidstThread.EDT)
2530
public abstract void draw(Fragment fragment, Graphics2D g2d, float time);
2631
}

src/main/java/amidst/fragment/layer/LayerBuilder.java

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,21 @@ public LayerBuilder(Settings settings) {
4949
private List<LayerDeclaration> createDeclarations(Settings settings) {
5050
LayerDeclaration[] declarations = new LayerDeclaration[LayerIds.NUMBER_OF_LAYERS];
5151
// @formatter:off
52-
declarations[LayerIds.ALPHA] = new LayerDeclaration(LayerIds.ALPHA, new ImmutableSetting<Boolean>(true));
53-
declarations[LayerIds.BIOME_DATA] = new LayerDeclaration(LayerIds.BIOME_DATA, new ImmutableSetting<Boolean>(true));
54-
declarations[LayerIds.END_ISLANDS] = new LayerDeclaration(LayerIds.END_ISLANDS, new ImmutableSetting<Boolean>(true));
55-
declarations[LayerIds.BACKGROUND] = new LayerDeclaration(LayerIds.BACKGROUND, new ImmutableSetting<Boolean>(true));
56-
declarations[LayerIds.SLIME] = new LayerDeclaration(LayerIds.SLIME, settings.showSlimeChunks);
57-
declarations[LayerIds.GRID] = new LayerDeclaration(LayerIds.GRID, settings.showGrid);
58-
declarations[LayerIds.SPAWN] = new LayerDeclaration(LayerIds.SPAWN, settings.showSpawn);
59-
declarations[LayerIds.STRONGHOLD] = new LayerDeclaration(LayerIds.STRONGHOLD, settings.showStrongholds);
60-
declarations[LayerIds.PLAYER] = new LayerDeclaration(LayerIds.PLAYER, settings.showPlayers);
61-
declarations[LayerIds.VILLAGE] = new LayerDeclaration(LayerIds.VILLAGE, settings.showVillages);
62-
declarations[LayerIds.TEMPLE] = new LayerDeclaration(LayerIds.TEMPLE, settings.showTemples);
63-
declarations[LayerIds.MINESHAFT] = new LayerDeclaration(LayerIds.MINESHAFT, settings.showMineshafts);
64-
declarations[LayerIds.NETHER_FORTRESS] = new LayerDeclaration(LayerIds.NETHER_FORTRESS, settings.showNetherFortresses);
65-
declarations[LayerIds.OCEAN_MONUMENT] = new LayerDeclaration(LayerIds.OCEAN_MONUMENT, settings.showOceanMonuments);
66-
declarations[LayerIds.END_CITY] = new LayerDeclaration(LayerIds.END_CITY, settings.showEndCities);
52+
declarations[LayerIds.ALPHA] = new LayerDeclaration(LayerIds.ALPHA, false, new ImmutableSetting<Boolean>(true));
53+
declarations[LayerIds.BIOME_DATA] = new LayerDeclaration(LayerIds.BIOME_DATA, false, new ImmutableSetting<Boolean>(true));
54+
declarations[LayerIds.END_ISLANDS] = new LayerDeclaration(LayerIds.END_ISLANDS, false, new ImmutableSetting<Boolean>(true));
55+
declarations[LayerIds.BACKGROUND] = new LayerDeclaration(LayerIds.BACKGROUND, false, new ImmutableSetting<Boolean>(true));
56+
declarations[LayerIds.SLIME] = new LayerDeclaration(LayerIds.SLIME, false, settings.showSlimeChunks);
57+
declarations[LayerIds.GRID] = new LayerDeclaration(LayerIds.GRID, true, settings.showGrid);
58+
declarations[LayerIds.SPAWN] = new LayerDeclaration(LayerIds.SPAWN, false, settings.showSpawn);
59+
declarations[LayerIds.STRONGHOLD] = new LayerDeclaration(LayerIds.STRONGHOLD, false, settings.showStrongholds);
60+
declarations[LayerIds.PLAYER] = new LayerDeclaration(LayerIds.PLAYER, false, settings.showPlayers);
61+
declarations[LayerIds.VILLAGE] = new LayerDeclaration(LayerIds.VILLAGE, false, settings.showVillages);
62+
declarations[LayerIds.TEMPLE] = new LayerDeclaration(LayerIds.TEMPLE, false, settings.showTemples);
63+
declarations[LayerIds.MINESHAFT] = new LayerDeclaration(LayerIds.MINESHAFT, false, settings.showMineshafts);
64+
declarations[LayerIds.NETHER_FORTRESS] = new LayerDeclaration(LayerIds.NETHER_FORTRESS, false, settings.showNetherFortresses);
65+
declarations[LayerIds.OCEAN_MONUMENT] = new LayerDeclaration(LayerIds.OCEAN_MONUMENT, false, settings.showOceanMonuments);
66+
declarations[LayerIds.END_CITY] = new LayerDeclaration(LayerIds.END_CITY, false, settings.showEndCities);
6767
// @formatter:on
6868
return Collections.unmodifiableList(Arrays.asList(declarations));
6969
}
@@ -129,9 +129,12 @@ private Iterable<FragmentLoader> createLoaders(World world,
129129

130130
/**
131131
* This also defines the rendering order.
132+
*
133+
* @param dimensionSelection
132134
*/
133135
public Iterable<FragmentDrawer> createDrawers(Zoom zoom,
134-
WorldIconSelection worldIconSelection) {
136+
WorldIconSelection worldIconSelection,
137+
DimensionSelection dimensionSelection) {
135138
// @formatter:off
136139
return Collections.unmodifiableList(Arrays.asList(
137140
new AlphaUpdater( declarations.get(LayerIds.ALPHA)),

src/main/java/amidst/fragment/layer/LayerDeclaration.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,24 @@
66
@Immutable
77
public class LayerDeclaration {
88
private final int layerId;
9+
private final boolean drawUnloaded;
910
private final Setting<Boolean> isVisibleSetting;
1011

11-
public LayerDeclaration(int layerId, Setting<Boolean> isVisibleSetting) {
12+
public LayerDeclaration(int layerId, boolean drawUnloaded,
13+
Setting<Boolean> isVisibleSetting) {
1214
this.layerId = layerId;
15+
this.drawUnloaded = drawUnloaded;
1316
this.isVisibleSetting = isVisibleSetting;
1417
}
1518

1619
public int getLayerId() {
1720
return layerId;
1821
}
1922

23+
public boolean isDrawUnloaded() {
24+
return drawUnloaded;
25+
}
26+
2027
public boolean isVisible() {
2128
return isVisibleSetting.get();
2229
}

src/main/java/amidst/gui/main/Actions.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@
2222
import amidst.mojangapi.MojangApi;
2323
import amidst.mojangapi.file.MojangApiParsingException;
2424
import amidst.mojangapi.minecraftinterface.MinecraftInterfaceException;
25+
import amidst.mojangapi.world.Dimension;
2526
import amidst.mojangapi.world.WorldSeed;
2627
import amidst.mojangapi.world.WorldType;
2728
import amidst.mojangapi.world.coordinates.CoordinatesInWorld;
2829
import amidst.mojangapi.world.icon.WorldIcon;
2930
import amidst.mojangapi.world.player.Player;
31+
import amidst.mojangapi.world.player.PlayerCoordinates;
3032
import amidst.settings.biomecolorprofile.BiomeColorProfile;
3133
import amidst.settings.biomecolorprofile.BiomeColorProfileSelection;
3234
import amidst.threading.WorkerExecutor;
@@ -190,7 +192,7 @@ public void howCanIMoveAPlayer() {
190192
+ "WARNING: This will change the contents of the save folder, so there is a chance that the world gets corrupted.\n"
191193
+ "We try to minimize the risk by creating a backup of the changed file, before it is changed.\n"
192194
+ "If the backup fails, we will not write the changes.\n"
193-
+ "You can find the backup files in a sub folder of the world, named 'amidst_backup'.\n"
195+
+ "You can find the backup files in a sub folder of the world, named 'amidst/backup'.\n"
194196
+ "Especially, make sure to not have the world loaded in Minecraft during this process.");
195197
}
196198

@@ -219,10 +221,10 @@ public void saveCaptureImage() {
219221
}
220222

221223
@CalledOnlyBy(AmidstThread.EDT)
222-
public void selectDimension(int dimensionId) {
224+
public void selectDimension(Dimension dimension) {
223225
ViewerFacade viewerFacade = this.viewerFacade.get();
224226
if (viewerFacade != null) {
225-
viewerFacade.selectDimension(dimensionId);
227+
viewerFacade.selectDimension(dimension);
226228
}
227229
}
228230

@@ -297,11 +299,14 @@ public void showPlayerPopupMenu(CoordinatesInWorld targetCoordinates,
297299
public void movePlayer(Player player, CoordinatesInWorld targetCoordinates) {
298300
ViewerFacade viewerFacade = this.viewerFacade.get();
299301
if (viewerFacade != null) {
300-
long currentHeight = player.getPlayerCoordinates().getY();
302+
PlayerCoordinates currentCoordinates = player
303+
.getPlayerCoordinates();
304+
long currentHeight = currentCoordinates.getY();
301305
String input = mainWindow.askForPlayerHeight(currentHeight);
302306
if (input != null) {
303307
player.moveTo(targetCoordinates,
304-
tryParseLong(input, currentHeight));
308+
tryParseLong(input, currentHeight),
309+
currentCoordinates.getDimension());
305310
viewerFacade.reloadPlayerLayer();
306311
if (mainWindow
307312
.askToConfirm(

src/main/java/amidst/gui/main/MainWindow.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public void setWorld(World world) {
148148
clearViewerFacade();
149149
if (decideWorldPlayerType(world.getMovablePlayerList())) {
150150
setViewerFacade(viewerFacadeBuilder.create(world, actions,
151-
menuBar.getSelectedDimensionId()));
151+
menuBar.getSelectedDimension()));
152152
} else {
153153
frame.revalidate();
154154
frame.repaint();

src/main/java/amidst/gui/main/menu/AmidstMenu.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import amidst.documentation.AmidstThread;
88
import amidst.documentation.CalledOnlyBy;
99
import amidst.documentation.NotThreadSafe;
10+
import amidst.mojangapi.world.Dimension;
1011

1112
@NotThreadSafe
1213
public class AmidstMenu {
@@ -49,7 +50,7 @@ public void setReloadPlayerLocationsMenuEnabled(boolean isEnabled) {
4950
}
5051

5152
@CalledOnlyBy(AmidstThread.EDT)
52-
public int getSelectedDimensionId() {
53+
public Dimension getSelectedDimension() {
5354
return dimensionToggleButtonModels.get();
5455
}
5556
}

src/main/java/amidst/gui/main/menu/DimensionToggleButtonModels.java

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,28 @@
33
import javax.swing.JToggleButton.ToggleButtonModel;
44

55
import amidst.documentation.ThreadSafe;
6-
import amidst.fragment.dimension.DimensionIds;
76
import amidst.gui.main.Actions;
7+
import amidst.mojangapi.world.Dimension;
88

99
@ThreadSafe
1010
public class DimensionToggleButtonModels {
1111
@SuppressWarnings("serial")
12-
public class DimensionIdButtonModel extends ToggleButtonModel {
13-
private final int dimensionId;
12+
public class DimensionButtonModel extends ToggleButtonModel {
13+
private final Dimension dimension;
1414

15-
public DimensionIdButtonModel(int dimensionId) {
16-
this.dimensionId = dimensionId;
17-
}
18-
19-
public int getDimensionId() {
20-
return dimensionId;
15+
public DimensionButtonModel(Dimension dimension) {
16+
this.dimension = dimension;
2117
}
2218

2319
@Override
2420
public boolean isSelected() {
25-
return dimensionId == get();
21+
return dimension == get();
2622
}
2723

2824
@Override
2925
public void setSelected(boolean isSelected) {
3026
if (isSelected) {
31-
set(dimensionId);
27+
set(dimension);
3228
}
3329
}
3430

@@ -38,15 +34,15 @@ private void update() {
3834
}
3935

4036
private final Actions actions;
41-
private final DimensionIdButtonModel overworld;
42-
private final DimensionIdButtonModel theEnd;
43-
private volatile int selection;
37+
private final DimensionButtonModel overworld;
38+
private final DimensionButtonModel theEnd;
39+
private volatile Dimension selection;
4440

4541
public DimensionToggleButtonModels(Actions actions) {
4642
this.actions = actions;
47-
this.overworld = new DimensionIdButtonModel(DimensionIds.OVERWORLD);
48-
this.theEnd = new DimensionIdButtonModel(DimensionIds.THE_END);
49-
this.set(DimensionIds.OVERWORLD);
43+
this.overworld = new DimensionButtonModel(Dimension.OVERWORLD);
44+
this.theEnd = new DimensionButtonModel(Dimension.END);
45+
this.set(Dimension.OVERWORLD);
5046
}
5147

5248
public ToggleButtonModel getOverworld() {
@@ -57,14 +53,14 @@ public ToggleButtonModel getTheEnd() {
5753
return theEnd;
5854
}
5955

60-
public int get() {
56+
public Dimension get() {
6157
return selection;
6258
}
6359

64-
public synchronized void set(int dimensionId) {
65-
this.selection = dimensionId;
60+
public synchronized void set(Dimension value) {
61+
this.selection = value;
6662
this.overworld.update();
6763
this.theEnd.update();
68-
this.actions.selectDimension(dimensionId);
64+
this.actions.selectDimension(value);
6965
}
7066
}
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
package amidst.gui.main.viewer;
22

33
import amidst.documentation.ThreadSafe;
4+
import amidst.mojangapi.world.Dimension;
45

56
@ThreadSafe
67
public class DimensionSelection {
7-
private volatile int dimensionId;
8+
private volatile Dimension dimension;
89

9-
public DimensionSelection(int dimensionId) {
10-
this.dimensionId = dimensionId;
10+
public DimensionSelection(Dimension dimension) {
11+
this.dimension = dimension;
1112
}
1213

13-
public boolean isDimensionId(int dimensionId) {
14-
return this.dimensionId == dimensionId;
14+
public boolean isDimension(Dimension dimension) {
15+
return this.dimension == dimension;
1516
}
1617

17-
public void setDimensionId(int dimensionId) {
18-
this.dimensionId = dimensionId;
18+
public void setDimension(Dimension dimension) {
19+
this.dimension = dimension;
1920
}
2021
}

0 commit comments

Comments
 (0)