Skip to content

implemented user configurable world height, cleaned up commits #4102

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: v3.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ private static class DataVersionMap {
int dataVersion;
//String version;
Color defcolor;
DataVersionMap(int dv, String v, int c) {
DataVersionMap(int dv, String v, Color c) {
dataVersion = dv;
//version = v;
defcolor = new Color((c>>16)&0xFF, (c>>8)&0xFF, c&0xFF);
Expand Down Expand Up @@ -59,11 +59,20 @@ private static class DataVersionMap {
new DataVersionMap(2860, "1.18.0", 0xA3E4D7),
new DataVersionMap(2865, "1.18.1", 0x48C9B0),
new DataVersionMap(2975, "1.18.2", 0x38bfa5),
new DataVersionMap(3105, "1.19", 0xd56f82),
new DataVersionMap(3105, "1.19.0", 0xd56f82),
new DataVersionMap(3116, "1.19.1", 0xe196a4),
new DataVersionMap(3120, "1.19.2", 0xe7aeb8),
new DataVersionMap(3218, "1.19.3", 0xf8c0c8),
new DataVersionMap(3337, "1.19.4", 0xffb6c1),
new DataVersionMap(3463, "1.20.0", 0xe196a6),
new DataVersionMap(3465, "1.20.1", 0xe7aeb10),
new DataVersionMap(3578, "1.20.2", 0xe196a7),
new DataVersionMap(3698, "1.20.3", 0xe7aeb11),
new DataVersionMap(3700, "1.20.4", 0xe196a8),
new DataVersionMap(3837, "1.20.5", 0xe7aeb12),
new DataVersionMap(3839, "1.20.6", 0xe196a9),
new DataVersionMap(3953, "1.21.0", 0xe7aeb13),


};
final static Color unknown_color = new Color(255, 255, 255);
Expand Down
34 changes: 21 additions & 13 deletions DynmapCore/src/main/java/org/dynmap/hdmap/TopoHDShader.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
import java.util.BitSet;
import java.util.List;

import org.dynmap.Color;
import org.dynmap.ConfigurationNode;
import org.dynmap.DynmapCore;
import org.dynmap.MapManager;
import org.dynmap.*;
import org.dynmap.common.DynmapCommandSender;
import org.dynmap.exporter.OBJExport;
import org.dynmap.renderer.DynmapBlockState;
Expand All @@ -26,15 +23,26 @@ public class TopoHDShader implements HDShader {
private final Color watercolor;
private BitSet hiddenids;
private final int linespacing;

private int worldheight;
public TopoHDShader(DynmapCore core, ConfigurationNode configuration) {
name = (String) configuration.get("name");

fillcolor = new Color[256]; /* Color by Y */
/* Load defined colors from parameters */
for(int i = 0; i < 256; i++) {
fillcolor[i] = configuration.getColor("color" + i, null);
if (HDBlockModels.checkVersionRange(core.getDynmapPluginPlatformVersion(), "-1.17.0")){
worldheight = 256;
fillcolor = new Color[worldheight]; /* Color by Y, must be range of total world height, offset by +64*/
/* Load defined colors from parameters */
for(int i = 0; i < worldheight; i++) {
fillcolor[i] = configuration.getColor("color" + (i - 64), null); /* need to substract by 64 because Color does not accept <0 indexes*/
}
}
else{
worldheight = configuration.getInteger("worldheight", 348);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

384, not 348 (64 + 320). however, i would caution against this, as it now requires users to manually specify the world height for nether and end worlds

fillcolor = new Color[worldheight]; /* Color by Y, must be range of total world height, offset by +64*/
/* Load defined colors from parameters */
for(int i = 0; i < worldheight; i++) {
fillcolor[i] = configuration.getColor("color" + (i - 64), null); /* need to substract by 64 because Color does not accept <0 indexes*/

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i - 64 will be incorrect for end and nether worlds (they still use 0-255)

}
}

linecolor = configuration.getColor("linecolor", null);
watercolor = configuration.getColor("watercolor", null);
float wateralpha = configuration.getFloat("wateralpha", 1.0F);
Expand All @@ -45,11 +53,11 @@ public TopoHDShader(DynmapCore core, ConfigurationNode configuration) {
if(fillcolor[0] == null) {
fillcolor[0] = new Color(0, 0, 0);
}
if(fillcolor[255] == null) {
fillcolor[255] = new Color(255, 255, 255);
if(fillcolor[worldheight-1] == null) {
fillcolor[worldheight-1] = new Color(255, 255, 255);
}
int starty = 0;
for(int i = 1; i < 256; i++) {
for(int i = 0; i < worldheight; i++) {
if(fillcolor[i] != null) { /* Found color? */
int delta = i - starty;
Color c0 = fillcolor[starty];
Expand Down