Skip to content

Commit 6da6973

Browse files
authored
Merge pull request #4 from jumpcutfindo/1.21.6
feat: 1.21.6
2 parents f287a28 + 89891f4 commit 6da6973

31 files changed

Lines changed: 380 additions & 306 deletions

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id 'fabric-loom' version '1.10-SNAPSHOT'
2+
id 'fabric-loom' version "${loom_version}"
33
id 'maven-publish'
44
}
55

gradle.properties

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,19 @@ https.protocols=TLSv1.2,TLSv1.3
44
org.gradle.parallel=true
55
# Fabric Properties
66
# check these on https://fabricmc.net/develop
7-
minecraft_version=1.21.5
8-
yarn_mappings=1.21.5+build.1
9-
loader_version=0.16.13
7+
minecraft_version=1.21.6
8+
yarn_mappings=1.21.6+build.1
9+
loader_version=0.17.3
10+
loom_version=1.11-SNAPSHOT
1011
# Mod Properties
11-
mod_version=1.0.1-1.21.5
12+
mod_version=1.0.1-1.21.6
1213
maven_group=com.jumpcutfindo
1314
archives_base_name=onmymark
1415
# Dependencies
1516
# Fabric API
16-
fabric_version=0.119.9+1.21.5
17+
fabric_version=0.128.2+1.21.6
1718
# modmenu
18-
modmenu_version=14.0.0-rc.2
19+
modmenu_version=15.0.0-beta.3
1920
# owo-lib
2021
# https://maven.wispforest.io/io/wispforest/owo-lib/
21-
owo_version=0.12.21+1.21.5
22+
owo_version=0.12.21+1.21.6

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

