Skip to content

Commit

Permalink
marker clipping & village priority
Browse files Browse the repository at this point in the history
  • Loading branch information
sisby-folk committed May 24, 2024
1 parent b33f63a commit a7bc076
Show file tree
Hide file tree
Showing 236 changed files with 521 additions and 267 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ org.gradle.configureondemand=true
# Enable advanced multi-module optimizations (share tiny-remaper instance between projects)
fabric.loom.multiProjectOptimisation=true
# Mod Properties
baseVersion = 2.7.3
baseVersion = 2.8.0
defaultBranch = 1.20
branch = 1.20
18 changes: 9 additions & 9 deletions src/main/java/folk/sisby/antique_atlas/AntiqueAtlasConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,40 +24,40 @@ public enum FallbackHandling {

@Comment("Whether to display the map in full-screen")
@Comment("The background is slightly less stylish, but more tiles are shown at once")
public final Boolean fullscreen = true;
public Boolean fullscreen = true;

@Comment("How to depict player death locations.")
public final GraveStyle graveStyle = GraveStyle.EUPHEMISMS;
public GraveStyle graveStyle = GraveStyle.EUPHEMISMS;

@Comment("The maximum number of chunks to represent as a tile, as a power of 2")
@Comment("Effectively the 'minimum zoom'")
@Comment("0: 1x1 chunk = 1 tile | 6: 64x64 chunks = 1 tile")
@IntegerRange(min = 0, max = 6)
public final Integer maxTileChunks = 5;
public Integer maxTileChunks = 5;

@Comment("The maximum size to render a tile at, as a power of 2 multiplier")
@Comment("Effectively the 'maximum zoom'")
@Comment("0: 1 tile = 16x16 | 3: 1 tile = 128x128")
@IntegerRange(min = 0, max = 3)
public final Integer maxTilePixels = 1;
public Integer maxTilePixels = 1;

@Comment("The effective GUI scale for tiles and markers - independent of the overall GUI scale.")
@Comment("0 will match your GUI scale - pixels will be the same size as the background & buttons")
@Comment("-1 will use half your GUI scale, rounding up.")
@Comment("-2 will use half your GUI scale, rounding down.")
@IntegerRange(min = -2, max = 10)
public final Integer mapScale = 0;
public Integer mapScale = 0;

@Comment("The maximum number of chunks to load onto the map per tick after entering a world")
public final Integer chunkTickLimit = 100;
public Integer chunkTickLimit = 100;

@Comment("How to handle biomes that aren't in any minecraft, conventional, or forge biome tags")
public final FallbackHandling fallbackFailHandling = FallbackHandling.MISSING;
public FallbackHandling fallbackFailHandling = FallbackHandling.MISSING;

@Comment("Whether to show debug information about hovered tiles and markers")
public final Boolean debugRender = false;
public Boolean debugRender = false;

public final Map<String, Boolean> structureMarkers = ValueMap.builder(true)
public Map<String, Boolean> structureMarkers = ValueMap.builder(true)
.put("minecraft:type/end_city", false)
.build();
}
12 changes: 6 additions & 6 deletions src/main/java/folk/sisby/antique_atlas/MarkerTexture.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,20 @@
import net.minecraft.util.math.MathHelper;
import org.joml.Vector2d;

