103 lines
3.1 KiB
Java
103 lines
3.1 KiB
Java
package org.dynmap.kzedmap;
|
|
|
|
import org.dynmap.DynmapChunk;
|
|
import org.dynmap.DynmapWorld;
|
|
import org.dynmap.MapManager;
|
|
|
|
import java.io.File;
|
|
import java.util.List;
|
|
|
|
import org.dynmap.MapTile;
|
|
import org.dynmap.utils.MapChunkCache;
|
|
|
|
public class KzedMapTile extends MapTile {
|
|
public KzedMap map;
|
|
public MapTileRenderer renderer;
|
|
public int px, py;
|
|
private String fname;
|
|
private String fname_day;
|
|
|
|
// Hack.
|
|
public File file = null;
|
|
|
|
public KzedMapTile(DynmapWorld world, KzedMap map, MapTileRenderer renderer, int px, int py) {
|
|
super(world);
|
|
this.map = map;
|
|
this.renderer = renderer;
|
|
this.px = px;
|
|
this.py = py;
|
|
}
|
|
|
|
@Override
|
|
public String getFilename() {
|
|
if(fname == null) {
|
|
if(map.isBigWorldMap(world))
|
|
fname = renderer.getPrefix() + "/" + (px >> 12) + '_' + (py >> 12) + '/' + px + "_" + py + ".png";
|
|
else
|
|
fname = renderer.getPrefix() + "_" + px + "_" + py + ".png";
|
|
}
|
|
return fname;
|
|
}
|
|
|
|
@Override
|
|
public String getDayFilename() {
|
|
if(fname_day == null) {
|
|
if(map.isBigWorldMap(world))
|
|
fname_day = renderer.getPrefix() + "_day/" + (px >> 12) + '_' + (py >> 12) + '/' + px + "_" + py + ".png";
|
|
else
|
|
fname_day = renderer.getPrefix() + "_day_" + px + "_" + py + ".png";
|
|
}
|
|
return fname_day;
|
|
}
|
|
|
|
@Override
|
|
public int hashCode() {
|
|
return px ^ py ^ map.getName().hashCode() ^ getWorld().getName().hashCode();
|
|
}
|
|
|
|
@Override
|
|
public boolean equals(Object obj) {
|
|
if (obj instanceof KzedMapTile) {
|
|
return equals((KzedMapTile) obj);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public boolean equals(KzedMapTile o) {
|
|
return o.px == px && o.py == py && (o.map == map) && (o.getWorld() == getWorld());
|
|
}
|
|
|
|
public String getKey() {
|
|
return getWorld().getName() + "." + renderer.getPrefix();
|
|
}
|
|
|
|
public String toString() {
|
|
return getWorld().getName() + ":" + getFilename();
|
|
}
|
|
|
|
public boolean render(MapChunkCache cache, String mapname) {
|
|
boolean rslt = false;
|
|
for(MapTileRenderer r : map.renderers) {
|
|
if((mapname == null) || (r.getName().equals(mapname))) {
|
|
KzedMapTile t = new KzedMapTile(world, map, r, px, py);
|
|
rslt |= map.render(cache, t, MapManager.mapman.getTileFile(t));
|
|
}
|
|
}
|
|
return rslt;
|
|
}
|
|
|
|
public List<DynmapChunk> getRequiredChunks() {
|
|
return map.getRequiredChunks(this);
|
|
}
|
|
|
|
public MapTile[] getAdjecentTiles() {
|
|
return map.getAdjecentTiles(this);
|
|
}
|
|
|
|
public boolean isBiomeDataNeeded() { return map.isBiomeDataNeeded(); }
|
|
public boolean isHightestBlockYDataNeeded() { return false; }
|
|
public boolean isRawBiomeDataNeeded() { return map.isRawBiomeDataNeeded(); }
|
|
public boolean isBlockTypeDataNeeded() { return true; }
|
|
public int tileOrdinalX() { return px >> 7; }
|
|
public int tileOrdinalY() { return py >> 7; }
|
|
}
|