Skip to content

Commit

Permalink
Add entity scaling option for bigger mobs, render them without blurri…
Browse files Browse the repository at this point in the history
…ng (#39)

* Add entity scale option

* Draw animal icons using nearest neighbor

* Add setting for entity blur

* Update changelog
  • Loading branch information
DarkShadow44 authored Jan 20, 2025
1 parent e6e30ab commit 52dbd25
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 26 deletions.
2 changes: 2 additions & 0 deletions doc/changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ <h1>JourneyMap ${version} for Minecraft ${mcversion}</h1>
<ul>
<li>Fixed: Some PNGs fail to resize.</li>
<li>Chore: Update buildscript.</li>
<li>Added: Option for entity icon scale.</li>
<li>Added: Option to disable entity icon blur.</li>
</ul>
12 changes: 11 additions & 1 deletion src/main/java/journeymap/client/properties/MapProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ public abstract class MapProperties extends PropertiesBase implements Comparable
@Config(category = Inherit, key = "jm.common.mob_icon_set", stringListProvider = IconSetFileHandler.IconSetStringListProvider.class)
public final AtomicReference<String> entityIconSetName = new AtomicReference<String>("2D");

@Config(category = Inherit, key = "jm.common.entity_scale", minValue = 50, maxValue = 400, defaultValue = 100)
public final AtomicInteger entityScale = new AtomicInteger(100);

@Config(category = Inherit, key = "jm.common.entity_blur")
public final AtomicBoolean entityBlur = new AtomicBoolean(true);

public final AtomicInteger zoomLevel = new AtomicInteger(0);

protected MapProperties()
Expand Down Expand Up @@ -85,6 +91,8 @@ public int hashCode()
result = 31 * result + showWaypoints.hashCode();
result = 31 * result + showSelf.hashCode();
result = 31 * result + getEntityIconSetName().hashCode();
result = 31 * result + entityScale.hashCode();
result = 31 * result + entityBlur.hashCode();
return result;
}

Expand All @@ -105,7 +113,9 @@ protected Objects.ToStringHelper toStringHelper(MapProperties me)
.add("showSelf", showSelf)
.add("showVillagers", showVillagers)
.add("showWaypoints", showWaypoints)
.add("zoomLevel", zoomLevel);
.add("zoomLevel", zoomLevel)
.add("entityScale", entityScale)
.add("entityBlur", entityBlur);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ public String toString()
", showPets=" + showPets +
", showPlayers=" + showPlayers +
", showWaypoints=" + showWaypoints +
", entityIconSetName=" + getEntityIconSetName();
", entityIconSetName=" + getEntityIconSetName() +
", entityScale=" + entityScale +
", entityBlur=" + entityBlur;
}


Expand Down
16 changes: 11 additions & 5 deletions src/main/java/journeymap/client/render/draw/DrawEntityStep.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,23 @@ public class DrawEntityStep implements DrawStep
WeakReference<EntityLivingBase> entityLivingRef;
String customName;
boolean flip;
double entityScale;
boolean entityBlur;

private DrawEntityStep(EntityLivingBase entityLiving)
{
super();
this.entityLivingRef = new WeakReference<EntityLivingBase>(entityLiving);
}

public void update(boolean flip, TextureImpl locatorTexture, TextureImpl texture, boolean showHeading)
public void update(boolean flip, TextureImpl locatorTexture, TextureImpl texture, boolean showHeading, double entityScale, boolean entityBlur)
{
this.locatorTexture = locatorTexture;
this.texture = texture;
this.flip = flip;
this.showHeading = showHeading;
this.entityScale = entityScale;
this.entityBlur = entityBlur;
EntityLivingBase entityLiving = entityLivingRef.get();
if (entityLiving != null)
{
Expand All @@ -69,6 +73,8 @@ public void draw(double xOffset, double yOffset, GridRenderer gridRenderer, floa
return;
}

drawScale *= entityScale;

Point2D pixel = gridRenderer.getPixel(entityLiving.posX, entityLiving.posZ);
if (pixel != null)
{
Expand Down Expand Up @@ -106,12 +112,12 @@ private void drawPlayer(double drawX, double drawY, GridRenderer gridRenderer, f

if (locatorTexture != null && showHeading)
{
DrawUtil.drawEntity(drawX, drawY, heading, false, locatorTexture, alpha, drawScale, rotation);
DrawUtil.drawEntity(drawX, drawY, heading, false, locatorTexture, alpha, drawScale, rotation, true);
}

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

if (locatorTexture != null && showHeading)
{
DrawUtil.drawEntity(drawX, drawY, heading, false, locatorTexture, alpha, drawScale, rotation);
DrawUtil.drawEntity(drawX, drawY, heading, false, locatorTexture, alpha, drawScale, rotation, true);
}

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

if (texture != null)
{
DrawUtil.drawEntity(drawX, drawY, heading, true, texture, alpha, drawScale, rotation);
DrawUtil.drawEntity(drawX, drawY, heading, true, texture, alpha, drawScale, rotation, entityBlur);
}
}

Expand Down
30 changes: 15 additions & 15 deletions src/main/java/journeymap/client/render/draw/DrawUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,14 @@ public static int getLabelHeight(FontRenderer fr, boolean fontShadow)
return fr.FONT_HEIGHT + (2 * vpad);
}

private static void drawQuad(TextureImpl texture, float alpha, final double x, final double y, final double width, final double height, boolean flip, double rotation)
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)
{
drawQuad(texture, x, y, width, height, rotation, null, alpha, flip, true, GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, false);
drawQuad(texture, x, y, width, height, rotation, null, alpha, flip, true, GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, false, linear);
}

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

/**
Expand All @@ -252,7 +252,7 @@ private static void drawQuad(TextureImpl texture, final double x, final double y
* @param glBlendSfactor For normal alpha blending: GL11.GL_SRC_ALPHA
* @param glBlendDFactor For normal alpha blending: GL11.GL_ONE_MINUS_SRC_ALPHA
*/
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)
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)
{
GL11.glPushMatrix();

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

renderHelper.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
renderHelper.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
renderHelper.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, linear ? GL11.GL_LINEAR : GL11.GL_NEAREST);
renderHelper.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, linear ? GL11.GL_LINEAR : GL11.GL_NEAREST);

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

