Skip to content

Commit

Permalink
fix player coloring
Browse files Browse the repository at this point in the history
  • Loading branch information
sisby-folk committed Jul 8, 2024
1 parent 47047a4 commit 553e2b4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 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.9.10
baseVersion = 2.9.11
defaultBranch = 1.20
branch = 1.20
2 changes: 1 addition & 1 deletion libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fl = "0.15.0"
yarn = "1.20.1+build.10"
fapi = "0.83.0+1.20.1"
kaleidoConfig = "0.3.1+1.3.1"
surveyor = "0.6.5+1.20"
surveyor = "0.6.10+1.20"

[plugins]
loom = { id = "fabric-loom", version.ref = "loom" }
Expand Down
19 changes: 10 additions & 9 deletions src/main/java/folk/sisby/antique_atlas/gui/AtlasScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@

import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
Expand Down Expand Up @@ -670,12 +671,12 @@ public void render(DrawContext context, int mouseX, int mouseY, float par3) {
context.getMatrices().push();
context.getMatrices().translate(getGuiX(), getGuiY(), 0);
PlayerSummary playerSummary = friends.remove(SurveyorClient.getClientUuid());
List<PlayerSummary> orderedFriends = new ArrayList<>(friends.values());
if (playerSummary != null) orderedFriends.add(playerSummary);
for (PlayerSummary friend : orderedFriends) {
if (state.is(HIDING_MARKERS) && (!playerBookmark.isSelected() || friend != playerSummary)) continue;
renderPlayer(context, friend, 1, hoveredFriend == friend && markerModal.getParent() == null);
}
Map<UUID, PlayerSummary> orderedFriends = new LinkedHashMap<>(friends);
if (playerSummary != null) orderedFriends.put(SurveyorClient.getClientUuid(), playerSummary);
orderedFriends.forEach((uuid, friend) -> {
if (state.is(HIDING_MARKERS) && (!playerBookmark.isSelected() || friend != playerSummary)) return;
renderPlayer(context, friend, 1, hoveredFriend == friend && markerModal.getParent() == null, friend == playerSummary);
});
context.getMatrices().pop();

super.render(context, mouseX, mouseY, par3);
Expand Down Expand Up @@ -714,7 +715,7 @@ public void render(DrawContext context, int mouseX, int mouseY, float par3) {
}
}

private void renderPlayer(DrawContext context, PlayerSummary player, float iconScale, boolean hovering) {
private void renderPlayer(DrawContext context, PlayerSummary player, float iconScale, boolean hovering, boolean self) {
double playerOffsetX = worldXToScreenX(player.pos().getX()) - getGuiX();
double playerOffsetY = worldZToScreenY(player.pos().getZ()) - getGuiY();

Expand All @@ -723,15 +724,15 @@ private void renderPlayer(DrawContext context, PlayerSummary player, float iconS

// Draw the icon:
float tint = (player.online() ? 1 : 0.5f) * (hovering ? 0.9f : 1);
float greenTint = player.username().equals(this.player.getGameProfile().getName()) ? 1 : 0.7f;
float greenTint = self ? 1 : 0.7f;
RenderSystem.setShaderColor(tint, tint * greenTint, tint, state.is(PLACING_MARKER) ? 0.5f : 1);
float playerRotation = (float) Math.round(player.yaw() / 360f * PLAYER_ROTATION_STEPS) / PLAYER_ROTATION_STEPS * 360f;

DrawUtil.drawCenteredWithRotation(context, PLAYER, playerOffsetX, playerOffsetY, iconScale, PLAYER_ICON_WIDTH, PLAYER_ICON_HEIGHT, playerRotation);

RenderSystem.setShaderColor(1, 1, 1, 1);

if (hovering && !player.username().equals(this.player.getGameProfile().getName())) {
if (hovering && !self) {
context.drawTooltip(textRenderer, Text.literal(player.username()).formatted(player.online() ? Formatting.LIGHT_PURPLE : Formatting.GRAY), (int) getMouseX() - getGuiX(), (int) getMouseY() - getGuiY());
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/folk/sisby/antique_atlas/util/DrawUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class DrawUtil {
public static void drawCenteredWithRotation(DrawContext context, Identifier texture, double x, double y, float scale, int textureWidth, int textureHeight, float rotation) {
context.getMatrices().push();
context.getMatrices().translate(x, y, 0.0);
context.getMatrices().scale(scale, scale, 0.0F);
context.getMatrices().scale(scale, scale, 1.0F);
context.getMatrices().multiply(RotationAxis.POSITIVE_Z.rotationDegrees(180 + rotation));
context.getMatrices().translate(-textureWidth / 2f, -textureHeight / 2f, 0f);
context.drawTexture(texture, 0, 0, 0, 0, textureWidth, textureHeight, textureWidth, textureHeight);
Expand Down

0 comments on commit 553e2b4

Please sign in to comment.