Skip to content
Closed
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
21 changes: 12 additions & 9 deletions DynmapCore/src/main/java/org/dynmap/MarkersComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class MarkersComponent extends ClientComponent {
private MarkerSet spawnbedset;
private MarkerIcon spawnbedicon;
private String spawnbedformat;
private boolean removebedonplayerleave;
private long maxofflineage;
private boolean showSpawn;
private boolean showBorder;
Expand Down Expand Up @@ -180,23 +181,25 @@ public void playerEvent(DynmapPlayer p) {

spawnbedicon = api.getMarkerIcon(configuration.getString("spawnbedicon", "bed"));
spawnbedformat = configuration.getString("spawnbedformat", "%name%'s bed");

removebedonplayerleave = configuration.getBoolean("spawnbedremoveonplayerleave", true);
/* Add listener for players coming and going */
core.listenerManager.addListener(EventType.PLAYER_JOIN, new PlayerEventListener() {
@Override
public void playerEvent(DynmapPlayer p) {
updatePlayer(p);
}
});
core.listenerManager.addListener(EventType.PLAYER_QUIT, new PlayerEventListener() {
@Override
public void playerEvent(DynmapPlayer p) {
Marker m = spawnbedset.findMarker(p.getName()+"_bed");
if(m != null) {
m.deleteMarker();
if (removebedonplayerleave) {
core.listenerManager.addListener(EventType.PLAYER_QUIT, new PlayerEventListener() {
@Override
public void playerEvent(DynmapPlayer p) {
Marker m = spawnbedset.findMarker(p.getName() + "_bed");
if (m != null) {
m.deleteMarker();
}
}
}
});
});
}
core.listenerManager.addListener(EventType.PLAYER_BED_LEAVE, new PlayerEventListener() {
@Override
public void playerEvent(final DynmapPlayer p) {
Expand Down
68 changes: 34 additions & 34 deletions DynmapCore/src/main/java/org/dynmap/hdmap/HDBlockModels.java

Large diffs are not rendered by default.

152 changes: 80 additions & 72 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 = 384;
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*/

Choose a reason for hiding this comment

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

this wont work as expected on nether and end worlds, which do not have an expanded height (0-255)

}
}
else{
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*/
}
}

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 All @@ -73,25 +81,25 @@ public TopoHDShader(DynmapCore core, ConfigurationNode configuration) {
}
linespacing = configuration.getInteger("linespacing", 1);
}

private void setHidden(String bn) {
DynmapBlockState bs = DynmapBlockState.getBaseStateByName(bn);
for (int i = 0; i < bs.getStateCount(); i++) {
DynmapBlockState b = bs.getState(i);
hiddenids.set(b.globalStateIndex);
}
}

@Override
public boolean isBiomeDataNeeded() {
return false;
public boolean isBiomeDataNeeded() {
return false;
}

@Override
public boolean isRawBiomeDataNeeded() {
return false;
public boolean isRawBiomeDataNeeded() {
return false;
}

@Override
public boolean isHightestBlockYDataNeeded() {
return false;
Expand All @@ -116,7 +124,7 @@ public boolean isEmittedLightLevelNeeded() {
public String getName() {
return name;
}

private class OurShaderState implements HDShaderState {
private Color color[];
private Color tmpcolor[];
Expand All @@ -128,7 +136,7 @@ private class OurShaderState implements HDShaderState {
private int heightshift; /* Divide to keep in 0-127 range of colors */
private boolean inWater;
final int[] lightingTable;

private OurShaderState(MapIterator mapiter, HDMap map, MapChunkCache cache, int scale) {
this.mapiter = mapiter;
this.map = map;
Expand Down Expand Up @@ -171,14 +179,14 @@ public HDShader getShader() {
public HDMap getMap() {
return map;
}

/**
* Get our lighting
*/
public HDLighting getLighting() {
return lighting;
}

/**
* Reset renderer state for new ray
*/
Expand All @@ -187,18 +195,18 @@ public void reset(HDPerspectiveState ps) {
color[i].setTransparent();
inWater = false;
}

private final boolean isHidden(DynmapBlockState blk) {
return hiddenids.get(blk.globalStateIndex);
}

/**
* Process next ray step - called for each block on route
* @return true if ray is done, false if ray needs to continue
*/
public boolean processBlock(HDPerspectiveState ps) {
DynmapBlockState blocktype = ps.getBlockState();

if (isHidden(blocktype)) {
return false;
}
Expand All @@ -208,56 +216,56 @@ public boolean processBlock(HDPerspectiveState ps) {
int[] xyz = ps.getSubblockCoord();
// Only color lines when spacing is matched
Color lcolor = ((y % linespacing) == 0)?linecolor:null;

/* See which face we're on (only do lines on top face) */
switch(ps.getLastBlockStep()) {
case Y_MINUS:
case Y_PLUS:
if((lcolor != null) &&
(((xyz[0] == 0) && (isHidden(mapiter.getBlockTypeAt(BlockStep.X_MINUS)))) ||
((xyz[0] == (scale-1)) && (isHidden(mapiter.getBlockTypeAt(BlockStep.X_PLUS)))) ||
((xyz[2] == 0) && (isHidden(mapiter.getBlockTypeAt(BlockStep.Z_MINUS)))) ||
((xyz[2] == (scale-1)) && (isHidden(mapiter.getBlockTypeAt(BlockStep.Z_PLUS)))))) {
c.setColor(lcolor);
inWater = false;
}
else if ((watercolor != null) && blocktype.isWater()) {
if (!inWater) {
c.setColor(watercolor);
inWater = true;
case Y_MINUS:
case Y_PLUS:
if((lcolor != null) &&
(((xyz[0] == 0) && (isHidden(mapiter.getBlockTypeAt(BlockStep.X_MINUS)))) ||
((xyz[0] == (scale-1)) && (isHidden(mapiter.getBlockTypeAt(BlockStep.X_PLUS)))) ||
((xyz[2] == 0) && (isHidden(mapiter.getBlockTypeAt(BlockStep.Z_MINUS)))) ||
((xyz[2] == (scale-1)) && (isHidden(mapiter.getBlockTypeAt(BlockStep.Z_PLUS)))))) {
c.setColor(lcolor);
inWater = false;
}
else if ((watercolor != null) && blocktype.isWater()) {
if (!inWater) {
c.setColor(watercolor);
inWater = true;
}
else {
return false;
}
}
else {
return false;
c.setColor(fillcolor[y >> heightshift]);
inWater = false;
}
}
else {
c.setColor(fillcolor[y >> heightshift]);
inWater = false;
}
break;
default:
if((lcolor != null) && (xyz[1] == (scale-1))) {
c.setColor(lcolor);
inWater = false;
}
else if ((watercolor != null) && blocktype.isWater()) {
if (!inWater) {
c.setColor(watercolor);
inWater = true;
break;
default:
if((lcolor != null) && (xyz[1] == (scale-1))) {
c.setColor(lcolor);
inWater = false;
}
else if ((watercolor != null) && blocktype.isWater()) {
if (!inWater) {
c.setColor(watercolor);
inWater = true;
}
else {
return false;
}
}
else {
return false;
c.setColor(fillcolor[y >> heightshift]);
inWater = false;
}
}
else {
c.setColor(fillcolor[y >> heightshift]);
inWater = false;
}
break;
break;
}
/* Handle light level, if needed */
lighting.applyLighting(ps, this, c, tmpcolor);

/* If no previous color contribution, use new color */
if(color[0].isTransparent()) {
for(int i = 0; i < color.length; i++)
Expand All @@ -272,15 +280,15 @@ else if ((watercolor != null) && blocktype.isWater()) {
if(talpha > 0)
for(int i = 0; i < color.length; i++)
color[i].setRGBA((tmpcolor[i].getRed()*alpha2 + color[i].getRed()*alpha) / talpha,
(tmpcolor[i].getGreen()*alpha2 + color[i].getGreen()*alpha) / talpha,
(tmpcolor[i].getBlue()*alpha2 + color[i].getBlue()*alpha) / talpha, talpha);
(tmpcolor[i].getGreen()*alpha2 + color[i].getGreen()*alpha) / talpha,
(tmpcolor[i].getBlue()*alpha2 + color[i].getBlue()*alpha) / talpha, talpha);
else
for(int i = 0; i < color.length; i++)
color[i].setTransparent();

return (talpha >= 254); /* If only one short, no meaningful contribution left */
}
}
}
/**
* Ray ended - used to report that ray has exited map (called if renderer has not reported complete)
*/
Expand Down Expand Up @@ -324,7 +332,7 @@ public void setLastBlockState(DynmapBlockState new_lastbs) {
public HDShaderState getStateInstance(HDMap map, MapChunkCache cache, MapIterator mapiter, int scale) {
return new OurShaderState(mapiter, map, cache, scale);
}

/* Add shader's contributions to JSON for map object */
public void addClientConfiguration(JSONObject mapObject) {
s(mapObject, "shader", name);
Expand Down
1 change: 1 addition & 0 deletions fabric-1.14.4/src/main/resources/configuration.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ components:
spawnbedhidebydefault: true
spawnbedminzoom: 0
spawnbedformat: "%name%'s bed"
spawnbedremoveonplayerleave: true
# (optional) Show world border (vanilla 1.8+)
showworldborder: true
worldborderlabel: "Border"
Expand Down
1 change: 1 addition & 0 deletions fabric-1.15.2/src/main/resources/configuration.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ components:
spawnbedhidebydefault: true
spawnbedminzoom: 0
spawnbedformat: "%name%'s bed"
spawnbedremoveonplayerleave: true
# (optional) Show world border (vanilla 1.8+)
showworldborder: true
worldborderlabel: "Border"
Expand Down
1 change: 1 addition & 0 deletions fabric-1.16.4/src/main/resources/configuration.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ components:
spawnbedhidebydefault: true
spawnbedminzoom: 0
spawnbedformat: "%name%'s bed"
spawnbedremoveonplayerleave: true
# (optional) Show world border (vanilla 1.8+)
showworldborder: true
worldborderlabel: "Border"
Expand Down
1 change: 1 addition & 0 deletions fabric-1.17.1/src/main/resources/configuration.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ components:
spawnbedhidebydefault: true
spawnbedminzoom: 0
spawnbedformat: "%name%'s bed"
spawnbedremoveonplayerleave: true
# (optional) Show world border (vanilla 1.8+)
showworldborder: true
worldborderlabel: "Border"
Expand Down
1 change: 1 addition & 0 deletions fabric-1.18.2/src/main/resources/configuration.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ components:
spawnbedhidebydefault: true
spawnbedminzoom: 0
spawnbedformat: "%name%'s bed"
spawnbedremoveonplayerleave: true
# (optional) Show world border (vanilla 1.8+)
showworldborder: true
worldborderlabel: "Border"
Expand Down
1 change: 1 addition & 0 deletions fabric-1.19.4/src/main/resources/configuration.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ components:
spawnbedhidebydefault: true
spawnbedminzoom: 0
spawnbedformat: "%name%'s bed"
spawnbedremoveonplayerleave: true
# (optional) Show world border (vanilla 1.8+)
showworldborder: true
worldborderlabel: "Border"
Expand Down
1 change: 1 addition & 0 deletions fabric-1.20.2/src/main/resources/configuration.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ components:
spawnbedhidebydefault: true
spawnbedminzoom: 0
spawnbedformat: "%name%'s bed"
spawnbedremoveonplayerleave: true
# (optional) Show world border (vanilla 1.8+)
showworldborder: true
worldborderlabel: "Border"
Expand Down
1 change: 1 addition & 0 deletions fabric-1.20.4/src/main/resources/configuration.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ components:
spawnbedhidebydefault: true
spawnbedminzoom: 0
spawnbedformat: "%name%'s bed"
spawnbedremoveonplayerleave: true
# (optional) Show world border (vanilla 1.8+)
showworldborder: true
worldborderlabel: "Border"
Expand Down
1 change: 1 addition & 0 deletions fabric-1.20/src/main/resources/configuration.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ components:
spawnbedhidebydefault: true
spawnbedminzoom: 0
spawnbedformat: "%name%'s bed"
spawnbedremoveonplayerleave: true
# (optional) Show world border (vanilla 1.8+)
showworldborder: true
worldborderlabel: "Border"
Expand Down
1 change: 1 addition & 0 deletions forge-1.12.2/src/main/resources/configuration.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ components:
spawnbedhidebydefault: true
spawnbedminzoom: 0
spawnbedformat: "%name%'s bed"
spawnbedremoveonplayerleave: true
# (optional) Show world border (vanilla 1.8+)
showworldborder: true
worldborderlabel: "Border"
Expand Down
Loading