Skip to content

Commit 52dbd25

Browse files
authored
Add entity scaling option for bigger mobs, render them without blurring (#39)
* Add entity scale option * Draw animal icons using nearest neighbor * Add setting for entity blur * Update changelog
1 parent e6e30ab commit 52dbd25

File tree

8 files changed

+52
-26
lines changed

8 files changed

+52
-26
lines changed

doc/changelog.html

+2
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,6 @@ <h1>JourneyMap ${version} for Minecraft ${mcversion}</h1>
2525
<ul>
2626
<li>Fixed: Some PNGs fail to resize.</li>
2727
<li>Chore: Update buildscript.</li>
28+
<li>Added: Option for entity icon scale.</li>
29+
<li>Added: Option to disable entity icon blur.</li>
2830
</ul>

src/main/java/journeymap/client/properties/MapProperties.java

+11-1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ public abstract class MapProperties extends PropertiesBase implements Comparable
4848
@Config(category = Inherit, key = "jm.common.mob_icon_set", stringListProvider = IconSetFileHandler.IconSetStringListProvider.class)
4949
public final AtomicReference<String> entityIconSetName = new AtomicReference<String>("2D");
5050

51+
@Config(category = Inherit, key = "jm.common.entity_scale", minValue = 50, maxValue = 400, defaultValue = 100)
52+
public final AtomicInteger entityScale = new AtomicInteger(100);
53+
54+
@Config(category = Inherit, key = "jm.common.entity_blur")
55+
public final AtomicBoolean entityBlur = new AtomicBoolean(true);
56+
5157
public final AtomicInteger zoomLevel = new AtomicInteger(0);
5258

5359
protected MapProperties()
@@ -85,6 +91,8 @@ public int hashCode()
8591
result = 31 * result + showWaypoints.hashCode();
8692
result = 31 * result + showSelf.hashCode();
8793
result = 31 * result + getEntityIconSetName().hashCode();
94+
result = 31 * result + entityScale.hashCode();
95+
result = 31 * result + entityBlur.hashCode();
8896
return result;
8997
}
9098

@@ -105,7 +113,9 @@ protected Objects.ToStringHelper toStringHelper(MapProperties me)
105113
.add("showSelf", showSelf)
106114
.add("showVillagers", showVillagers)
107115
.add("showWaypoints", showWaypoints)
108-
.add("zoomLevel", zoomLevel);
116+
.add("zoomLevel", zoomLevel)
117+
.add("entityScale", entityScale)
118+
.add("entityBlur", entityBlur);
109119
}
110120

111121

src/main/java/journeymap/client/properties/WebMapProperties.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ public String toString()
9292
", showPets=" + showPets +
9393
", showPlayers=" + showPlayers +
9494
", showWaypoints=" + showWaypoints +
95-
", entityIconSetName=" + getEntityIconSetName();
95+
", entityIconSetName=" + getEntityIconSetName() +
96+
", entityScale=" + entityScale +
97+
", entityBlur=" + entityBlur;
9698
}
9799

98100

src/main/java/journeymap/client/render/draw/DrawEntityStep.java

+11-5
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,23 @@ public class DrawEntityStep implements DrawStep
3939
WeakReference<EntityLivingBase> entityLivingRef;
4040
String customName;
4141
boolean flip;
42+
double entityScale;
43+
boolean entityBlur;
4244

4345
private DrawEntityStep(EntityLivingBase entityLiving)
4446
{
4547
super();
4648
this.entityLivingRef = new WeakReference<EntityLivingBase>(entityLiving);
4749
}
4850