src/main/java/com/jumpcutfindo/onmymark/OnMyMarkConfigModel.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
@Config(name = OnMyMarkMod.MOD_ID, wrapperName = "OnMyMarkConfig")
99
public class OnMyMarkConfigModel {
1010

11-
@SectionHeader("markerDrawingSection")
11+
@SectionHeader("markerPositionSection")
1212
@Sync(Option.SyncMode.NONE)
1313
public ClampType markerClampType = ClampType.DEFAULT_CLAMP_TYPE;
1414

@@ -20,7 +20,7 @@ public class OnMyMarkConfigModel {
2020
@Sync(Option.SyncMode.NONE)
2121
public int circleClampDiameter = ClampType.DEFAULT_OVAL_CLAMP_PADDING;
2222

23-
@SectionHeader("markerPointerSection")
23+
@SectionHeader("markerStyleSection")
2424

2525
@RangeConstraint(min = 0.60F, max = 1.00F)
2626
@Sync(Option.SyncMode.NONE)
@@ -34,6 +34,18 @@ public class OnMyMarkConfigModel {
3434
@Sync(Option.SyncMode.NONE)
3535
public int markerPointerHeight = MarkerRenderer.DEFAULT_POINTER_HEIGHT;
3636

37+
@Sync(Option.SyncMode.NONE)
38+
public boolean isIconTileVisible = true;
39+
40+
@Sync(Option.SyncMode.NONE)
41+
public boolean isPlayerHeadEnabled = true;
42+
43+
@RangeConstraint(min = 0.60F, max = 1.50F)
44+
@Sync(Option.SyncMode.NONE)
45+
public float playerHeadScale = 1.0F;
46+
47+
@SectionHeader("markerLifetimeSection")
48+
3749
@RangeConstraint(min = 1, max = 86400)
3850
@Sync(Option.SyncMode.OVERRIDE_CLIENT)
3951
public long blockMarkerLifetimeSecs = BlockMarkerRenderer.DEFAULT_LIFETIME_SECS;

src/main/java/com/jumpcutfindo/onmymark/client/OnMyMarkClient.java

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
package com.jumpcutfindo.onmymark.client;
22

33
import com.jumpcutfindo.onmymark.OnMyMarkMod;
4+
import com.jumpcutfindo.onmymark.client.graphics.OnMyMarkRenderer;
5+
import com.jumpcutfindo.onmymark.client.input.InputListener;
46
import com.jumpcutfindo.onmymark.client.marker.ClientMarkerManager;
57
import com.jumpcutfindo.onmymark.client.party.ClientPartyManager;
6-
import com.jumpcutfindo.onmymark.client.input.InputListener;
7-
import com.jumpcutfindo.onmymark.client.graphics.OnMyMarkRenderer;
88
import com.jumpcutfindo.onmymark.client.sounds.CustomSoundEvents;
99
import net.fabricmc.api.ClientModInitializer;
1010
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
1111
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents;
12-
import net.fabricmc.fabric.api.client.rendering.v1.HudLayerRegistrationCallback;
13-
import net.fabricmc.fabric.api.client.rendering.v1.IdentifiedLayer;
12+
import net.fabricmc.fabric.api.client.rendering.v1.hud.HudElementRegistry;
1413
import net.minecraft.client.MinecraftClient;
1514
import net.minecraft.util.Identifier;
1615

@@ -41,13 +40,7 @@ public void onInitializeClient() {
4140
}
4241

4342
private void registerRenderer() {
44-
HudLayerRegistrationCallback.EVENT.register(layeredDrawer ->
45-
layeredDrawer.attachLayerAfter(
46-
IdentifiedLayer.MISC_OVERLAYS,
47-
Identifier.of(OnMyMarkMod.MOD_ID, "render_overlay"),
48-
renderer::render
49-
)
50-
);
43+
HudElementRegistry.addLast(Identifier.of(OnMyMarkMod.MOD_ID, "render_overlay"), renderer::render);
5144
}
5245

5346
private void registerInputListener() {

src/main/java/com/jumpcutfindo/onmymark/client/graphics/markers/BlockMarkerRenderer.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ public void drawLabel(DrawContext drawContext, float screenX, float screenY, boo
3030
if (blockItem.isEmpty()) {
3131
super.drawLabel(drawContext, screenX, screenY, isOutlined);
3232
} else {
33-
34-
DrawUtils.drawItemOutlined(drawContext, blockItem, (int) screenX, (int) screenY, this.getPointerColor());
33+
DrawUtils.drawItemTiled(drawContext, blockItem, (int) screenX, (int) screenY, this.getPointerColor());
3534
}
3635

3736
}

src/main/java/com/jumpcutfindo/onmymark/client/graphics/markers/EntityMarkerRenderer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ public void drawLabel(DrawContext drawContext, float screenX, float screenY, boo
7373
Entity entity = this.entityMarker.entity();
7474

7575
if (entity instanceof ItemEntity item) {
76-
DrawUtils.drawItemOutlined(drawContext, item.getStack(), (int) screenX, (int) screenY, this.getPointerColor());
76+
DrawUtils.drawItemTiled(drawContext, item.getStack(), (int) screenX, (int) screenY, this.getPointerColor());
7777
drawContext.drawStackOverlay(MinecraftClient.getInstance().textRenderer, item.getStack(), (int) screenX, (int) screenY);
7878
} else if (entity instanceof VehicleEntity vehicle) {
79-
DrawUtils.drawItemOutlined(drawContext, ((VehicleEntityMixin) vehicle).asItem().getDefaultStack(), (int) screenX, (int) screenY, this.getPointerColor());
79+
DrawUtils.drawItemTiled(drawContext, ((VehicleEntityMixin) vehicle).asItem().getDefaultStack(), (int) screenX, (int) screenY, this.getPointerColor());
8080
} else {
8181
super.drawLabel(drawContext, screenX, screenY, isOutlined);
8282
}

src/main/java/com/jumpcutfindo/onmymark/client/graphics/markers/MarkerRenderer.java

Lines changed: 54 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@
33
import com.jumpcutfindo.onmymark.OnMyMarkMod;
44
import com.jumpcutfindo.onmymark.client.graphics.utils.DrawUtils;
55
import com.jumpcutfindo.onmymark.client.graphics.utils.RenderMath;
6+
import com.jumpcutfindo.onmymark.client.party.ClientPartyMember;
67
import com.jumpcutfindo.onmymark.marker.Marker;
78
import net.minecraft.client.MinecraftClient;
89
import net.minecraft.client.gui.DrawContext;
10+
import net.minecraft.client.gui.PlayerSkinDrawer;
11+
import net.minecraft.client.util.SkinTextures;
12+
import net.minecraft.util.Colors;
913
import net.minecraft.util.math.ColorHelper;
1014
import net.minecraft.util.math.MathHelper;
1115
import net.minecraft.util.math.Vec3d;
@@ -30,6 +34,8 @@ public abstract class MarkerRenderer {
3034
private boolean isClamped;
3135
private float clampWidth, clampHeight;
3236

37+
private final SkinTextures playerSkinTextures;
38+
3339
protected MarkerRenderer(MinecraftClient client, Marker marker, PointerShape pointerShape) {
3440
this.client = client;
3541
this.marker = marker;
@@ -40,6 +46,12 @@ protected MarkerRenderer(MinecraftClient client, Marker marker, PointerShape poi
4046
this.pointerShape = pointerShape;
4147

4248
this.creationTime = Instant.now();
49+
50+
this.playerSkinTextures = MinecraftClient.getInstance()
51+
.getSkinProvider()
52+
.getSkinTextures(
53+
((ClientPartyMember)marker.owner()).gameProfile()
54+
);
4355
}
4456

4557
public Vector4f screenPos() {
@@ -154,26 +166,37 @@ public void draw(DrawContext drawContext) {
154166
float pointerHeight = OnMyMarkMod.CONFIG.markerPointerHeight() * pointerSizeModifier;
155167
int pointerColor = ColorHelper.withAlpha((int) Math.min((float) existTimeMs / 20, 1.0F) * 255, this.getPointerColor());
156168

157-
if (this.isClamped) {
169+
// Calculate label width
170+
int labelWidth = this.getLabelWidth();
171+
int labelHeight = this.getLabelHeight();
172+
173+
float playerHeadScale = OnMyMarkMod.CONFIG.playerHeadScale();
158174

175+
if (this.isClamped) {
159176
// Draw edge pointer if the marker has been clamped
160177
this.drawEdgePointer(drawContext, pointerWidth, pointerHeight, pointerColor);
161178

162-
Vector2f iconPos = this.getClampedLabelPos(this.getLabelWidth(), this.getLabelHeight(), 16F + distanceLabelHeight * screenPosNormal.y);
163-
this.drawLabel(drawContext, iconPos.x(), iconPos.y(), true);
179+
Vector2f labelPos = this.getClampedLabelPos(labelWidth, labelHeight, 16F + distanceLabelHeight * screenPosNormal.y);
180+
181+
this.drawLabel(drawContext, labelPos.x(), labelPos.y(), true);
182+
this.drawDistanceLabel(drawContext, labelPos.x() + labelWidth / 2F - distanceLabelWidth / 2F, labelPos.y() + labelHeight + 4F, distanceLabelScale);
164183

165-
this.drawDistanceLabel(drawContext, iconPos.x() + getLabelWidth() / 2F - distanceLabelWidth / 2F, iconPos.y() + getLabelHeight() + 4F, distanceLabelScale);
184+
if (OnMyMarkMod.CONFIG.isPlayerHeadEnabled()) {
185+
this.drawPlayerHead(drawContext, labelPos.x() - 4F, labelPos.y() + labelHeight / 2F, playerHeadScale);
186+
}
166187
} else {
167188
// Draw pointer that points directly toward object
168-
169189
this.drawPointer(drawContext, pointerWidth, pointerHeight, pointerColor);
170190

171-
float screenX = screenPos.x() - this.getLabelWidth() / 2F;
172-
float screenY = screenPos.y() - OnMyMarkMod.CONFIG.markerPointerHeight() - getLabelHeight() - 4F;
191+
float screenX = screenPos.x() - labelWidth / 2F;
192+
float screenY = screenPos.y() - OnMyMarkMod.CONFIG.markerPointerHeight() - labelHeight - 4F;
173193

174194
this.drawLabel(drawContext, screenX, screenY, true);
175-
176195
this.drawDistanceLabel(drawContext, screenPos.x() - distanceLabelWidth / 2F, screenPos.y() - OnMyMarkMod.CONFIG.markerPointerHeight() - distanceLabelHeight - 24F, distanceLabelScale);
196+
197+
if (OnMyMarkMod.CONFIG.isPlayerHeadEnabled()) {
198+
this.drawPlayerHead(drawContext, screenX - 4F, screenY + labelHeight / 2F, playerHeadScale);
199+
}
177200
}
178201

179202
}
@@ -190,7 +213,7 @@ private void drawPointer(DrawContext drawContext, float width, float height, int
190213
float x3 = this.screenPos.x + width / 2F;
191214
float y3 = this.screenPos.y - height;
192215

193-
DrawUtils.drawTriangle(drawContext, x1, y1, x2, y2, x3, y3, color);
216+
DrawUtils.drawTriangle(drawContext, (int) x1, (int) y1, (int) x2, (int) y2, (int) x3, (int) y3, color);
194217
} else {
195218
float x2 = this.screenPos.x - width / 2F;
196219
float y2 = this.screenPos.y - height / 2F;
@@ -201,7 +224,7 @@ private void drawPointer(DrawContext drawContext, float width, float height, int
201224
float x4 = this.screenPos.x + width / 2F;
202225
float y4 = this.screenPos.y - height / 2F;
203226

204-
DrawUtils.drawQuad(drawContext, x1, y1, x2, y2, x3, y3, x4, y4, color);
227+
DrawUtils.drawQuad(drawContext, (int) x1, (int) y1, (int) x2, (int) y2, (int) x3, (int) y3, (int) x4, (int) y4, color);
205228
}
206229

207230
}
@@ -219,10 +242,21 @@ private String getDistanceLabelString() {
219242
}
220243

221244
private void drawDistanceLabel(DrawContext drawContext, float screenX, float screenY, float scale) {
222-
drawContext.getMatrices().push();
223-
drawContext.getMatrices().scale(scale, scale, scale);
224-
drawContext.drawText(this.client.textRenderer, getDistanceLabelString(), (int) (screenX / scale), (int) (screenY / scale), 0xFFFFFFFF, true);
225-
drawContext.getMatrices().pop();
245+
drawContext.getMatrices().pushMatrix();
246+
drawContext.getMatrices().scale(scale, scale);
247+
drawContext.drawText(this.client.textRenderer, getDistanceLabelString(), (int) (screenX / scale), (int) (screenY / scale), Colors.WHITE, true);
248+
drawContext.getMatrices().popMatrix();
249+
}
250+
251+
private void drawPlayerHead(DrawContext drawContext, float screenX, float screenY, float scale) {
252+
float headSize = 8 * scale;
253+
254+
int headScreenX = (int) (screenX - headSize);
255+
int headScreenY = (int) (screenY - headSize / 2);
256+
257+
if (this.playerSkinTextures != null) {
258+
PlayerSkinDrawer.draw(drawContext, this.playerSkinTextures.texture(), headScreenX, headScreenY, (int) headSize, false, false, -1);
259+
}
226260
}
227261

228262
/**
@@ -258,7 +292,7 @@ private void drawEdgePointer(DrawContext drawContext, float width, float height,
258292
float baseRightX = baseCenterX + baseOffsetX;
259293
float baseRightY = baseCenterY + baseOffsetY;
260294

261-
DrawUtils.drawTriangle(drawContext, tipX, tipY, baseLeftX, baseLeftY, baseRightX, baseRightY, color);
295+
DrawUtils.drawTriangle(drawContext, (int) tipX, (int) tipY, (int) baseRightX, (int) baseRightY, (int) baseLeftX, (int) baseLeftY, color);
262296
} else {
263297
float centerX = tipX - normal.x * height / 2;
264298
float centerY = tipY - normal.y * height / 2;
@@ -274,10 +308,10 @@ private void drawEdgePointer(DrawContext drawContext, float width, float height,
274308
Vector2f right = new Vector2f(perpendicular).mul(hw).add(centerX, centerY);
275309

276310
DrawUtils.drawQuad(drawContext,
277-
top.x, top.y,
278-
right.x, right.y,
279-
bottom.x, bottom.y,
280-
left.x, left.y,
311+
(int) top.x, (int) top.y,
312+
(int) right.x, (int) right.y,
313+
(int) bottom.x, (int) bottom.y,
314+
(int) left.x, (int) left.y,
281315
color
282316
);
283317
}
@@ -310,7 +344,7 @@ protected Vector2f getClampedLabelPos(float labelWidth, float labelHeight, float
310344

311345
public void drawLabel(DrawContext drawContext, float screenX, float screenY, boolean isOutlined) {
312346
// Draw the name of the object by default
313-
drawContext.drawText(client.textRenderer, this.getName(), (int) screenX, (int) screenY, 0xFFFFFF, true);
347+
drawContext.drawText(client.textRenderer, this.getName(), (int) screenX, (int) screenY, Colors.WHITE, true);
314348
}
315349

316350
protected abstract LabelDisplayType getLabelDisplayType();

src/main/java/com/jumpcutfindo/onmymark/client/graphics/markers/PlayerMarkerRenderer.java

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,25 @@
33
import com.jumpcutfindo.onmymark.OnMyMarkMod;
44
import com.jumpcutfindo.onmymark.marker.Marker;
55
import com.jumpcutfindo.onmymark.marker.PlayerMarker;
6-
import com.mojang.authlib.GameProfile;
76
import net.minecraft.client.MinecraftClient;
87
import net.minecraft.client.gui.DrawContext;
9-
import net.minecraft.client.gui.PlayerSkinDrawer;
10-
import net.minecraft.client.util.SkinTextures;
118
import net.minecraft.util.math.Vec3d;
129

1310
public class PlayerMarkerRenderer extends MarkerRenderer {
1411
public static final long DEFAULT_LIFETIME_SECS = 60L;
1512
private static final int PLAYER_HEAD_SIZE = 8;
1613

1714
private final PlayerMarker playerMarker;
18-
private final SkinTextures playerSkinTextures;
1915

2016
public PlayerMarkerRenderer(MinecraftClient client, PlayerMarker marker) {
2117
super(client, marker, PointerShape.DIAMOND);
2218

2319
this.playerMarker = marker;
24-
25-
this.playerSkinTextures = MinecraftClient.getInstance()
26-
.getSkinProvider()
27-
.getSkinTextures(
28-
new GameProfile(playerMarker.playerId(), playerMarker.playerName())
29-
);
3020
}
3121

3222
@Override
3323
public void drawLabel(DrawContext drawContext, float screenX, float screenY, boolean isOutlined) {
34-
PlayerSkinDrawer.draw(drawContext, this.playerSkinTextures, (int) screenX, (int) screenY, PLAYER_HEAD_SIZE);
35-
super.drawLabel(drawContext, screenX + PLAYER_HEAD_SIZE + 4, screenY, isOutlined);
24+
super.drawLabel(drawContext, screenX, screenY, isOutlined);
3625
}
3726

3827
@Override
@@ -42,7 +31,7 @@ protected LabelDisplayType getLabelDisplayType() {
4231

4332
@Override
4433
public int getLabelWidth() {
45-
return client.textRenderer.getWidth(this.getName()) + PLAYER_HEAD_SIZE + 4;
34+
return client.textRenderer.getWidth(this.getName());
4635
}
4736

4837
@Override

src/main/java/com/jumpcutfindo/onmymark/client/graphics/render/CustomRenderLayers.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.jumpcutfindo.onmymark.client.graphics.render;
22

33
import com.jumpcutfindo.onmymark.OnMyMarkMod;
4-
import com.mojang.blaze3d.systems.RenderSystem;
54
import net.minecraft.client.render.RenderLayer;
65
import net.minecraft.client.render.RenderPhase;
76
import net.minecraft.util.Identifier;
@@ -28,13 +27,14 @@ public class CustomRenderLayers {
2827
float g = ((color >> 8) & 0xFF) / 255f;
2928
float b = (color & 0xFF) / 255f;
3029

31-
RenderSystem.setShaderColor(r, g, b, a);
30+
// RenderSystem.setShaderColor(r, g, b, a);
3231
}, () -> {
3332
// Resets the color
34-
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
33+
// RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
3534
}))
3635
.build(true);
3736
return RenderLayer.of(Identifier.of(OnMyMarkMod.MOD_ID, "solid_entity_color").toString(), 1536, true, false, CustomRenderPipelines.SOLID_ENTITY_COLOR, multiPhaseParameters);
38-
});;
37+
});
38+
;
3939
}
4040
}

0 commit comments

Comments
 (0)