Skip to content

Commit

Permalink
Show a message and do not crash with outdated Terra121
Browse files Browse the repository at this point in the history
  • Loading branch information
SmylerMC committed Oct 23, 2020
1 parent bc7e4cd commit e9734f2
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 16 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ forge_version = 1.12.2-14.23.5.2847
mcp_mappings = stable_39

# Mod stuff
mod_version = 1.0.0-beta6
mod_version = 1.0.0-beta6.1
mod_group = fr.thesmyler.terramap
mod_id = terramap
40 changes: 25 additions & 15 deletions src/main/java/fr/thesmyler/terramap/gui/TerramapScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,22 +222,36 @@ public void onUpdate(Screen parent) {

double mouseLat = this.map.getMouseLatitude();
double mouseLon = this.map.getMouseLongitude();
String displayLat = GeoServices.formatGeoCoordForDisplay(mouseLat);
String displayLon = GeoServices.formatGeoCoordForDisplay(mouseLon);
String formatX = "-";
String formatZ = "-";
String formatScale = "-";
String formatOrientation = "-";
if(Math.abs(mouseLat) > WebMercatorUtils.LIMIT_LATITUDE) {
displayLat = "-";
displayLon = "-";
} else if(projection != null) {
double[] pos = projection.fromGeo(mouseLon, mouseLat);
formatX = "" + Math.round(pos[0]);
formatZ = "" + Math.round(pos[1]);
double[] dist = projection.tissot(mouseLon, mouseLat, 0.0000001f);
formatScale = "" + GeoServices.formatGeoCoordForDisplay(Math.sqrt(Math.abs(dist[0])));
formatOrientation = "" + GeoServices.formatGeoCoordForDisplay(dist[1]*180.0/Math.PI);
this.distortionText.setText(I18n.format("terramap.terramapscreen.information.distortion", "-", "-"));
this.mouseGeoLocationText.setText(I18n.format("terramap.terramapscreen.information.mouse_geo", "-", "-"));
this.mouseMCLocationText.setText(I18n.format("terramap.terramapscreen.information.mouse_mc", "-", "-"));
} else {
String displayLat = GeoServices.formatGeoCoordForDisplay(mouseLat);
String displayLon = GeoServices.formatGeoCoordForDisplay(mouseLon);
this.mouseGeoLocationText.setText(I18n.format("terramap.terramapscreen.information.mouse_geo", displayLat, displayLon));
if(projection != null) {
double[] pos = projection.fromGeo(mouseLon, mouseLat);
formatX = "" + Math.round(pos[0]);
formatZ = "" + Math.round(pos[1]);
this.mouseMCLocationText.setText(I18n.format("terramap.terramapscreen.information.mouse_mc", formatX, formatZ));
try {
double[] dist = projection.tissot(mouseLon, mouseLat, 0.0000001f);
formatScale = "" + GeoServices.formatGeoCoordForDisplay(Math.sqrt(Math.abs(dist[0])));
formatOrientation = "" + GeoServices.formatGeoCoordForDisplay(dist[1]*180.0/Math.PI);
this.distortionText.setText(I18n.format("terramap.terramapscreen.information.distortion", formatScale, formatOrientation));
} catch(NoSuchMethodError e) {
this.distortionText.setText(I18n.format("terramap.terramapscreen.information.outdatedterra121"));
this.distortionText.setBaseColor(0xFFFF0000);
}
} else {
this.distortionText.setText(I18n.format("terramap.terramapscreen.information.distortion", "-", "-"));
this.mouseMCLocationText.setText(I18n.format("terramap.terramapscreen.information.mouse_mc", "-", "-"));
}
}

if(this.map.isTracking()) {
Expand Down Expand Up @@ -266,10 +280,6 @@ public void onUpdate(Screen parent) {
} else {
this.playerGeoLocationText.setText(I18n.format("terramap.terramapscreen.information.noplayer"));
}

this.mouseGeoLocationText.setText(I18n.format("terramap.terramapscreen.information.mouse_geo", displayLat, displayLon));
this.mouseMCLocationText.setText(I18n.format("terramap.terramapscreen.information.mouse_mc", formatX, formatZ));
this.distortionText.setText(I18n.format("terramap.terramapscreen.information.distortion", formatScale, formatOrientation));

if(this.debugMode) {
String dbText = "";
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/terramap/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ terramap.terramapscreen.information.playerout=You are outside the projection
terramap.terramapscreen.information.playergeo=Player position: %1$s° %2$s°
terramap.terramapscreen.information.noplayer=Player position: -° -°
terramap.terramapscreen.information.distortion=Distortion: %1$s blocks/m ; ±%2$s°
terramap.terramapscreen.information.outdatedterra121=Please update Terra121

terramap.terramapscreen.markercontrollers.buttons.mainplayer=Toggle main player visibility
terramap.terramapscreen.markercontrollers.buttons.otherplayer=Toggle other players visibility
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/terramap/lang/fr_fr.lang
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ terramap.terramapscreen.information.playerout=Vous êtes en dehors de la project
terramap.terramapscreen.information.playergeo=Position du joueur: %1$s° %2$s°
terramap.terramapscreen.information.noplayer=Position du joueur: -° -°
terramap.terramapscreen.information.distortion=Distortion: %1$s blocks/m ; ±%2$s°
terramap.terramapscreen.information.outdatedterra121=Merci de mettre à jour Terra121

terramap.terramapscreen.markercontrollers.buttons.mainplayer=Changer la visibilité du joueur principal
terramap.terramapscreen.markercontrollers.buttons.otherplayer=Changer la visibilité des autres joueurs
Expand Down

0 comments on commit e9734f2

Please sign in to comment.