Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

End Improvements #759

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
2236e7c
Speed up some things in EndIslandOracle, add End Gateways as an icon
burgerindividual May 16, 2020
10c0f41
fix weird merge bug
burgerindividual May 16, 2020
476052b
change some stuff that messed up in merge
burgerindividual May 16, 2020
c4aed0b
redo some icons
burgerindividual May 16, 2020
c74e47e
Merge branch 'master' into end-improvements-2
burgerindividual May 16, 2020
9233bff
Merge branch 'master' into end-improvements-2
burgerindividual May 22, 2020
d1359b5
merge stuff from master-changes
burgerindividual May 22, 2020
b4d7383
wip small islands in end
burgerindividual Jun 30, 2020
5770e4b
Merge branch 'master' into end-improvements-2
burgerindividual Jun 30, 2020
97099d6
Fix end gateways for 1.16, make possible end gateways more accurate, …
burgerindividual Jul 1, 2020
f3be919
fix cursorinformationwidget for versions before 18w06a
burgerindividual Jul 1, 2020
67d17e8
Merge branch 'master' into end-improvements-2
burgerindividual Jul 1, 2020
9c2348d
remove unneeded //FIXME
burgerindividual Jul 1, 2020
a0572cd
Merge branch 'master' into end-improvements-2
burgerindividual Jul 14, 2020
1099412
Merge branch 'master' into end-improvements-2
burgerindividual Jul 19, 2020
f4df81a
Update pom.xml
burgerindividual Jul 20, 2020
e43630d
Merge branch 'master' into end-improvements-2
burgerindividual Jul 24, 2020
d2a05bf
fix tests by only using large end islands
burgerindividual Jul 24, 2020
e21b706
merge master
burgerindividual Aug 6, 2020
f967a09
Merge branch 'master' into end-improvements-2
burgerindividual Aug 11, 2020
25547d2
Merge branch 'master' into end-improvements-2
burgerindividual Aug 28, 2020
7e62b00
changes to work with master merge
burgerindividual Aug 28, 2020
b83a6f4
fix versions for end gateways, add proper null checks for small end i…
burgerindividual Aug 28, 2020
e6ad64f
Merge branch 'master' into end-improvements-2
burgerindividual Aug 31, 2020
a69a580
merge master
burgerindividual Aug 31, 2020
05a3d0d
Update pom.xml
burgerindividual Aug 31, 2020
727f009
Update EndIslandOracle.java
burgerindividual Aug 31, 2020
156e5d5
fix small island pixels
burgerindividual Sep 9, 2020
c2f8ad4
Merge branch 'master' into end-improvements-2
burgerindividual Sep 15, 2020
0f19acc
Merge branch 'master' into end-improvements-2
burgerindividual Oct 16, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/java/amidst/AmidstSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class AmidstSettings {
public final Setting<Boolean> showOceanFeatures;
public final Setting<Boolean> showNetherFortresses;
public final Setting<Boolean> showEndCities;
public final Setting<Boolean> showEndGateways;

public final Setting<Boolean> smoothScrolling;
public final Setting<Boolean> fragmentFading;
Expand Down Expand Up @@ -67,6 +68,7 @@ public AmidstSettings(Preferences preferences) {
showOceanFeatures = Setting.createBoolean( preferences, "oceanFeaturesIcons", true);
showNetherFortresses = Setting.createBoolean( preferences, "netherFortressIcons", false);
showEndCities = Setting.createBoolean( preferences, "endCityIcons", false);
showEndGateways = Setting.createBoolean( preferences, "endGatewayIcons", false);

smoothScrolling = Setting.createBoolean( preferences, "mapFlicking", true);
fragmentFading = Setting.createBoolean( preferences, "mapFading", true);
Expand Down
18 changes: 14 additions & 4 deletions src/main/java/amidst/fragment/Fragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
import amidst.mojangapi.world.coordinates.Resolution;
import amidst.mojangapi.world.icon.WorldIcon;
import amidst.mojangapi.world.oracle.BiomeDataOracle;
import amidst.mojangapi.world.oracle.EndIsland;
import amidst.mojangapi.world.oracle.end.EndIslandList;
import amidst.mojangapi.world.oracle.end.LargeEndIsland;
import amidst.mojangapi.world.oracle.end.SmallEndIsland;

/**
* This class contains nearly no logic but only simple and atomic getters and
Expand Down Expand Up @@ -96,7 +98,7 @@ public class Fragment {

private volatile float alpha;
private volatile short[][] biomeData;
private volatile List<EndIsland> endIslands;
private volatile EndIslandList endIslands;
private final AtomicReferenceArray<BufferedImage> images;
private final AtomicReferenceArray<List<WorldIcon>> worldIcons;

Expand Down Expand Up @@ -135,11 +137,19 @@ public short getBiomeDataAt(int x, int y) {
return biomeData[x][y];
}

public void setEndIslands(List<EndIsland> endIslands) {
public void setEndIslands(EndIslandList endIslands) {
this.endIslands = endIslands;
}

public List<EndIsland> getEndIslands() {
public List<LargeEndIsland> getLargeEndIslands() {
return endIslands.getLargeIslands();
}

public List<SmallEndIsland> getSmallEndIslands() {
return endIslands.getSmallIslands();
}

public EndIslandList getEndIslands() {
return endIslands;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
import amidst.documentation.ThreadSafe;
import amidst.fragment.Fragment;
import amidst.mojangapi.world.Dimension;
import amidst.mojangapi.world.oracle.EndIsland;
import amidst.mojangapi.world.oracle.end.EndIslandList;
import amidst.mojangapi.world.oracle.end.LargeEndIsland;
import amidst.mojangapi.world.oracle.end.SmallEndIsland;

@ThreadSafe
public class TheEndColorProvider implements ColorProvider {
Expand All @@ -31,8 +33,8 @@ public int getColorAt(Dimension dimension, Fragment fragment, long cornerX, long
long xAsQuarter = cornerX + x;
long yAsQuarter = cornerY + y;
return getColorAt(
(int) (xAsQuarter << 2),
(int) (yAsQuarter << 2),
xAsQuarter << 2,
yAsQuarter << 2,
xAsQuarter >> 2,
yAsQuarter >> 2,
(int) (x % TEXTURES_WIDTH),
Expand All @@ -41,26 +43,27 @@ public int getColorAt(Dimension dimension, Fragment fragment, long cornerX, long
}

private int getColorAt(
int x,
int y,
long x,
long y,
long chunkX,
long chunkY,
int textureX,
int textureY,
List<EndIsland> endIslands) {
// Determine whether this
EndIslandList endIslands) {

float maxInfluence = getMaxInfluence(x, y, endIslands);
if (maxInfluence >= INFLUENCE_FADE_START) {
// Draw endstone island
return getEndStoneTextureAt(textureX, textureY);
} else {
return getFadingColorAt(chunkX, chunkY, textureX, textureY, maxInfluence);
// Draw fade and small islands
return getOuterColorAt(x, y, chunkX, chunkY, textureX, textureY, maxInfluence, endIslands);
}
}

private float getMaxInfluence(int x, int y, List<EndIsland> endIslands) {
private float getMaxInfluence(long x, long y, EndIslandList endIslands) {
float result = -100.0f;
for (EndIsland island : endIslands) {
for (LargeEndIsland island : endIslands.getLargeIslands()) {
float influence = island.influenceAtBlock(x, y);
if (result < influence) {
result = influence;
Expand All @@ -69,35 +72,68 @@ private float getMaxInfluence(int x, int y, List<EndIsland> endIslands) {
return result;
}

private int getFadingColorAt(long chunkX, long chunkY, int textureX, int textureY, float maxInfluence) {
private int getOuterColorAt(
long x,
long y,
long chunkX,
long chunkY,
int textureX,
int textureY,
float maxInfluence,
EndIslandList endIslands) {
int result = VOID_TRANSPARENT_BLACK;
if (showRockyShores(chunkX, chunkY)) {

// The small islands list is null if the version doesn't support them
if (endIslands.getSmallIslands() != null) {
// Small islands can leak into other biomes if they spawn close enough, so we want to set this to when large islands start fading so they merge smoothly
if(maxInfluence <= INFLUENCE_FADE_START) {
result = getSmallIslandSSAAPixel(x, y, textureX, textureY, endIslands.getSmallIslands());
}
} else if (showOldRockyShores(chunkX, chunkY)) {
result = getRockyShoresTextureAt(textureX, textureY);
}

if (maxInfluence > INFLUENCE_FADE_FINISH) {
// Fade out the endstone - this is the edge of an island
int pixelAlpha = result >>> 24;
int fadingIslandAlpha = getFadingIslandAlpha(maxInfluence);
if (fadingIslandAlpha > pixelAlpha) {
// favor the island pixel instead of the rocky shores pixel
// (Should look perfect without needing to blend, because
// rocky shore is still endstone texture)
return getFadedEndStoneTextureAt(textureX, textureY, fadingIslandAlpha);
}
int pixelAlpha = (result >>> 24) + getFadingIslandAlpha(maxInfluence);
// Add alphas together to blend
return getFadedEndStoneTextureAt(textureX, textureY, pixelAlpha);
}
return result;
}

/**
* Determine if the chunk may contain miniature islands.
*/
private boolean showRockyShores(long chunkX, long chunkY) {
return (chunkX * chunkX + chunkY * chunkY) > 4096;

private static final double ALPHA_INCREMENT = 63.75d;
private static final int[] NEIGHBORING_PIXEL_TABLE = {
0, 0,
1, 0,
0, 1,
1, 1
};

// Anti-aliased pixel through taking 4 samples and blending them
private int getSmallIslandSSAAPixel(long x, long y, int textureX, int textureY, List<SmallEndIsland> smallIslands) {
double alpha = 0;
for(SmallEndIsland smallIsland : smallIslands) {
for(int i = 0; i <= 3; i++) {
if(smallIsland.isOnIsland(x + NEIGHBORING_PIXEL_TABLE[(i * 2)], y + NEIGHBORING_PIXEL_TABLE[(i * 2) + 1])) {
alpha += ALPHA_INCREMENT;
}
}
}

return alpha == 0 ? VOID_TRANSPARENT_BLACK : getFadedEndStoneTextureAt(textureX, textureY, (int) alpha);
}

private int getFadingIslandAlpha(float maxInfluence) {
return 255 - (int) (255 * (INFLUENCE_FADE_START - maxInfluence) / INFLUENCE_FADE_RANGE);
}

/**
* Determine whether to show the rocky shores texture.
*/
private boolean showOldRockyShores(long chunkX, long chunkY) {
return (chunkX * chunkX + chunkY * chunkY) > 4096L;
}

private int getEndStoneTextureAt(int textureX, int textureY) {
return TEXTURES.getRGB(textureX, textureY);
Expand All @@ -108,12 +144,14 @@ private int getEndStoneTextureAt(int textureX, int textureY) {
* from the world seed, like chorus plants they are decorations whose PRNG
* state depends on the order chunks are created/explored in. This makes me
* sad :( Let's use a symbolic texture, since we can't plot them properly.
*
* EDIT: This isn't true past 1.13, they can be generated from the seed.
*/
private int getRockyShoresTextureAt(int textureX, int textureY) {
return TEXTURES.getRGB(textureX, textureY + TEXTURES_HEIGHT);
}

private int getFadedEndStoneTextureAt(int textureX, int textureY, int alpha) {
return (getEndStoneTextureAt(textureX, textureY) & 0x00FFFFFF) | (alpha << 24);
return (getEndStoneTextureAt(textureX, textureY) & 0x00FFFFFF) | (Math.min(alpha, 0xFF) << 24);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
import amidst.documentation.CalledOnlyBy;
import amidst.documentation.Immutable;
import amidst.fragment.Fragment;
import amidst.mojangapi.world.oracle.end.EndIslandList;

@Immutable
public class EndIslandsConstructor implements FragmentConstructor {
@CalledOnlyBy(AmidstThread.EDT)
@Override
public void construct(Fragment fragment) {
fragment.setEndIslands(Collections.emptyList());
fragment.setEndIslands(new EndIslandList(Collections.emptyList(), Collections.emptyList()));
}
}
7 changes: 5 additions & 2 deletions src/main/java/amidst/fragment/layer/LayerBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ private List<LayerDeclaration> createDeclarations(AmidstSettings settings, List<
declare(settings, declarations, enabledLayers, LayerIds.OCEAN_FEATURES, Dimension.OVERWORLD, false, settings.showOceanFeatures);
declare(settings, declarations, enabledLayers, LayerIds.NETHER_FEATURES, Dimension.OVERWORLD, false, settings.showNetherFortresses);
declare(settings, declarations, enabledLayers, LayerIds.END_CITY, Dimension.END, false, settings.showEndCities);
declare(settings, declarations, enabledLayers, LayerIds.END_GATEWAY, Dimension.END, false, settings.showEndGateways);
// @formatter:on
return Collections.unmodifiableList(Arrays.asList(declarations));
}
Expand Down Expand Up @@ -146,7 +147,8 @@ private Iterable<FragmentLoader> createLoaders(
new WorldIconLoader<>(declarations.get(LayerIds.WOODLAND_MANSION),world.getWoodlandMansionProducer()),
new WorldIconLoader<>(declarations.get(LayerIds.OCEAN_FEATURES), world.getOceanFeaturesProducer()),
new WorldIconLoader<>(declarations.get(LayerIds.NETHER_FEATURES), world.getNetherFortressProducer()),
new WorldIconLoader<>(declarations.get(LayerIds.END_CITY), world.getEndCityProducer(), Fragment::getEndIslands)
new WorldIconLoader<>(declarations.get(LayerIds.END_CITY), world.getEndCityProducer(), Fragment::getLargeEndIslands),
new WorldIconLoader<>(declarations.get(LayerIds.END_GATEWAY), world.getEndGatewayProducer(), Fragment::getEndIslands)
));
// @formatter:on
}
Expand Down Expand Up @@ -176,7 +178,8 @@ private Iterable<FragmentDrawer> createDrawers(
new WorldIconDrawer(declarations.get(LayerIds.WOODLAND_MANSION),zoom, worldIconSelection, settings.useHybridScaling),
new WorldIconDrawer(declarations.get(LayerIds.OCEAN_FEATURES), zoom, worldIconSelection, settings.useHybridScaling),
new WorldIconDrawer(declarations.get(LayerIds.NETHER_FEATURES), zoom, worldIconSelection, settings.useHybridScaling),
new WorldIconDrawer(declarations.get(LayerIds.END_CITY), zoom, worldIconSelection, settings.useHybridScaling)
new WorldIconDrawer(declarations.get(LayerIds.END_CITY), zoom, worldIconSelection, settings.useHybridScaling),
new WorldIconDrawer(declarations.get(LayerIds.END_GATEWAY), zoom, worldIconSelection, settings.useHybridScaling)
));
// @formatter:on
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/amidst/fragment/layer/LayerIds.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class LayerIds {
public static final int OCEAN_FEATURES = 14;
public static final int NETHER_FEATURES = 15;
public static final int END_CITY = 16;
public static final int NUMBER_OF_LAYERS = 17;
public static final int END_GATEWAY = 17;
public static final int NUMBER_OF_LAYERS = 18;
// @formatter:on
}
8 changes: 3 additions & 5 deletions src/main/java/amidst/fragment/loader/EndIslandsLoader.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package amidst.fragment.loader;

import java.util.List;

import amidst.documentation.AmidstThread;
import amidst.documentation.CalledByAny;
import amidst.documentation.CalledOnlyBy;
Expand All @@ -10,8 +8,8 @@
import amidst.fragment.layer.LayerDeclaration;
import amidst.mojangapi.world.Dimension;
import amidst.mojangapi.world.coordinates.CoordinatesInWorld;
import amidst.mojangapi.world.oracle.EndIsland;
import amidst.mojangapi.world.oracle.EndIslandOracle;
import amidst.mojangapi.world.oracle.end.EndIslandList;
import amidst.mojangapi.world.oracle.end.EndIslandOracle;

//TODO: use longs?
@NotThreadSafe
Expand Down Expand Up @@ -42,7 +40,7 @@ private void doLoad(Fragment fragment) {
}

@CalledOnlyBy(AmidstThread.FRAGMENT_LOADER)
private List<EndIsland> getEndIslands(CoordinatesInWorld corner) {
private EndIslandList getEndIslands(CoordinatesInWorld corner) {
return endIslandOracle.getAt(corner);
}
}
10 changes: 9 additions & 1 deletion src/main/java/amidst/gui/main/menu/LayersMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private void createOverworldAndEndLayers(Dimension dimension) {
createOverworldLayers(dimension);
menu.addSeparator();
Menus.radio( menu, dimensionSetting, group, Dimension.END, MenuShortcuts.DISPLAY_DIMENSION_END);
endLayer( settings.showEndCities, "End City Icons", getIcon("end_city.png"), MenuShortcuts.SHOW_END_CITIES, dimension, LayerIds.END_CITY);
createEndLayers(dimension);
// @formatter:on
}

Expand All @@ -97,6 +97,14 @@ private void createOverworldLayers(Dimension dimension) {
overworldLayer(settings.showNetherFortresses, "Nether Features Icons", getIcon("nether_fortress.png"), MenuShortcuts.SHOW_NETHER_FEATURES, dimension, LayerIds.NETHER_FEATURES);
// @formatter:on
}

@CalledOnlyBy(AmidstThread.EDT)
private void createEndLayers(Dimension dimension) {
// @formatter:off
endLayer( settings.showEndCities, "End City Icons", getIcon("end_city.png"), MenuShortcuts.SHOW_END_CITIES, dimension, LayerIds.END_CITY);
endLayer( settings.showEndGateways, "End Gateway Icons", getIcon("end_gateway.png"), MenuShortcuts.SHOW_END_GATEWAYS, dimension, LayerIds.END_GATEWAY);
// @formatter:on
}

@CalledOnlyBy(AmidstThread.EDT)
private void createAllDimensions() {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/amidst/gui/main/menu/MenuShortcuts.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public enum MenuShortcuts implements MenuShortcut {
// It's okay to duplicate the Overworld layers shortcuts here, because
// the End layers will never be active at the same time.
SHOW_END_CITIES("menu 1"),
SHOW_END_GATEWAYS("menu 2"),

SHOW_GRID("menu G"),
SHOW_PLAYERS("menu P"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private static List<Widget> createWidgets(
new SeedAndWorldTypeWidget( CornerAnchorPoint.TOP_LEFT, worldOptions.getWorldSeed(), worldOptions.getWorldType()),
new SelectedIconWidget( CornerAnchorPoint.TOP_LEFT, worldIconSelection),
debugWidget,
new CursorInformationWidget( CornerAnchorPoint.TOP_RIGHT, graph, translator, settings.dimension, world.getBiomeList()),
new CursorInformationWidget( CornerAnchorPoint.TOP_RIGHT, graph, translator, settings.dimension, world.getBiomeList()),
biomeToggleWidget,
new BiomeExporterProgressWidget(CornerAnchorPoint.BOTTOM_RIGHT, progressEntrySupplier, -20, settings.showDebug, debugWidget, biomeToggleWidget.getWidth()),
biomeWidget
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import amidst.mojangapi.world.biome.BiomeList;
import amidst.mojangapi.world.coordinates.CoordinatesInWorld;
import amidst.mojangapi.world.coordinates.Resolution;
import amidst.mojangapi.world.oracle.end.EndIslandOracle;
import amidst.mojangapi.world.versionfeatures.DefaultBiomes;
import amidst.settings.Setting;

Expand Down Expand Up @@ -61,12 +62,26 @@ private String getBiomeNameAt(CoordinatesInWorld coordinates) {
if (dimension.equals(Dimension.OVERWORLD)) {
return getOverworldBiomeNameAt(coordinates);
} else if (dimension.equals(Dimension.END)) {
return biomeList.getByIdOrNull(DefaultBiomes.theEnd).getName();
return getEndBiomeNameAt(coordinates);
} else {
AmidstLogger.warn("unsupported dimension");
return UNKNOWN_BIOME_NAME;
}
}

public String getEndBiomeNameAt(CoordinatesInWorld coordinates) {
Fragment fragment = graph.getFragmentAt(coordinates);
if (fragment != null && fragment.isLoaded()) {
Biome biome = biomeList.getByIdOrNull(EndIslandOracle.getBiomeAtBlock(coordinates.getX(), coordinates.getY(), graph.getFragmentAt(coordinates).getLargeEndIslands()));

if (biome != null) {
return biome.getName();
} else {
return biomeList.getByIdOrNull(DefaultBiomes.theEnd).getName();
}
}
return UNKNOWN_BIOME_NAME;
}

@CalledOnlyBy(AmidstThread.EDT)
private String getOverworldBiomeNameAt(CoordinatesInWorld coordinates) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ public enum RecognisedVersion {
_1_11 ("1.11", "rroumhkfph[Llw;mt[J[[Jmp"), // matches the launcher version id: 1.11 1.11-pre1
_16w44a ("16w44a", "rqotmgkfpg[Llv;ms[J[[Jmo"), // matches the launcher version id: 16w44a
_16w43a ("16w43a", "rpotmgkfpg[Llv;ms[J[[Jmo"), // matches the launcher version id: 16w43a 16w42a 16w41a 16w40a 16w39c
_16w39a ("16w39a", "rnotmgkfpg[Llv;ms[J[[Jmo"), // matches the launcher version id: 16w39a
_16w38a ("16w38a", "rlosmfkepf[Llu;mr[J[[Jmn"), // matches the launcher version id: 16w38a
_16w36a ("16w36a", "rkosmfkepf[Llu;mr[J[[Jmn"), // matches the launcher version id: 16w36a
_16w35a ("16w35a", "rjosmfkepf[Llu;mr[J[[Jmn"), // matches the launcher version id: 16w35a 16w33a 16w32b
Expand Down
Loading