public record MarkerTexture(Identifier id, Identifier accentId, int offsetX, int offsetY, int textureWidth, int textureHeight, int mipLevels) {
public record MarkerTexture(Identifier id, Identifier accentId, int offsetX, int offsetY, int textureWidth, int textureHeight, int mipLevels, int nearClip, int farClip) {
private static Identifier idToTexture(Identifier id) {
return id.withPrefixedPath("textures/atlas/marker/").withSuffixedPath(".png");
}

public static MarkerTexture ofId(Identifier id, int offsetX, int offsetY, int width, int height, int mipLevels, boolean accent) {
return new MarkerTexture(idToTexture(id), accent ? idToTexture(id.withSuffixedPath("_accent")) : null, offsetX, offsetY, width, height, mipLevels);
public static MarkerTexture ofId(Identifier id, int offsetX, int offsetY, int width, int height, int mipLevels, int nearClip, int farClip, boolean accent) {
return new MarkerTexture(idToTexture(id), accent ? idToTexture(id.withSuffixedPath("_accent")) : null, offsetX, offsetY, width, height, mipLevels, nearClip, farClip);
}

public static MarkerTexture centered(Identifier id, int width, int height, int mipLevels, boolean accent) {
return ofId(id, -width / 2, -height / 2, width, height, mipLevels, accent);
public static MarkerTexture centered(Identifier id, int width, int height, int mipLevels, int nearClip, int farClip, boolean accent) {
return ofId(id, -width / 2, -height / 2, width, height, mipLevels, nearClip, farClip, accent);
}

public static final MarkerTexture DEFAULT = centered(AntiqueAtlas.id("custom/point"), 32, 32, 0, true);
public static final MarkerTexture DEFAULT = centered(AntiqueAtlas.id("custom/point"), 32, 32, 0, 1, Integer.MAX_VALUE, true);

public Identifier keyId() {
return new Identifier(id.getNamespace(), id.getPath().substring("textures/atlas/marker/".length(), id.getPath().length() - 4));
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/folk/sisby/antique_atlas/WorldAtlasData.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,12 @@ public Map<Landmark<?>, MarkerTexture> getEditableLandmarks() {
return map;
}

public Map<Landmark<?>, MarkerTexture> getAllMarkers() {
public Map<Landmark<?>, MarkerTexture> getAllMarkers(int tileChunks) {
Map<Landmark<?>, MarkerTexture> map = new HashMap<>();
landmarkMarkers.forEach((type, landmarks) -> landmarks.forEach((pos, pair) -> map.put(pair.left(), pair.right())));
map.putAll(structureMarkers);
structureMarkers.forEach((landmark, texture) -> {
if (tileChunks >= texture.nearClip() && tileChunks <= texture.farClip()) map.put(landmark, texture);
});
return map;
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/folk/sisby/antique_atlas/gui/AtlasScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ public void render(DrawContext context, int mouseX, int mouseY, float par3) {
if (!state.is(HIDING_MARKERS)) {
if (isMouseOverMap) {
double bestDistance = Double.MAX_VALUE;
for (Map.Entry<Landmark<?>, MarkerTexture> entry : worldAtlasData.getAllMarkers().entrySet()) {
for (Map.Entry<Landmark<?>, MarkerTexture> entry : worldAtlasData.getAllMarkers(tileChunks).entrySet()) {
Landmark<?> landmark = entry.getKey();
MarkerTexture texture = entry.getValue();
double markerX = worldXToScreenX(landmark.pos().getX());
Expand All @@ -641,7 +641,7 @@ public void render(DrawContext context, int mouseX, int mouseY, float par3) {
}
}
}
worldAtlasData.getAllMarkers().forEach((landmark, texture) -> {
worldAtlasData.getAllMarkers(tileChunks).forEach((landmark, texture) -> {
renderMarker(context, landmark, texture, WorldAtlasData.landmarkIsEditable(landmark), hoveredLandmark == landmark && markerModal.getParent() == null, markerScale);
});
}
Expand All @@ -667,7 +667,7 @@ public void render(DrawContext context, int mouseX, int mouseY, float par3) {
List<PlayerSummary> orderedFriends = new ArrayList<>(friends.values());
if (playerSummary != null) orderedFriends.add(playerSummary);
for (PlayerSummary friend : orderedFriends) {
if (state.is(HIDING_MARKERS)) continue;
if (state.is(HIDING_MARKERS) && (!playerBookmark.isSelected() || friend != playerSummary)) continue;
renderPlayer(context, friend, 1, hoveredFriend == friend && markerModal.getParent() == null);
}
context.getMatrices().pop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,17 @@ public Identifier getFabricId() {
return ID;
}

public record MarkerTextureMeta(Optional<Integer> textureWidth, Optional<Integer> textureHeight, Optional<Integer> mipLevels, Optional<Integer> offsetX, Optional<Integer> offsetY) {
public static final MarkerTextureMeta DEFAULT = new MarkerTextureMeta(Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty());
public record MarkerTextureMeta(Optional<Integer> textureWidth, Optional<Integer> textureHeight, Optional<Integer> mipLevels, Optional<Integer> offsetX, Optional<Integer> offsetY, Optional<Integer> nearClip, Optional<Integer> farClip) {
public static final MarkerTextureMeta DEFAULT = new MarkerTextureMeta(Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty(), Optional.empty());

public static final Codec<MarkerTextureMeta> CODEC = RecordCodecBuilder.create(instance -> instance.group(
Codec.INT.optionalFieldOf("textureWidth").forGetter(MarkerTextureMeta::textureWidth),
Codec.INT.optionalFieldOf("textureHeight").forGetter(MarkerTextureMeta::textureHeight),
Codec.INT.optionalFieldOf("mipLevels").forGetter(MarkerTextureMeta::mipLevels),
Codec.INT.optionalFieldOf("offsetX").forGetter(MarkerTextureMeta::offsetX),
Codec.INT.optionalFieldOf("offsetY").forGetter(MarkerTextureMeta::offsetY)
Codec.INT.optionalFieldOf("offsetY").forGetter(MarkerTextureMeta::offsetY),
Codec.INT.optionalFieldOf("nearClip").forGetter(MarkerTextureMeta::nearClip),
Codec.INT.optionalFieldOf("farClip").forGetter(MarkerTextureMeta::farClip)
).apply(instance, MarkerTextureMeta::new));

public static final ResourceMetadataReader<MarkerTextureMeta> METADATA = new CodecUtil.CodecResourceMetadataSerializer<>(CODEC, AntiqueAtlas.id("marker"));
Expand All @@ -116,7 +118,9 @@ public MarkerTexture build(Identifier id, boolean accent) {
int mipLevels = this.mipLevels.orElse(0);
int offsetX = this.offsetX.orElse(-textureWidth / 2);
int offsetY = this.offsetY.orElse(-textureHeight / 2);
return MarkerTexture.ofId(id, offsetX, offsetY, textureWidth, textureHeight, mipLevels, accent);
int nearClip = this.nearClip.orElse(1);
int farClip = this.farClip.orElse(Integer.MAX_VALUE);
return MarkerTexture.ofId(id, offsetX, offsetY, textureWidth, textureHeight, mipLevels, nearClip, farClip, accent);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ protected void apply(Map<Identifier, JsonElement> prepared, ResourceManager mana
JsonObject fileJson = fileEntry.getValue().getAsJsonObject();
if (fileJson.has("textures")) {
JsonElement textureJson = fileJson.get("textures");
int priority = fileJson.has("priority") ? fileJson.get("priority").getAsInt() : Integer.MAX_VALUE;
int priority = fileJson.has("priority") ? fileJson.get("priority").getAsInt() : 999;
List<TileTexture> defaultTextures = resolveTextureJson(textures, textureJson);
if (defaultTextures != null) {
StructureTileProvider provider = new StructureTileProvider(id, priority, defaultTextures);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"antique_atlas:marker": {
"nearClip": 2
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
{
"antique_atlas:tiling": {
"borderType": "inner",
"tags": [
"antique_atlas:small_land_structures"
"antique_atlas:small_land_structures",
"antique_atlas:village_path_accessible"
],
"tilesTo": [
"#antique_atlas:village_path"
]
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
{
"antique_atlas:tiling": {
"borderType": "inner",
"tags": [
"antique_atlas:small_land_structures"
"antique_atlas:small_land_structures",
"antique_atlas:village_path_accessible"
],
"tilesTo": [
"#antique_atlas:village_path"
]
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
{
"antique_atlas:tiling": {
"borderType": "inner",
"tags": [
"antique_atlas:small_land_structures"
"antique_atlas:small_land_structures",
"antique_atlas:village_path_accessible"
],
"tilesTo": [
"#antique_atlas:village_path"
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
"borderType": "inner",
"tags": [
"antique_atlas:small_land_structures",
"antique_atlas:village_path",
"antique_atlas:village_path_accessible"
],
"tilesTo": [
"#antique_atlas:village_path"
"#antique_atlas:village_path",
"#antique_atlas:village_path_accessible"
]
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
{
"antique_atlas:tiling": {
"borderType": "inner",
"tags": [
"antique_atlas:small_land_structures"
"antique_atlas:small_land_structures",
"antique_atlas:village_path_accessible"
],
"tilesTo": [
"#antique_atlas:village_path"
]
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
{
"antique_atlas:tiling": {
"borderType": "inner",
"tags": [
"antique_atlas:small_land_structures"
"antique_atlas:small_land_structures",
"antique_atlas:village_path_accessible"
],
"tilesTo": [
"#antique_atlas:village_path"
]
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
{
"antique_atlas:tiling": {
"borderType": "inner",
"tags": [
"antique_atlas:small_land_structures"
"antique_atlas:small_land_structures",
"antique_atlas:village_path_accessible"
],
"tilesTo": [
"#antique_atlas:village_path"
]
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"textures": "antique_atlas:structure/village/plains/lamp"
}
"textures": "antique_atlas:structure/village/plains/lamp",
"priority": 1100
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"textures": "antique_atlas:structure/village/plains/temple"
"textures": "antique_atlas:structure/village/plains/temple",
"priority": 800
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"textures": "antique_atlas:structure/village/plains/temple"
"textures": "antique_atlas:structure/village/plains/temple",
"priority": 800
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"textures": "antique_atlas:structure/village/desert/weaponsmith"
}
"textures": "antique_atlas:structure/village/desert/weaponsmith",
"priority": 800
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"textures": "antique_atlas:structure/village/desert/weaponsmith"
}
"textures": "antique_atlas:structure/village/desert/weaponsmith",
"priority": 800
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"textures": "antique_atlas:structure/village/path_crossroad"
"textures": "antique_atlas:structure/village/path_crossroad",
"priority": 1050
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"textures": "antique_atlas:structure/village/path_crossroad"
"textures": "antique_atlas:structure/village/path_crossroad",
"priority": 1050
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"textures": "antique_atlas:structure/village/path_crossroad"
"textures": "antique_atlas:structure/village/path_crossroad",
"priority": 1050
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"textures": "antique_atlas:structure/village/path_crossroad"
"textures": "antique_atlas:structure/village/path_crossroad",
"priority": 1050
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"textures": "antique_atlas:structure/village/path_crossroad"
"textures": "antique_atlas:structure/village/path_crossroad",
"priority": 1050
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"textures": "antique_atlas:structure/village/path_crossroad"
"textures": "antique_atlas:structure/village/path_crossroad",
"priority": 1050
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"textures": "antique_atlas:structure/village/path_crossroad"
"textures": "antique_atlas:structure/village/path_crossroad",
"priority": 1050
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"textures": {
"path_straight_horizontal": "antique_atlas:structure/village/path_horizontal",
"path_straight_vertical": "antique_atlas:structure/village/path_vertical"
}
},
"priority": 1050
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"textures": {
"path_straight_horizontal": "antique_atlas:structure/village/path_horizontal",
"path_straight_vertical": "antique_atlas:structure/village/path_vertical"
}
},
"priority": 1060
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"textures": {
"path_straight_horizontal": "antique_atlas:structure/village/path_horizontal",
"path_straight_vertical": "antique_atlas:structure/village/path_vertical"
}
},
"priority": 1060
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"textures": "antique_atlas:structure/village/path_crossroad"
"textures": "antique_atlas:structure/village/path_crossroad",
"priority": 1050
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"textures": "antique_atlas:structure/village/plains/meeting_point"
"textures": "antique_atlas:structure/village/plains/meeting_point",
"priority": 900
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"textures": "antique_atlas:structure/village/plains/meeting_point"
"textures": "antique_atlas:structure/village/plains/meeting_point",
"priority": 900
}
Loading

0 comments on commit a7bc076

Please sign in to comment.