49-
public void update(boolean flip, TextureImpl locatorTexture, TextureImpl texture, boolean showHeading)
51+
public void update(boolean flip, TextureImpl locatorTexture, TextureImpl texture, boolean showHeading, double entityScale, boolean entityBlur)
5052
{
5153
this.locatorTexture = locatorTexture;
5254
this.texture = texture;
5355
this.flip = flip;
5456
this.showHeading = showHeading;
57+
this.entityScale = entityScale;
58+
this.entityBlur = entityBlur;
5559
EntityLivingBase entityLiving = entityLivingRef.get();
5660
if (entityLiving != null)
5761
{
@@ -69,6 +73,8 @@ public void draw(double xOffset, double yOffset, GridRenderer gridRenderer, floa
6973
return;
7074
}
7175

76+
drawScale *= entityScale;
77+
7278
Point2D pixel = gridRenderer.getPixel(entityLiving.posX, entityLiving.posZ);
7379
if (pixel != null)
7480
{
@@ -106,12 +112,12 @@ private void drawPlayer(double drawX, double drawY, GridRenderer gridRenderer, f
106112

107113
if (locatorTexture != null && showHeading)
108114
{
109-
DrawUtil.drawEntity(drawX, drawY, heading, false, locatorTexture, alpha, drawScale, rotation);
115+
DrawUtil.drawEntity(drawX, drawY, heading, false, locatorTexture, alpha, drawScale, rotation, true);
110116
}
111117

112118
if (texture != null)
113119
{
114-
DrawUtil.drawEntity(drawX, drawY, heading, true, texture, alpha, drawScale * .75f, rotation);
120+
DrawUtil.drawEntity(drawX, drawY, heading, true, texture, alpha, drawScale * .75f, rotation, true);
115121
}
116122
int labelOffset = texture == null ? 0 : rotation == 0 ? -texture.getHeight() / 2 : texture.getHeight() / 2;
117123
Point2D labelPoint = gridRenderer.shiftWindowPosition(drawX, drawY, 0, -labelOffset);
@@ -140,7 +146,7 @@ private void drawCreature(double drawX, double drawY, GridRenderer gridRenderer,
140146

141147
if (locatorTexture != null && showHeading)
142148
{
143-
DrawUtil.drawEntity(drawX, drawY, heading, false, locatorTexture, alpha, drawScale, rotation);
149+
DrawUtil.drawEntity(drawX, drawY, heading, false, locatorTexture, alpha, drawScale, rotation, true);
144150
}
145151

146152
int labelOffset = texture == null ? 8 : rotation == 0 ? texture.getHeight() : -texture.getHeight();
@@ -153,7 +159,7 @@ private void drawCreature(double drawX, double drawY, GridRenderer gridRenderer,
153159

154160
if (texture != null)
155161
{
156-
DrawUtil.drawEntity(drawX, drawY, heading, true, texture, alpha, drawScale, rotation);
162+
DrawUtil.drawEntity(drawX, drawY, heading, true, texture, alpha, drawScale, rotation, entityBlur);
157163
}
158164
}
159165

src/main/java/journeymap/client/render/draw/DrawUtil.java

+15-15
Original file line numberDiff line numberDiff line change
@@ -230,14 +230,14 @@ public static int getLabelHeight(FontRenderer fr, boolean fontShadow)
230230
return fr.FONT_HEIGHT + (2 * vpad);
231231
}
232232

233-
private static void drawQuad(TextureImpl texture, float alpha, final double x, final double y, final double width, final double height, boolean flip, double rotation)
233+
private static void drawQuad(TextureImpl texture, float alpha, final double x, final double y, final double width, final double height, boolean flip, double rotation, boolean linear)
234234
{
235-
drawQuad(texture, x, y, width, height, rotation, null, alpha, flip, true, GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, false);
235+
drawQuad(texture, x, y, width, height, rotation, null, alpha, flip, true, GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, false, linear);
236236
}
237237

238238
private static void drawQuad(TextureImpl texture, final double x, final double y, final double width, final double height, boolean flip, double rotation)
239239
{
240-
drawQuad(texture, x, y, width, height, rotation, null, 1f, flip, true, GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, false);
240+
drawQuad(texture, x, y, width, height, rotation, null, 1f, flip, true, GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, false, true);
241241
}
242242

243243
/**
@@ -252,7 +252,7 @@ private static void drawQuad(TextureImpl texture, final double x, final double y
252252
* @param glBlendSfactor For normal alpha blending: GL11.GL_SRC_ALPHA
253253
* @param glBlendDFactor For normal alpha blending: GL11.GL_ONE_MINUS_SRC_ALPHA
254254
*/
255-
public static void drawQuad(TextureImpl texture, final double x, final double y, final double width, final double height, double rotation, Integer color, float alpha, boolean flip, boolean blend, int glBlendSfactor, int glBlendDFactor, boolean clampTexture)
255+
public static void drawQuad(TextureImpl texture, final double x, final double y, final double width, final double height, double rotation, Integer color, float alpha, boolean flip, boolean blend, int glBlendSfactor, int glBlendDFactor, boolean clampTexture, boolean linear)
256256
{
257257
GL11.glPushMatrix();
258258

@@ -277,8 +277,8 @@ public static void drawQuad(TextureImpl texture, final double x, final double y,
277277
renderHelper.glColor4f(1, 1, 1, alpha);
278278
}
279279

280-
renderHelper.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
281-
renderHelper.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
280+
renderHelper.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, linear ? GL11.GL_LINEAR : GL11.GL_NEAREST);
281+
renderHelper.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, linear ? GL11.GL_LINEAR : GL11.GL_NEAREST);
282282

283283
int texEdgeBehavior = clampTexture ? GL12.GL_CLAMP_TO_EDGE : GL11.GL_REPEAT;
284284
renderHelper.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, texEdgeBehavior);
@@ -388,9 +388,9 @@ public static void drawBoundTexture(double startU, double startV, double startX,
388388
renderHelper.draw();
389389
}
390390

391-
public static void drawImage(TextureImpl texture, double x, double y, boolean flip, float alpha, float scale, double rotation)
391+
public static void drawImage(TextureImpl texture, double x, double y, boolean flip, float alpha, float scale, double rotation, boolean linear)
392392
{
393-
drawQuad(texture, alpha, x, y, (texture.getWidth() * scale), (texture.getHeight() * scale), flip, rotation);
393+
drawQuad(texture, alpha, x, y, (texture.getWidth() * scale), (texture.getHeight() * scale), flip, rotation, linear);
394394
}
395395

396396
public static void drawImage(TextureImpl texture, double x, double y, boolean flip, float scale, double rotation)
@@ -405,17 +405,17 @@ public static void drawClampedImage(TextureImpl texture, double x, double y, flo
405405

406406
public static void drawClampedImage(TextureImpl texture, Integer color, double x, double y, float scale, float alpha, double rotation)
407407
{
408-
drawQuad(texture, x, y, (texture.getWidth() * scale), (texture.getHeight() * scale), rotation, color, alpha, false, true, GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, true);
408+
drawQuad(texture, x, y, (texture.getWidth() * scale), (texture.getHeight() * scale), rotation, color, alpha, false, true, GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, true, true);
409409
}
410410

411411
public static void drawColoredImage(TextureImpl texture, int alpha, Integer color, double x, double y, float scale, double rotation)
412412
{
413-
drawQuad(texture, x, y, (texture.getWidth() * scale), (texture.getHeight() * scale), rotation, color, alpha, false, true, GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, false);
413+
drawQuad(texture, x, y, (texture.getWidth() * scale), (texture.getHeight() * scale), rotation, color, alpha, false, true, GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, false, true);
414414
}
415415

416416
public static void drawColoredImage(TextureImpl texture, int alpha, Integer color, double x, double y, double rotation)
417417
{
418-
drawQuad(texture, x, y, texture.getWidth(), texture.getHeight(), rotation, color, alpha, false, true, GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, false);
418+
drawQuad(texture, x, y, texture.getWidth(), texture.getHeight(), rotation, color, alpha, false, true, GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, false, true);
419419
}
420420

421421
/**
@@ -430,7 +430,7 @@ public static void drawColoredImage(TextureImpl texture, int alpha, Integer colo
430430
*/
431431
public static void drawEntity(double x, double y, double heading, boolean flipInsteadOfRotate, TextureImpl texture, float scale, double rotation)
432432
{
433-
drawEntity(x, y, heading, flipInsteadOfRotate, texture, 1f, scale, rotation);
433+
drawEntity(x, y, heading, flipInsteadOfRotate, texture, 1f, scale, rotation, true);
434434
}
435435

436436
/**
@@ -443,7 +443,7 @@ public static void drawEntity(double x, double y, double heading, boolean flipIn
443443
* @param flipInsteadOfRotate
444444
* @param texture
445445
*/
446-
public static void drawEntity(double x, double y, double heading, boolean flipInsteadOfRotate, TextureImpl texture, float alpha, float scale, double rotation)
446+
public static void drawEntity(double x, double y, double heading, boolean flipInsteadOfRotate, TextureImpl texture, float alpha, float scale, double rotation, boolean linear)
447447
{
448448
// Adjust to scale
449449
double width = (texture.getWidth() * scale);
@@ -454,12 +454,12 @@ public static void drawEntity(double x, double y, double heading, boolean flipIn
454454
if (flipInsteadOfRotate)
455455
{
456456
boolean flip = (heading % 180) < 90;
457-
drawImage(texture, drawX, drawY, flip, alpha, scale, -rotation);
457+
drawImage(texture, drawX, drawY, flip, alpha, scale, -rotation, linear);
458458
}
459459
else
460460
{
461461
// Draw texture in rotated position
462-
drawImage(texture, drawX, drawY, false, alpha, scale, heading);
462+
drawImage(texture, drawX, drawY, false, alpha, scale, heading, linear);
463463
}
464464
}
465465

src/main/java/journeymap/client/render/draw/RadarDrawStepFactory.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ public List<DrawStep> prepareSteps(List<EntityDTO> entityDTOs, GridRenderer grid
3636
final boolean showMobHeading = mapProperties.showMobHeading.get();
3737
final boolean showPlayerHeading = mapProperties.showPlayerHeading.get();
3838
final List<DrawStep> drawStepList = new ArrayList<DrawStep>();
39+
final double entityScale = (double)mapProperties.entityScale.get() / 100;
40+
final boolean entityBlur = mapProperties.entityBlur.get();
3941

4042
try
4143
{
@@ -104,7 +106,7 @@ public List<DrawStep> prepareSteps(List<EntityDTO> entityDTOs, GridRenderer grid
104106
{
105107
entityIcon = tc.getPlayerSkin(ForgeHelper.INSTANCE.getEntityName(entityLiving));
106108
DrawEntityStep drawStep = DataCache.instance().getDrawEntityStep(entityLiving);
107-
drawStep.update(false, locatorImg, entityIcon, showPlayerHeading);
109+
drawStep.update(false, locatorImg, entityIcon, showPlayerHeading, entityScale, true);
108110
drawStepList.add(drawStep);
109111
}
110112
else
@@ -113,7 +115,7 @@ public List<DrawStep> prepareSteps(List<EntityDTO> entityDTOs, GridRenderer grid
113115
if (entityIcon != null)
114116
{
115117
DrawEntityStep drawStep = DataCache.instance().getDrawEntityStep(entityLiving);
116-
drawStep.update(false, locatorImg, entityIcon, showMobHeading);
118+
drawStep.update(false, locatorImg, entityIcon, showMobHeading, entityScale, entityBlur);
117119
drawStepList.add(drawStep);
118120
}
119121
}

src/main/java/journeymap/client/ui/theme/ThemeMinimapFrame.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public void drawMask()
132132
}
133133
else
134134
{
135-
DrawUtil.drawQuad(textureCircleMask, x, y, this.width, this.height, 0, null, 1f, false, true, GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, true);
135+
DrawUtil.drawQuad(textureCircleMask, x, y, this.width, this.height, 0, null, 1f, false, true, GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, true, true);
136136
}
137137
}
138138

@@ -209,7 +209,7 @@ public void drawFrame()
209209
}
210210
else
211211
{
212-
DrawUtil.drawQuad(textureCircle, x, y, this.width, this.height, 0, frameColor, 1f, false, true, GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, true);
212+
DrawUtil.drawQuad(textureCircle, x, y, this.width, this.height, 0, frameColor, 1f, false, true, GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, true, true);
213213
}
214214
}
215215
}

src/main/resources/assets/journeymap/lang/en_US.lang

+4
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ jm.common.mapgui_only_ready=Press [§b%1$s§f]
137137
jm.common.memory_warning=Minecraft is running out of memory: %1$s
138138
jm.common.mob_icon_set=Mob Icons
139139
jm.common.mob_icon_set.tooltip=The iconset used to display mobs on radar
140+
jm.common.entity_scale=Entity Scale
141+
jm.common.entity_scale.tooltip=The scale used for entities
142+
jm.common.entity_blur=Entity Blur
143+
jm.common.entity_blur.tooltip=If true, enables blur for entity icons. Set to false for a pixelated look
140144
jm.common.new_version_available=Newer version available: %1$s
141145
jm.common.night=Night
142146
jm.common.off=Off

0 commit comments

Comments
 (0)