Skip to content

Commit

Permalink
add option for biome name under the minimap
Browse files Browse the repository at this point in the history
  • Loading branch information
Vectron committed Jan 6, 2016
1 parent a980e63 commit 5404945
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 10 deletions.
12 changes: 11 additions & 1 deletion src/main/java/mapwriter/Mw.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import net.minecraft.client.resources.I18n;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.util.BlockPos;
import net.minecraft.util.ChatComponentText;
import net.minecraft.world.chunk.Chunk;

Expand Down Expand Up @@ -56,6 +57,7 @@ public class Mw
public int playerXInt = 0;
public int playerYInt = 0;
public int playerZInt = 0;
public String playerBiome = "";
public double playerHeading = 0.0;
public int playerDimension = 0;
public float mapRotationDegrees = 0.0f;
Expand Down Expand Up @@ -143,7 +145,15 @@ public void updatePlayer()
this.playerXInt = (int) Math.floor(this.playerX);
this.playerYInt = (int) Math.floor(this.playerY);
this.playerZInt = (int) Math.floor(this.playerZ);


if (this.mc.theWorld != null)
{
if (!this.mc.theWorld.getChunkFromBlockCoords(new BlockPos(this.playerX, 0, this.playerZ)).isEmpty())
{
this.playerBiome = this.mc.theWorld.getBiomeGenForCoords(new BlockPos(this.playerX, 0, this.playerZ)).biomeName;
}
}

// rotationYaw of 0 points due north, we want it to point due east
// instead
// so add pi/2 radians (90 degrees)
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/mapwriter/config/MapModeConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public class MapModeConfig
public int heightPercent = this.heightPercentDef;
public String PositionDef = "FullScreen";
public String Position = this.PositionDef;
public String biomeModeDef = coordsModeStringArray[0];
public String biomeMode = this.biomeModeDef;

public MapModeConfig(String configCategory)
{
Expand Down
1 change: 1 addition & 0 deletions src/main/java/mapwriter/config/largeMapModeConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public void loadConfig()
this.circular = ConfigurationHandler.configuration.getBoolean("circular", this.configCategory, this.circularDef, "", "mw.config.map.circular");
this.coordsMode = ConfigurationHandler.configuration.getString("coordsMode", this.configCategory, this.coordsModeDef, "", coordsModeStringArray, "mw.config.map.coordsMode");
this.borderMode = ConfigurationHandler.configuration.getBoolean("borderMode", this.configCategory, this.borderModeDef, "", "mw.config.map.borderMode");
this.biomeMode = ConfigurationHandler.configuration.getString("biomeMode", this.configCategory, this.biomeModeDef, "", coordsModeStringArray, "mw.config.map.biomeMode");
}

@Override
Expand Down
1 change: 1 addition & 0 deletions src/main/java/mapwriter/config/smallMapModeConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public void setDefaults()
this.rotateDef = true;
this.circularDef = true;
this.coordsModeDef = coordsModeStringArray[1];
this.biomeModeDef = coordsModeStringArray[0];
this.borderModeDef = true;
this.playerArrowSizeDef = 4;
this.markerSizeDef = 3;
Expand Down
52 changes: 45 additions & 7 deletions src/main/java/mapwriter/map/MapRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import mapwriter.util.Reference;
import mapwriter.util.Render;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.BlockPos;

import org.lwjgl.opengl.GL11;

Expand All @@ -24,7 +26,8 @@ public class MapRenderer
// accessed by the MwGui to check whether the mouse cursor is near the
// player arrow on the rendered map
public Point.Double playerArrowScreenPos = new Point.Double(0, 0);

private int textOffset = 12;

public MapRenderer(Mw mw, MapMode mapMode, MapView mapView)
{
this.mw = mw;
Expand Down Expand Up @@ -219,6 +222,14 @@ private void drawIcons()
this.drawPlayerArrow();
}

private void drawStatusText()
{
this.textOffset = 12;
drawCoords();
drawBiomeName();
drawUndergroundMode();
}

private void drawCoords()
{
// draw coordinates
Expand All @@ -228,19 +239,46 @@ private void drawCoords()
GlStateManager.translate(this.mapMode.textX, this.mapMode.textY, 0);
if (this.mapMode.config.coordsMode.equals(MapModeConfig.coordsModeStringArray[1]))
{
GlStateManager.scale(0.5f, 0.5f, 1.0f);
GlStateManager.scale(0.5f, 0.5f, 1.0f);
this.textOffset = (int)(this.textOffset * 0.5f);
}
int offset = 0;
Render.drawCentredString(0, 0, this.mapMode.textColour, "%d, %d, %d", this.mw.playerXInt, this.mw.playerYInt, this.mw.playerZInt);
offset += 12;
if (Config.undergroundMode)
this.mapMode.textY += this.textOffset;
GlStateManager.popMatrix();
}
}

private void drawBiomeName()
{
if (!this.mapMode.config.biomeMode.equals(MapModeConfig.coordsModeStringArray[0]))
{
GlStateManager.pushMatrix();
GlStateManager.translate(this.mapMode.textX, this.mapMode.textY, 0);
if (this.mapMode.config.biomeMode.equals(MapModeConfig.coordsModeStringArray[1]))
{
Render.drawCentredString(0, offset, this.mapMode.textColour, "underground mode");
GlStateManager.scale(0.5f, 0.5f, 1.0f);
this.textOffset = (int)(this.textOffset * 0.5f);
}
Render.drawCentredString(0, 0, this.mapMode.textColour, this.mw.playerBiome);
this.mapMode.textY += this.textOffset;
GlStateManager.popMatrix();
}
}

private void drawUndergroundMode()
{
if (Config.undergroundMode)
{
GlStateManager.pushMatrix();
GlStateManager.translate(this.mapMode.textX, this.mapMode.textY, 0);
GlStateManager.scale(0.5f, 0.5f, 1.0f);
this.textOffset = (int)(this.textOffset * 0.5f);
Render.drawCentredString(0, 0, this.mapMode.textColour, "underground mode");
this.mapMode.textY += this.textOffset;
GlStateManager.popMatrix();
}
}

private IMwDataProvider drawOverlay()
{
// draw overlays from registered providers
Expand Down Expand Up @@ -284,7 +322,7 @@ public void draw()
}
this.drawIcons();

this.drawCoords();
this.drawStatusText();

// some shader mods seem to need depth testing re-enabled
GL11.glEnable(GL11.GL_DEPTH_TEST);
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/assets/mapwriter/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,14 @@ mw.config.map.rotate=Rotate map
mw.config.map.rotate.tooltip=Set to true to rotate the map, only possible in circular mode
mw.config.map.circular=Circular map
mw.config.map.circular.tooltip=True = Circular map, false = square map
mw.config.map.coordsEnabled=Enable coordinates
mw.config.map.coordsEnabled.tooltip=set to true to display coordinates under map
mw.config.map.borderMode=Draw border
mw.config.map.borderMode.tooltip=Set to true to draw the borders around the map
mw.config.map.trailMarkerSize=Trail marker size
mw.config.map.trailMarkerSize.tooltip=The size of trail markers on the map
mw.config.map.coordsMode=Coordinates mode
mw.config.map.coordsMode.tooltip=Switch between no,small or large coordinates under the minimap
mw.config.map.biomeMode=Biome mode
mw.config.map.biomeMode.tooltip=Switch between no,small or large biome name under the minimap
mw.config.map.coordsMode.disabled=Disabled
mw.config.map.coordsMode.small=Small
mw.config.map.coordsMode.large=Large
Expand Down

0 comments on commit 5404945

Please sign in to comment.