public static void drawImage(TextureImpl texture, double x, double y, boolean flip, float alpha, float scale, double rotation)
public static void drawImage(TextureImpl texture, double x, double y, boolean flip, float alpha, float scale, double rotation, boolean linear)
{
drawQuad(texture, alpha, x, y, (texture.getWidth() * scale), (texture.getHeight() * scale), flip, rotation);
drawQuad(texture, alpha, x, y, (texture.getWidth() * scale), (texture.getHeight() * scale), flip, rotation, linear);
}

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

public static void drawClampedImage(TextureImpl texture, Integer color, double x, double y, float scale, float alpha, double rotation)
{
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);
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);
}

public static void drawColoredImage(TextureImpl texture, int alpha, Integer color, double x, double y, float scale, double rotation)
{
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);
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);
}

public static void drawColoredImage(TextureImpl texture, int alpha, Integer color, double x, double y, double rotation)
{
drawQuad(texture, x, y, texture.getWidth(), texture.getHeight(), rotation, color, alpha, false, true, GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, false);
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);
}

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

/**
Expand All @@ -443,7 +443,7 @@ public static void drawEntity(double x, double y, double heading, boolean flipIn
* @param flipInsteadOfRotate
* @param texture
*/
public static void drawEntity(double x, double y, double heading, boolean flipInsteadOfRotate, TextureImpl texture, float alpha, float scale, double rotation)
public static void drawEntity(double x, double y, double heading, boolean flipInsteadOfRotate, TextureImpl texture, float alpha, float scale, double rotation, boolean linear)
{
// Adjust to scale
double width = (texture.getWidth() * scale);
Expand All @@ -454,12 +454,12 @@ public static void drawEntity(double x, double y, double heading, boolean flipIn
if (flipInsteadOfRotate)
{
boolean flip = (heading % 180) < 90;
drawImage(texture, drawX, drawY, flip, alpha, scale, -rotation);
drawImage(texture, drawX, drawY, flip, alpha, scale, -rotation, linear);
}
else
{
// Draw texture in rotated position
drawImage(texture, drawX, drawY, false, alpha, scale, heading);
drawImage(texture, drawX, drawY, false, alpha, scale, heading, linear);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public List<DrawStep> prepareSteps(List<EntityDTO> entityDTOs, GridRenderer grid
final boolean showMobHeading = mapProperties.showMobHeading.get();
final boolean showPlayerHeading = mapProperties.showPlayerHeading.get();
final List<DrawStep> drawStepList = new ArrayList<DrawStep>();
final double entityScale = (double)mapProperties.entityScale.get() / 100;
final boolean entityBlur = mapProperties.entityBlur.get();

try
{
Expand Down Expand Up @@ -104,7 +106,7 @@ public List<DrawStep> prepareSteps(List<EntityDTO> entityDTOs, GridRenderer grid
{
entityIcon = tc.getPlayerSkin(ForgeHelper.INSTANCE.getEntityName(entityLiving));
DrawEntityStep drawStep = DataCache.instance().getDrawEntityStep(entityLiving);
drawStep.update(false, locatorImg, entityIcon, showPlayerHeading);
drawStep.update(false, locatorImg, entityIcon, showPlayerHeading, entityScale, true);
drawStepList.add(drawStep);
}
else
Expand All @@ -113,7 +115,7 @@ public List<DrawStep> prepareSteps(List<EntityDTO> entityDTOs, GridRenderer grid
if (entityIcon != null)
{
DrawEntityStep drawStep = DataCache.instance().getDrawEntityStep(entityLiving);
drawStep.update(false, locatorImg, entityIcon, showMobHeading);
drawStep.update(false, locatorImg, entityIcon, showMobHeading, entityScale, entityBlur);
drawStepList.add(drawStep);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public void drawMask()
}
else
{
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);
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);
}
}

Expand Down Expand Up @@ -209,7 +209,7 @@ public void drawFrame()
}
else
{
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);
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);
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/assets/journeymap/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ jm.common.mapgui_only_ready=Press [§b%1$s§f]
jm.common.memory_warning=Minecraft is running out of memory: %1$s
jm.common.mob_icon_set=Mob Icons
jm.common.mob_icon_set.tooltip=The iconset used to display mobs on radar
jm.common.entity_scale=Entity Scale
jm.common.entity_scale.tooltip=The scale used for entities
jm.common.entity_blur=Entity Blur
jm.common.entity_blur.tooltip=If true, enables blur for entity icons. Set to false for a pixelated look
jm.common.new_version_available=Newer version available: %1$s
jm.common.night=Night
jm.common.off=Off
Expand Down

0 comments on commit 52dbd25

Please sign in to comment.