mirror of https://github.com/webbukkit/dynmap.git
Add blockname and statename support to CTM
This commit is contained in:
parent
41a6a14fbd
commit
b24f92cdd0
|
@ -130,7 +130,6 @@ public class DynmapCore implements DynmapCommonAPI {
|
||||||
private boolean persist_ids_by_ip = false;
|
private boolean persist_ids_by_ip = false;
|
||||||
private int snapshotcachesize;
|
private int snapshotcachesize;
|
||||||
private boolean snapshotsoftref;
|
private boolean snapshotsoftref;
|
||||||
private int[] blockmaterialmap = new int[0];
|
|
||||||
private String[] biomenames = new String[0];
|
private String[] biomenames = new String[0];
|
||||||
private Map<String, Integer> blockmap = null;
|
private Map<String, Integer> blockmap = null;
|
||||||
private Map<String, Integer> itemmap = null;
|
private Map<String, Integer> itemmap = null;
|
||||||
|
@ -198,18 +197,7 @@ public class DynmapCore implements DynmapCommonAPI {
|
||||||
server = srv;
|
server = srv;
|
||||||
}
|
}
|
||||||
public final DynmapServerInterface getServer() { return server; }
|
public final DynmapServerInterface getServer() { return server; }
|
||||||
|
|
||||||
public final void setBlockMaterialMap(int[] materials) {
|
|
||||||
blockmaterialmap = materials;
|
|
||||||
}
|
|
||||||
public final int[] getBlockMaterialMap() {
|
|
||||||
return blockmaterialmap;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final Map<String, Integer> getBlockIDMap() {
|
|
||||||
return blockmap;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final void setBiomeNames(String[] names) {
|
public final void setBiomeNames(String[] names) {
|
||||||
biomenames = names;
|
biomenames = names;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.BitSet;
|
import java.util.BitSet;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
@ -30,14 +29,11 @@ public class CTMTexturePack {
|
||||||
private String[] ctpfiles;
|
private String[] ctpfiles;
|
||||||
private TexturePackLoader tpl;
|
private TexturePackLoader tpl;
|
||||||
private CTMProps[][] bytilelist;
|
private CTMProps[][] bytilelist;
|
||||||
private CTMProps[][] byblocklist;
|
private CTMProps[][] bybaseblockstatelist;
|
||||||
private BitSet mappedtiles;
|
private BitSet mappedtiles;
|
||||||
private BitSet mappedblocks;
|
private BitSet mappedblocks;
|
||||||
private Map<String, Integer> blocknames;
|
|
||||||
private int[] blockmaterials;
|
|
||||||
private String[] biomenames;
|
private String[] biomenames;
|
||||||
|
|
||||||
private String ctmpath;
|
|
||||||
private String vanillatextures;
|
private String vanillatextures;
|
||||||
|
|
||||||
static final int BOTTOM_FACE = 0; // 0, -1, 0
|
static final int BOTTOM_FACE = 0; // 0, -1, 0
|
||||||
|
@ -305,7 +301,16 @@ public class CTMTexturePack {
|
||||||
return parseInt(p, fld, def);
|
return parseInt(p, fld, def);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int[] getIDList(Properties properties, String key, String type, Map<String, Integer> blocknames) {
|
private void addBlockStateToIDSet(Set<Integer> list, DynmapBlockState bs) {
|
||||||
|
list.add(bs.globalStateIndex);
|
||||||
|
}
|
||||||
|
private void addBaseBlockStateToIDSet(Set<Integer> list, DynmapBlockState bs) {
|
||||||
|
bs = bs.baseState;
|
||||||
|
for (int i = 0; i < bs.getStateCount(); i++) {
|
||||||
|
list.add(bs.getStateByIndex(i).globalStateIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private int[] getIDList(Properties properties, String key, String type) {
|
||||||
Set<Integer> list = new HashSet<Integer>();
|
Set<Integer> list = new HashSet<Integer>();
|
||||||
String property = properties.getProperty(key, "");
|
String property = properties.getProperty(key, "");
|
||||||
for (String token : property.split("\\s+")) {
|
for (String token : property.split("\\s+")) {
|
||||||
|
@ -313,7 +318,13 @@ public class CTMTexturePack {
|
||||||
} else if (token.matches("\\d+")) {
|
} else if (token.matches("\\d+")) {
|
||||||
try {
|
try {
|
||||||
int id = Integer.parseInt(token);
|
int id = Integer.parseInt(token);
|
||||||
list.add(id);
|
DynmapBlockState bs = DynmapBlockState.getStateByLegacyBlockID(id);
|
||||||
|
if (bs == null) {
|
||||||
|
Log.info("Unknown Legacy block ID in CTM: " + token);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
addBaseBlockStateToIDSet(list, bs);
|
||||||
|
}
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
Log.info("Bad ID token: " + token);
|
Log.info("Bad ID token: " + token);
|
||||||
}
|
}
|
||||||
|
@ -321,9 +332,25 @@ public class CTMTexturePack {
|
||||||
if (token.indexOf(':') < 0) { // No 'modid:'?
|
if (token.indexOf(':') < 0) { // No 'modid:'?
|
||||||
token = "minecraft:" + token;
|
token = "minecraft:" + token;
|
||||||
}
|
}
|
||||||
Integer id = blocknames.get(token);
|
String[] toks = token.split(":");
|
||||||
if (id != null) {
|
DynmapBlockState bs;
|
||||||
list.add(id);
|
boolean addbase = false;
|
||||||
|
// If blockname:statename
|
||||||
|
if (toks.length > 2) {
|
||||||
|
bs = DynmapBlockState.getStateByNameAndState(toks[0] + ":" + toks[1], toks[2]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bs = DynmapBlockState.getBaseStateByName(token);
|
||||||
|
addbase = true;
|
||||||
|
}
|
||||||
|
if (bs.isAir()) {
|
||||||
|
Log.info("Unknown block ID in CTM: " + token);
|
||||||
|
}
|
||||||
|
else if (addbase) {
|
||||||
|
addBaseBlockStateToIDSet(list, bs);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
addBlockStateToIDSet(list, bs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -331,7 +358,14 @@ public class CTMTexturePack {
|
||||||
Matcher m = Pattern.compile(type + "(\\d+)").matcher(name);
|
Matcher m = Pattern.compile(type + "(\\d+)").matcher(name);
|
||||||
if (m.find()) {
|
if (m.find()) {
|
||||||
try {
|
try {
|
||||||
list.add(Integer.parseInt(m.group(1)));
|
int id = Integer.parseInt(m.group(1));
|
||||||
|
DynmapBlockState bs = DynmapBlockState.getStateByLegacyBlockID(id);
|
||||||
|
if (bs == null) {
|
||||||
|
Log.info("Unknown Legacy block ID from filename in CTM: " + name);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
addBlockStateToIDSet(list, bs);
|
||||||
|
}
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
Log.info("Bad block number: " + name);
|
Log.info("Bad block number: " + name);
|
||||||
}
|
}
|
||||||
|
@ -530,7 +564,10 @@ public class CTMTexturePack {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (id >= 0) {
|
if (id >= 0) {
|
||||||
this.matchBlocks = new int[] { id };
|
DynmapBlockState bs = DynmapBlockState.getStateByLegacyBlockID(id);
|
||||||
|
if (bs != null) {
|
||||||
|
this.matchBlocks = new int[] { bs.globalStateIndex };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -548,7 +585,7 @@ public class CTMTexturePack {
|
||||||
if(last_dot > 0) {
|
if(last_dot > 0) {
|
||||||
this.name = this.name.substring(0, last_dot);
|
this.name = this.name.substring(0, last_dot);
|
||||||
}
|
}
|
||||||
this.matchBlocks = getIDList(p, "matchBlocks", "block", tp.blocknames);
|
this.matchBlocks = getIDList(p, "matchBlocks", "block");
|
||||||
getMatchTiles(p);
|
getMatchTiles(p);
|
||||||
getMethod(p);
|
getMethod(p);
|
||||||
this.tiles = parseTileNames(p.getProperty("tiles"));
|
this.tiles = parseTileNames(p.getProperty("tiles"));
|
||||||
|
@ -841,7 +878,7 @@ public class CTMTexturePack {
|
||||||
}
|
}
|
||||||
switch (connect) {
|
switch (connect) {
|
||||||
case BLOCK:
|
case BLOCK:
|
||||||
return neighbor == ctx.blk;
|
return neighbor.baseState == ctx.blk.baseState;
|
||||||
|
|
||||||
case TILE:
|
case TILE:
|
||||||
int txt = TexturePack.getTextureIDAt(ctx.mapiter, neighbor, ctx.laststep);
|
int txt = TexturePack.getTextureIDAt(ctx.mapiter, neighbor, ctx.laststep);
|
||||||
|
@ -866,20 +903,21 @@ public class CTMTexturePack {
|
||||||
public CTMTexturePack(TexturePackLoader tpl, TexturePack tp, DynmapCore core, boolean is_rp) {
|
public CTMTexturePack(TexturePackLoader tpl, TexturePack tp, DynmapCore core, boolean is_rp) {
|
||||||
ArrayList<String> files = new ArrayList<String>();
|
ArrayList<String> files = new ArrayList<String>();
|
||||||
this.tpl = tpl;
|
this.tpl = tpl;
|
||||||
blocknames = core.getBlockIDMap();
|
|
||||||
blockmaterials = core.getBlockMaterialMap();
|
|
||||||
biomenames = core.getBiomeNames();
|
biomenames = core.getBiomeNames();
|
||||||
Set<String> ent = tpl.getEntries();
|
Set<String> ent = tpl.getEntries();
|
||||||
|
String ctmpath;
|
||||||
|
String ctmpath2;
|
||||||
if (is_rp) {
|
if (is_rp) {
|
||||||
ctmpath = "assets/minecraft/mcpatcher/ctm/";
|
ctmpath = "assets/minecraft/mcpatcher/ctm/";
|
||||||
|
ctmpath2 = "assets/minecraft/optifine/ctm/";
|
||||||
vanillatextures = "assets/%1$s/textures/blocks/%2$s";
|
vanillatextures = "assets/%1$s/textures/blocks/%2$s";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ctmpath = "ctm/";
|
ctmpath = ctmpath2 = "ctm/";
|
||||||
vanillatextures = "textures/blocks/%2$s";
|
vanillatextures = "textures/blocks/%2$s";
|
||||||
}
|
}
|
||||||
for (String name : ent) {
|
for (String name : ent) {
|
||||||
if(name.startsWith(ctmpath) && name.endsWith(".properties")) {
|
if((name.startsWith(ctmpath) || name.startsWith(ctmpath2)) && name.endsWith(".properties")) {
|
||||||
files.add(name);
|
files.add(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -920,7 +958,7 @@ public class CTMTexturePack {
|
||||||
*/
|
*/
|
||||||
private void processFiles(DynmapCore core) {
|
private void processFiles(DynmapCore core) {
|
||||||
bytilelist = new CTMProps[256][];
|
bytilelist = new CTMProps[256][];
|
||||||
byblocklist = new CTMProps[256][];
|
bybaseblockstatelist = new CTMProps[256][];
|
||||||
mappedtiles = new BitSet();
|
mappedtiles = new BitSet();
|
||||||
mappedblocks = new BitSet();
|
mappedblocks = new BitSet();
|
||||||
|
|
||||||
|
@ -946,7 +984,7 @@ public class CTMTexturePack {
|
||||||
if(ctmp.isValid(f)) {
|
if(ctmp.isValid(f)) {
|
||||||
ctmp.registerTiles(this.vanillatextures, f);
|
ctmp.registerTiles(this.vanillatextures, f);
|
||||||
bytilelist = addToList(bytilelist, mappedtiles, ctmp.matchTileIcons, ctmp);
|
bytilelist = addToList(bytilelist, mappedtiles, ctmp.matchTileIcons, ctmp);
|
||||||
byblocklist = addToList(byblocklist, mappedblocks, ctmp.matchBlocks, ctmp);
|
bybaseblockstatelist = addToList(bybaseblockstatelist, mappedblocks, ctmp.matchBlocks, ctmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException iox) {
|
} catch (IOException iox) {
|
||||||
|
@ -957,6 +995,22 @@ public class CTMTexturePack {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// for (int i = 0; i < bybaseblockstatelist.length; i++) {
|
||||||
|
// CTMProps[] p = bybaseblockstatelist[i];
|
||||||
|
// if (p != null) {
|
||||||
|
// DynmapBlockState bs = DynmapBlockState.getStateByGlobalIndex(i);
|
||||||
|
// Log.info(bs.blockName + ":" + bs.stateName + "(" + i + "): legacyID=" + bs.legacyBlockID);
|
||||||
|
// for (CTMProps pp : p) {
|
||||||
|
// Log.info(" " + pp.name + ", faces=" + pp.faces + ",connect=" + pp.connect + ", meta=" + pp.metadata + ", method=" + pp.method);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// for (int i = 0; i < mappedblocks.length(); i++) {
|
||||||
|
// if (mappedblocks.get(i)) {
|
||||||
|
// DynmapBlockState bs = DynmapBlockState.getStateByGlobalIndex(i);
|
||||||
|
// Log.info("mapped:" + bs.blockName + ":" + bs.stateName + "(" + i + "): legacyID=" + bs.legacyBlockID);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Constants for rotateUV
|
// Constants for rotateUV
|
||||||
|
@ -1043,18 +1097,15 @@ public class CTMTexturePack {
|
||||||
final boolean checkMaterialMatch(DynmapBlockState neighbor) {
|
final boolean checkMaterialMatch(DynmapBlockState neighbor) {
|
||||||
if (blk == neighbor)
|
if (blk == neighbor)
|
||||||
return true;
|
return true;
|
||||||
else if ((blk.globalStateIndex < blockmaterials.length) && (neighbor.globalStateIndex < blockmaterials.length)) {
|
else
|
||||||
return blockmaterials[blk.globalStateIndex] == blockmaterials[neighbor.globalStateIndex];
|
return blk.material.equals(neighbor.material);
|
||||||
}
|
|
||||||
else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int mapTexture(MapIterator mapiter, DynmapBlockState blk, BlockStep laststep, int textid, HDShaderState ss) {
|
public int mapTexture(MapIterator mapiter, DynmapBlockState blk, BlockStep laststep, int textid, HDShaderState ss) {
|
||||||
int newtext = -1;
|
int newtext = -1;
|
||||||
if ((!this.mappedblocks.get(blk.globalStateIndex)) && ((textid < 0) || (!this.mappedtiles.get(textid)))) {
|
int gidx = blk.globalStateIndex;
|
||||||
|
if ((!this.mappedblocks.get(gidx)) && ((textid < 0) || (!this.mappedtiles.get(textid)))) {
|
||||||
return textid;
|
return textid;
|
||||||
}
|
}
|
||||||
// See if cached result
|
// See if cached result
|
||||||
|
@ -1075,8 +1126,8 @@ public class CTMTexturePack {
|
||||||
if ((textid >= 0) && (textid < bytilelist.length)) {
|
if ((textid >= 0) && (textid < bytilelist.length)) {
|
||||||
newtext = mapTextureByList(bytilelist[textid], ctx);
|
newtext = mapTextureByList(bytilelist[textid], ctx);
|
||||||
}
|
}
|
||||||
if ((newtext < 0) && (blk.globalStateIndex < byblocklist.length)) {
|
if ((newtext < 0) && (gidx < bybaseblockstatelist.length)) {
|
||||||
newtext = mapTextureByList(byblocklist[blk.globalStateIndex], ctx);
|
newtext = mapTextureByList(bybaseblockstatelist[gidx], ctx);
|
||||||
}
|
}
|
||||||
/* If matched, check for second match */
|
/* If matched, check for second match */
|
||||||
if (newtext >= 0) {
|
if (newtext >= 0) {
|
||||||
|
|
|
@ -20,10 +20,14 @@ public class DynmapBlockState {
|
||||||
public final String stateName;
|
public final String stateName;
|
||||||
// Overall state index (uniquely assigned autoincrement number for state: packed, zero based)
|
// Overall state index (uniquely assigned autoincrement number for state: packed, zero based)
|
||||||
public final int globalStateIndex;
|
public final int globalStateIndex;
|
||||||
|
// Legacy block ID (if defined - otherwise -1)
|
||||||
|
public final int legacyBlockID;
|
||||||
// List of block states (only defined on base block), indexed by stateIndex (null if single state base block)
|
// List of block states (only defined on base block), indexed by stateIndex (null if single state base block)
|
||||||
private DynmapBlockState[] states;
|
private DynmapBlockState[] states;
|
||||||
// Full name for state (base name, or base name[state name])
|
// Full name for state (base name, or base name[state name])
|
||||||
private final String fullName;
|
private final String fullName;
|
||||||
|
// Material string
|
||||||
|
public final String material;
|
||||||
// Next global state index
|
// Next global state index
|
||||||
private static int nextGlobalStateIndex = 0;
|
private static int nextGlobalStateIndex = 0;
|
||||||
// Match flags
|
// Match flags
|
||||||
|
@ -41,6 +45,8 @@ public class DynmapBlockState {
|
||||||
private static HashMap<String, DynmapBlockState> blocksByName = new HashMap<String, DynmapBlockState>();
|
private static HashMap<String, DynmapBlockState> blocksByName = new HashMap<String, DynmapBlockState>();
|
||||||
// Map of states by global state index
|
// Map of states by global state index
|
||||||
private static HashMap<Integer, DynmapBlockState> blocksByIndex = new HashMap<Integer, DynmapBlockState>();
|
private static HashMap<Integer, DynmapBlockState> blocksByIndex = new HashMap<Integer, DynmapBlockState>();
|
||||||
|
// Map of base states by legacy ID
|
||||||
|
private static HashMap<Integer, DynmapBlockState> blocksByLegacyID = new HashMap<Integer, DynmapBlockState>();
|
||||||
|
|
||||||
// Well known block names (some versions might need to overwrite these)
|
// Well known block names (some versions might need to overwrite these)
|
||||||
public static String AIR_BLOCK = "minecraft:air";
|
public static String AIR_BLOCK = "minecraft:air";
|
||||||
|
@ -75,22 +81,37 @@ public class DynmapBlockState {
|
||||||
private static HashSet<String> water_blocks = new HashSet<String>(Arrays.asList(WATER_BLOCK, FLOWING_WATER_BLOCK));
|
private static HashSet<String> water_blocks = new HashSet<String>(Arrays.asList(WATER_BLOCK, FLOWING_WATER_BLOCK));
|
||||||
|
|
||||||
// Well known base blocks - air
|
// Well known base blocks - air
|
||||||
public static final DynmapBlockState AIR = new DynmapBlockState(null, 0, AIR_BLOCK, "");
|
public static final DynmapBlockState AIR = new DynmapBlockState(null, 0, AIR_BLOCK, "", "AIR", 0);
|
||||||
|
|
||||||
private static DynmapBlockState still_water = null;
|
private static DynmapBlockState still_water = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for block state
|
* Constructor for block state
|
||||||
* @param base - base block state (null if first/only state for block)
|
* @param base - base block state (null if first/only state for block)
|
||||||
* @param stateidx - index of state (0-based relative to the base block state)
|
* @param stateidx - index of state (0-based relative to the base block state)
|
||||||
* @param blkname - block name, in modid:blockname format (minecraft:blockname for vanilla)
|
* @param blkname - block name, in modid:blockname format (minecraft:blockname for vanilla)
|
||||||
* @param statename - block state name: null if single state block, "attrib=value,..." for 1.13+, "meta=value" for 1.12-
|
* @param statename - block state name: null if single state block, "attrib=value,..." for 1.13+, "meta=value" for 1.12-
|
||||||
|
* @param material - material name string
|
||||||
*/
|
*/
|
||||||
public DynmapBlockState(DynmapBlockState base, int stateidx, String blkname, String statename) {
|
public DynmapBlockState(DynmapBlockState base, int stateidx, String blkname, String statename, String material) {
|
||||||
|
this(base, stateidx, blkname, statename, material, -1);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Constructor for block state
|
||||||
|
* @param base - base block state (null if first/only state for block)
|
||||||
|
* @param stateidx - index of state (0-based relative to the base block state)
|
||||||
|
* @param blkname - block name, in modid:blockname format (minecraft:blockname for vanilla)
|
||||||
|
* @param statename - block state name: null if single state block, "attrib=value,..." for 1.13+, "meta=value" for 1.12-
|
||||||
|
* @param material - material name string
|
||||||
|
* @param legacyblkid - legacy block ID (if defined), otherwise -1
|
||||||
|
*/
|
||||||
|
public DynmapBlockState(DynmapBlockState base, int stateidx, String blkname, String statename, String material, int legacyblkid) {
|
||||||
globalStateIndex = (nextGlobalStateIndex++); // Assign index
|
globalStateIndex = (nextGlobalStateIndex++); // Assign index
|
||||||
if (base == null) base = this;
|
if (base == null) base = this;
|
||||||
baseState = base;
|
baseState = base;
|
||||||
stateIndex = stateidx;
|
stateIndex = stateidx;
|
||||||
|
legacyBlockID = legacyblkid;
|
||||||
|
this.material = material;
|
||||||
if (blkname.indexOf(':') == -1) { // No mod:, assume minecraft:
|
if (blkname.indexOf(':') == -1) { // No mod:, assume minecraft:
|
||||||
blkname = "minecraft:" + blkname;
|
blkname = "minecraft:" + blkname;
|
||||||
}
|
}
|
||||||
|
@ -114,6 +135,9 @@ public class DynmapBlockState {
|
||||||
// If base block state, add to map
|
// If base block state, add to map
|
||||||
if (base == this) {
|
if (base == this) {
|
||||||
blocksByName.put(blkname, this);
|
blocksByName.put(blkname, this);
|
||||||
|
if (legacyBlockID >= 0) {
|
||||||
|
blocksByLegacyID.put(legacyBlockID, this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (stateName.length() > 0) {
|
if (stateName.length() > 0) {
|
||||||
fullName = blockName + "[" + stateName + "]";
|
fullName = blockName + "[" + stateName + "]";
|
||||||
|
@ -179,6 +203,34 @@ public class DynmapBlockState {
|
||||||
DynmapBlockState bs = blocksByIndex.get(gidx);
|
DynmapBlockState bs = blocksByIndex.get(gidx);
|
||||||
return (bs != null) ? bs : AIR;
|
return (bs != null) ? bs : AIR;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Find block state by legacy ID
|
||||||
|
* @param legacyid - legacy ID
|
||||||
|
* @return block base state, or null if not found
|
||||||
|
*/
|
||||||
|
public static final DynmapBlockState getStateByLegacyBlockID(int legacyid) {
|
||||||
|
return blocksByLegacyID.get(legacyid);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Find block state by name and state name
|
||||||
|
* @param name - block name
|
||||||
|
* @param statename - state name
|
||||||
|
* @return base block state, or AIR if not found
|
||||||
|
*/
|
||||||
|
public static final DynmapBlockState getStateByNameAndState(String name, String statename) {
|
||||||
|
DynmapBlockState blk = getBaseStateByName(name);
|
||||||
|
if (blk != null) {
|
||||||
|
if (blk.states != null) {
|
||||||
|
for (DynmapBlockState bb : blk.states) {
|
||||||
|
if (bb.stateName.contains(statename)) {
|
||||||
|
return bb;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
blk = null;
|
||||||
|
}
|
||||||
|
return (blk != null) ? blk : AIR;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Get current top of range of block state global indexes, plus 1
|
* Get current top of range of block state global indexes, plus 1
|
||||||
* @return length of global block state index range (N, for 0-(N-1))
|
* @return length of global block state index range (N, for 0-(N-1))
|
||||||
|
|
|
@ -126,20 +126,21 @@ public class BukkitVersionHelperSpigot113_1 extends BukkitVersionHelperCB {
|
||||||
int off2 = fname.indexOf(']');
|
int off2 = fname.indexOf(']');
|
||||||
sb = fname.substring(off1+1, off2);
|
sb = fname.substring(off1+1, off2);
|
||||||
}
|
}
|
||||||
DynmapBlockState bs = new DynmapBlockState(lastbs, idx, bname, sb);
|
Material mat = bd.getMaterial();
|
||||||
|
DynmapBlockState bs = new DynmapBlockState(lastbs, idx, bname, sb, mat.toString());
|
||||||
if ((!bd.s().e()) && ((bd.getBlock() instanceof BlockFluids) == false)) { // Test if fluid type for block is not empty
|
if ((!bd.s().e()) && ((bd.getBlock() instanceof BlockFluids) == false)) { // Test if fluid type for block is not empty
|
||||||
bs.setWaterlogged();
|
bs.setWaterlogged();
|
||||||
}
|
}
|
||||||
if (bd.getMaterial() == Material.AIR) {
|
if (mat == Material.AIR) {
|
||||||
bs.setAir();
|
bs.setAir();
|
||||||
}
|
}
|
||||||
if (bd.getMaterial() == Material.LEAVES) {
|
if (mat == Material.LEAVES) {
|
||||||
bs.setLeaves();
|
bs.setLeaves();
|
||||||
}
|
}
|
||||||
if (bd.getBlock() instanceof BlockLogAbstract) {
|
if (bd.getBlock() instanceof BlockLogAbstract) {
|
||||||
bs.setLog();
|
bs.setLog();
|
||||||
}
|
}
|
||||||
if (bd.getMaterial().isSolid()) {
|
if (mat.isSolid()) {
|
||||||
bs.setSolid();
|
bs.setSolid();
|
||||||
}
|
}
|
||||||
dataToState.put(bd, bs);
|
dataToState.put(bd, bs);
|
||||||
|
|
|
@ -126,20 +126,21 @@ public class BukkitVersionHelperSpigot113_2 extends BukkitVersionHelperCB {
|
||||||
int off2 = fname.indexOf(']');
|
int off2 = fname.indexOf(']');
|
||||||
sb = fname.substring(off1+1, off2);
|
sb = fname.substring(off1+1, off2);
|
||||||
}
|
}
|
||||||
DynmapBlockState bs = new DynmapBlockState(lastbs, idx, bname, sb);
|
Material mat = bd.getMaterial();
|
||||||
|
DynmapBlockState bs = new DynmapBlockState(lastbs, idx, bname, sb, mat.toString());
|
||||||
if ((!bd.s().e()) && ((bd.getBlock() instanceof BlockFluids) == false)) { // Test if fluid type for block is not empty
|
if ((!bd.s().e()) && ((bd.getBlock() instanceof BlockFluids) == false)) { // Test if fluid type for block is not empty
|
||||||
bs.setWaterlogged();
|
bs.setWaterlogged();
|
||||||
}
|
}
|
||||||
if (bd.getMaterial() == Material.AIR) {
|
if (mat == Material.AIR) {
|
||||||
bs.setAir();
|
bs.setAir();
|
||||||
}
|
}
|
||||||
if (bd.getMaterial() == Material.LEAVES) {
|
if (mat == Material.LEAVES) {
|
||||||
bs.setLeaves();
|
bs.setLeaves();
|
||||||
}
|
}
|
||||||
if (bd.getBlock() instanceof BlockLogAbstract) {
|
if (bd.getBlock() instanceof BlockLogAbstract) {
|
||||||
bs.setLog();
|
bs.setLog();
|
||||||
}
|
}
|
||||||
if (bd.getMaterial().isSolid()) {
|
if (mat.isSolid()) {
|
||||||
bs.setSolid();
|
bs.setSolid();
|
||||||
}
|
}
|
||||||
dataToState.put(bd, bs);
|
dataToState.put(bd, bs);
|
||||||
|
|
|
@ -120,20 +120,21 @@ public class BukkitVersionHelperSpigot113 extends BukkitVersionHelperCB {
|
||||||
int off2 = fname.indexOf(']');
|
int off2 = fname.indexOf(']');
|
||||||
sb = fname.substring(off1+1, off2);
|
sb = fname.substring(off1+1, off2);
|
||||||
}
|
}
|
||||||
DynmapBlockState bs = new DynmapBlockState(lastbs, idx, bname, sb);
|
Material mat = bd.getMaterial();
|
||||||
|
DynmapBlockState bs = new DynmapBlockState(lastbs, idx, bname, sb, mat.toString());
|
||||||
if ((!bd.s().e()) && ((bd.getBlock() instanceof BlockFluids) == false)) { // Test if fluid type for block is not empty
|
if ((!bd.s().e()) && ((bd.getBlock() instanceof BlockFluids) == false)) { // Test if fluid type for block is not empty
|
||||||
bs.setWaterlogged();
|
bs.setWaterlogged();
|
||||||
}
|
}
|
||||||
if (bd.getMaterial() == Material.AIR) {
|
if (mat == Material.AIR) {
|
||||||
bs.setAir();
|
bs.setAir();
|
||||||
}
|
}
|
||||||
if (bd.getMaterial() == Material.LEAVES) {
|
if (mat == Material.LEAVES) {
|
||||||
bs.setLeaves();
|
bs.setLeaves();
|
||||||
}
|
}
|
||||||
if (bd.getBlock() instanceof BlockLogAbstract) {
|
if (bd.getBlock() instanceof BlockLogAbstract) {
|
||||||
bs.setLog();
|
bs.setLog();
|
||||||
}
|
}
|
||||||
if (bd.getMaterial().isSolid()) {
|
if (mat.isSolid()) {
|
||||||
bs.setSolid();
|
bs.setSolid();
|
||||||
}
|
}
|
||||||
dataToState.put(bd, bs);
|
dataToState.put(bd, bs);
|
||||||
|
|
|
@ -3,7 +3,7 @@ package org.dynmap.bukkit.helper;
|
||||||
public class BukkitMaterial {
|
public class BukkitMaterial {
|
||||||
public final String name;
|
public final String name;
|
||||||
public final boolean isSolid;
|
public final boolean isSolid;
|
||||||
private final boolean isLiquid;
|
public final boolean isLiquid;
|
||||||
public BukkitMaterial(String n, boolean sol, boolean liq) {
|
public BukkitMaterial(String n, boolean sol, boolean liq) {
|
||||||
name = n;
|
name = n;
|
||||||
isSolid = sol;
|
isSolid = sol;
|
||||||
|
|
|
@ -105,10 +105,6 @@ public abstract class BukkitVersionHelper {
|
||||||
* Get biome name list
|
* Get biome name list
|
||||||
*/
|
*/
|
||||||
public abstract String[] getBiomeNames();
|
public abstract String[] getBiomeNames();
|
||||||
/**
|
|
||||||
* Get block material index list
|
|
||||||
*/
|
|
||||||
public abstract int[] getBlockMaterialMap();
|
|
||||||
/**
|
/**
|
||||||
* Get list of online players
|
* Get list of online players
|
||||||
*/
|
*/
|
||||||
|
@ -151,11 +147,12 @@ public abstract class BukkitVersionHelper {
|
||||||
}
|
}
|
||||||
// Only do defined names, and not "air"
|
// Only do defined names, and not "air"
|
||||||
if (!bn.equals(DynmapBlockState.AIR_BLOCK)) {
|
if (!bn.equals(DynmapBlockState.AIR_BLOCK)) {
|
||||||
DynmapBlockState basebs = new DynmapBlockState(null, 0, bn, "meta=0");
|
|
||||||
stateByID[i << 4] = basebs;
|
|
||||||
BukkitMaterial mat = blkmat[i];
|
BukkitMaterial mat = blkmat[i];
|
||||||
for (int m = 1; m < 16; m++) {
|
DynmapBlockState basebs = null;
|
||||||
DynmapBlockState bs = new DynmapBlockState(basebs, m, bn, "meta=" + m);
|
for (int m = 0; m < 16; m++) {
|
||||||
|
String sn = helper.getStateStringByCombinedId(i, m);
|
||||||
|
DynmapBlockState bs = new DynmapBlockState(basebs, m, bn, sn, mat.name, i);
|
||||||
|
if (basebs == null) basebs = bs;
|
||||||
stateByID[(i << 4) + m] = bs;
|
stateByID[(i << 4) + m] = bs;
|
||||||
if (mat != null) {
|
if (mat != null) {
|
||||||
if (mat.name.equals("AIR")) {
|
if (mat.name.equals("AIR")) {
|
||||||
|
@ -174,10 +171,10 @@ public abstract class BukkitVersionHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int gidx = 0; gidx < DynmapBlockState.getGlobalIndexMax(); gidx++) {
|
//for (int gidx = 0; gidx < DynmapBlockState.getGlobalIndexMax(); gidx++) {
|
||||||
DynmapBlockState bs = DynmapBlockState.getStateByGlobalIndex(gidx);
|
// DynmapBlockState bs = DynmapBlockState.getStateByGlobalIndex(gidx);
|
||||||
Log.verboseinfo(gidx + ":" + bs.toString() + ", gidx=" + bs.globalStateIndex + ", sidx=" + bs.stateIndex);
|
// Log.verboseinfo(gidx + ":" + bs.toString() + ", gidx=" + bs.globalStateIndex + ", sidx=" + bs.stateIndex);
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Create chunk cache for given chunks of given world
|
* Create chunk cache for given chunks of given world
|
||||||
|
@ -200,4 +197,5 @@ public abstract class BukkitVersionHelper {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract String getStateStringByCombinedId(int blkid, int meta);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,8 @@ public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric {
|
||||||
private Method getbiomebyid;
|
private Method getbiomebyid;
|
||||||
private Method getbiomefunc;
|
private Method getbiomefunc;
|
||||||
private Method getidbybiome;
|
private Method getidbybiome;
|
||||||
|
private Method getbycombinedid;
|
||||||
|
|
||||||
private boolean isBadUnload = false;
|
private boolean isBadUnload = false;
|
||||||
|
|
||||||
public BukkitVersionHelperCB() {
|
public BukkitVersionHelperCB() {
|
||||||
|
@ -79,7 +81,7 @@ public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
material = getPrivateField(nmsblock, new String[] { "material" }, nmsmaterial);
|
material = getPrivateField(nmsblock, new String[] { "material" }, nmsmaterial);
|
||||||
|
getbycombinedid = getMethod(nmsblock, new String[] { "getByCombinedId" }, new Class[] { int.class });
|
||||||
// Get material methods
|
// Get material methods
|
||||||
material_issolid = getMethod(nmsmaterial, new String[] { "isSolid" }, nulltypes);
|
material_issolid = getMethod(nmsmaterial, new String[] { "isSolid" }, nulltypes);
|
||||||
material_isliquid = getMethod(nmsmaterial, new String[] { "isLiquid" }, nulltypes);
|
material_isliquid = getMethod(nmsmaterial, new String[] { "isLiquid" }, nulltypes);
|
||||||
|
@ -266,52 +268,6 @@ public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric {
|
||||||
}
|
}
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* Get block material index list
|
|
||||||
*/
|
|
||||||
public int[] getBlockMaterialMap() {
|
|
||||||
try {
|
|
||||||
int[] map = new int[4096];
|
|
||||||
Arrays.fill(map, -1);
|
|
||||||
if (blockbyid != null) {
|
|
||||||
Object[] byid = (Object[])blockbyid.get(nmsblock);
|
|
||||||
ArrayList<Object> mats = new ArrayList<Object>();
|
|
||||||
for (int i = 0; i < map.length; i++) {
|
|
||||||
if (byid[i] != null) {
|
|
||||||
Object mat = (Object)material.get(byid[i]);
|
|
||||||
if (mat != null) {
|
|
||||||
map[i] = mats.indexOf(mat);
|
|
||||||
if (map[i] < 0) {
|
|
||||||
map[i] = mats.size();
|
|
||||||
mats.add(mat);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (blockbyidfunc != null) {
|
|
||||||
ArrayList<Object> mats = new ArrayList<Object>();
|
|
||||||
for (int i = 0; i < map.length; i++) {
|
|
||||||
Object blk = blockbyidfunc.invoke(nmsblock, i);
|
|
||||||
if (blk != null) {
|
|
||||||
Object mat = (Object)material.get(blk);
|
|
||||||
if (mat != null) {
|
|
||||||
map[i] = mats.indexOf(mat);
|
|
||||||
if (map[i] < 0) {
|
|
||||||
map[i] = mats.size();
|
|
||||||
mats.add(mat);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return map;
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
} catch (IllegalAccessException e) {
|
|
||||||
} catch (InvocationTargetException e) {
|
|
||||||
}
|
|
||||||
return new int[0];
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Get material map by block ID
|
* Get material map by block ID
|
||||||
*/
|
*/
|
||||||
|
@ -419,4 +375,26 @@ public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isUnloadChunkBroken() { return isBadUnload; }
|
public boolean isUnloadChunkBroken() { return isBadUnload; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getStateStringByCombinedId(int blkid, int meta) {
|
||||||
|
int id = blkid | (meta << 12);
|
||||||
|
if (getbycombinedid != null) {
|
||||||
|
try {
|
||||||
|
Object iblockdata = getbycombinedid.invoke(nmsblock, id);
|
||||||
|
if (iblockdata != null) {
|
||||||
|
String nm = iblockdata.toString();
|
||||||
|
int off1 = nm.indexOf('[');
|
||||||
|
if (off1 >= 0) {
|
||||||
|
int off2 = nm.indexOf(']');
|
||||||
|
return nm.substring(off1+1, off2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IllegalAccessException x) {
|
||||||
|
} catch (IllegalArgumentException x) {
|
||||||
|
} catch (InvocationTargetException x) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "meta=" + meta;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,12 +139,6 @@ public class BukkitVersionHelperGlowstone extends BukkitVersionHelper {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String[] getBlockNames() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String[] bnames = {
|
private static final String[] bnames = {
|
||||||
"Ocean",
|
"Ocean",
|
||||||
"Plains",
|
"Plains",
|
||||||
|
@ -410,10 +404,11 @@ public class BukkitVersionHelperGlowstone extends BukkitVersionHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int[] getBlockMaterialMap() {
|
public String[] getBlockNames() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BukkitMaterial[] getMaterialList() {
|
public BukkitMaterial[] getMaterialList() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
@ -447,4 +442,9 @@ public class BukkitVersionHelperGlowstone extends BukkitVersionHelper {
|
||||||
return p.getHealth();
|
return p.getHealth();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getStateStringByCombinedId(int blkid, int meta) {
|
||||||
|
return "meta=" + meta;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import java.util.regex.Pattern;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.command.CommandBase;
|
import net.minecraft.command.CommandBase;
|
||||||
import net.minecraft.command.CommandException;
|
import net.minecraft.command.CommandException;
|
||||||
|
@ -171,31 +172,43 @@ public class DynmapPlugin
|
||||||
String bn = ui.getResourceDomain() + ":" + ui.getResourcePath();
|
String bn = ui.getResourceDomain() + ":" + ui.getResourcePath();
|
||||||
// Only do defined names, and not "air"
|
// Only do defined names, and not "air"
|
||||||
if (!bn.equals(DynmapBlockState.AIR_BLOCK)) {
|
if (!bn.equals(DynmapBlockState.AIR_BLOCK)) {
|
||||||
DynmapBlockState basebs = new DynmapBlockState(null, 0, bn, "meta=0");
|
DynmapBlockState basebs = null;
|
||||||
stateByID[i << 4] = basebs;
|
for (int m = 0; m < 16; m++) {
|
||||||
for (int m = 1; m < 16; m++) {
|
|
||||||
DynmapBlockState bs = new DynmapBlockState(basebs, m, bn, "meta=" + m);
|
|
||||||
stateByID[(i << 4) + m] = bs;
|
|
||||||
IBlockState blkstate = null;
|
IBlockState blkstate = null;
|
||||||
try {
|
try {
|
||||||
blkstate = b.getStateFromMeta(m);
|
blkstate = b.getStateFromMeta(m);
|
||||||
} catch (Exception x) {
|
} catch (Exception x) {
|
||||||
// Invalid meta
|
// Invalid meta
|
||||||
}
|
}
|
||||||
|
Material mat = Material.AIR;
|
||||||
|
String statename = "meta=" + m;
|
||||||
if (blkstate != null) {
|
if (blkstate != null) {
|
||||||
Material mat = blkstate.getMaterial();
|
mat = blkstate.getMaterial();
|
||||||
if (mat.isSolid()) {
|
String pstate = null;
|
||||||
bs.setSolid();
|
for(Entry<IProperty<?>, Comparable<?>> p : blkstate.getProperties().entrySet()) {
|
||||||
}
|
if (pstate == null)
|
||||||
if (mat == Material.AIR) {
|
pstate = "";
|
||||||
bs.setAir();
|
else
|
||||||
}
|
pstate += ",";
|
||||||
if (mat == Material.WOOD) {
|
pstate += p.getKey().getName() + "=" + p.getValue().toString();
|
||||||
bs.setLog();
|
|
||||||
}
|
|
||||||
if (mat == Material.LEAVES) {
|
|
||||||
bs.setLeaves();
|
|
||||||
}
|
}
|
||||||
|
if (pstate != null)
|
||||||
|
statename = pstate;
|
||||||
|
}
|
||||||
|
DynmapBlockState bs = new DynmapBlockState(basebs, m, bn, statename, mat.toString(), i);
|
||||||
|
if (basebs == null) basebs = bs;
|
||||||
|
stateByID[(i << 4) + m] = bs;
|
||||||
|
if (mat.isSolid()) {
|
||||||
|
bs.setSolid();
|
||||||
|
}
|
||||||
|
if (mat == Material.AIR) {
|
||||||
|
bs.setAir();
|
||||||
|
}
|
||||||
|
if (mat == Material.WOOD) {
|
||||||
|
bs.setLog();
|
||||||
|
}
|
||||||
|
if (mat == Material.LEAVES) {
|
||||||
|
bs.setLeaves();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1386,28 +1399,6 @@ public class DynmapPlugin
|
||||||
return lst;
|
return lst;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int[] getBlockMaterialMap() {
|
|
||||||
int[] map = new int[4096];
|
|
||||||
ArrayList<Material> mats = new ArrayList<Material>();
|
|
||||||
for (int i = 0; i < map.length; i++) {
|
|
||||||
Block b = getBlockByID(i);
|
|
||||||
if(b != null) {
|
|
||||||
Material mat = b.getBlockState().getBaseState().getMaterial();
|
|
||||||
if (mat != null) {
|
|
||||||
map[i] = mats.indexOf(mat);
|
|
||||||
if (map[i] < 0) {
|
|
||||||
map[i] = mats.size();
|
|
||||||
mats.add(mat);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
map[i] = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onEnable()
|
public void onEnable()
|
||||||
{
|
{
|
||||||
/* Get MC version */
|
/* Get MC version */
|
||||||
|
@ -1445,7 +1436,6 @@ public class DynmapPlugin
|
||||||
ForgeMapChunkCache.init();
|
ForgeMapChunkCache.init();
|
||||||
core.setTriggerDefault(TRIGGER_DEFAULTS);
|
core.setTriggerDefault(TRIGGER_DEFAULTS);
|
||||||
core.setBiomeNames(getBiomeNames());
|
core.setBiomeNames(getBiomeNames());
|
||||||
core.setBlockMaterialMap(getBlockMaterialMap());
|
|
||||||
|
|
||||||
if(!core.initConfiguration(null))
|
if(!core.initConfiguration(null))
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,6 +27,7 @@ import java.util.regex.Pattern;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.command.CommandBase;
|
import net.minecraft.command.CommandBase;
|
||||||
import net.minecraft.command.CommandException;
|
import net.minecraft.command.CommandException;
|
||||||
|
@ -177,31 +178,43 @@ public class DynmapPlugin
|
||||||
String bn = ui.getResourceDomain() + ":" + ui.getResourcePath();
|
String bn = ui.getResourceDomain() + ":" + ui.getResourcePath();
|
||||||
// Only do defined names, and not "air"
|
// Only do defined names, and not "air"
|
||||||
if (!bn.equals(DynmapBlockState.AIR_BLOCK)) {
|
if (!bn.equals(DynmapBlockState.AIR_BLOCK)) {
|
||||||
DynmapBlockState basebs = new DynmapBlockState(null, 0, bn, "meta=0");
|
DynmapBlockState basebs = null;
|
||||||
stateByID[i << 4] = basebs;
|
for (int m = 0; m < 16; m++) {
|
||||||
for (int m = 1; m < 16; m++) {
|
Material mat = Material.AIR;
|
||||||
DynmapBlockState bs = new DynmapBlockState(basebs, m, bn, "meta=" + m);
|
|
||||||
stateByID[(i << 4) + m] = bs;
|
|
||||||
IBlockState blkstate = null;
|
IBlockState blkstate = null;
|
||||||
try {
|
try {
|
||||||
blkstate = b.getStateFromMeta(m);
|
blkstate = b.getStateFromMeta(m);
|
||||||
} catch (Exception x) {
|
} catch (Exception x) {
|
||||||
// Invalid metadata
|
// Invalid metadata
|
||||||
}
|
}
|
||||||
|
String statename = "meta=" + m;
|
||||||
if (blkstate != null) {
|
if (blkstate != null) {
|
||||||
Material mat = blkstate.getMaterial();
|
mat = blkstate.getMaterial();
|
||||||
if (mat.isSolid()) {
|
String pstate = null;
|
||||||
bs.setSolid();
|
for(Entry<IProperty<?>, Comparable<?>> p : blkstate.getProperties().entrySet()) {
|
||||||
}
|
if (pstate == null)
|
||||||
if (mat == Material.AIR) {
|
pstate = "";
|
||||||
bs.setAir();
|
else
|
||||||
}
|
pstate += ",";
|
||||||
if (mat == Material.WOOD) {
|
pstate += p.getKey().getName() + "=" + p.getValue().toString();
|
||||||
bs.setLog();
|
|
||||||
}
|
|
||||||
if (mat == Material.LEAVES) {
|
|
||||||
bs.setLeaves();
|
|
||||||
}
|
}
|
||||||
|
if (pstate != null)
|
||||||
|
statename = pstate;
|
||||||
|
}
|
||||||
|
DynmapBlockState bs = new DynmapBlockState(basebs, m, bn, statename, mat.toString(), i);
|
||||||
|
if (basebs == null) basebs = bs;
|
||||||
|
stateByID[(i << 4) + m] = bs;
|
||||||
|
if (mat.isSolid()) {
|
||||||
|
bs.setSolid();
|
||||||
|
}
|
||||||
|
if (mat == Material.AIR) {
|
||||||
|
bs.setAir();
|
||||||
|
}
|
||||||
|
if (mat == Material.WOOD) {
|
||||||
|
bs.setLog();
|
||||||
|
}
|
||||||
|
if (mat == Material.LEAVES) {
|
||||||
|
bs.setLeaves();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1401,31 +1414,6 @@ public class DynmapPlugin
|
||||||
return lst;
|
return lst;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int[] getBlockMaterialMap() {
|
|
||||||
int[] map = new int[512];
|
|
||||||
ArrayList<Material> mats = new ArrayList<Material>();
|
|
||||||
Iterator<Block> iter = Block.REGISTRY.iterator();
|
|
||||||
while (iter.hasNext()) {
|
|
||||||
Block b = iter.next();
|
|
||||||
int i = Block.getIdFromBlock(b);
|
|
||||||
if (i >= map.length) {
|
|
||||||
map = Arrays.copyOf(map, i+1);
|
|
||||||
}
|
|
||||||
Material mat = b.getBlockState().getBaseState().getMaterial();
|
|
||||||
if (mat != null) {
|
|
||||||
map[i] = mats.indexOf(mat);
|
|
||||||
if (map[i] < 0) {
|
|
||||||
map[i] = mats.size();
|
|
||||||
mats.add(mat);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
map[i] = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onEnable()
|
public void onEnable()
|
||||||
{
|
{
|
||||||
/* Get MC version */
|
/* Get MC version */
|
||||||
|
@ -1463,7 +1451,6 @@ public class DynmapPlugin
|
||||||
ForgeMapChunkCache.init();
|
ForgeMapChunkCache.init();
|
||||||
core.setTriggerDefault(TRIGGER_DEFAULTS);
|
core.setTriggerDefault(TRIGGER_DEFAULTS);
|
||||||
core.setBiomeNames(getBiomeNames());
|
core.setBiomeNames(getBiomeNames());
|
||||||
core.setBlockMaterialMap(getBlockMaterialMap());
|
|
||||||
|
|
||||||
if(!core.initConfiguration(null))
|
if(!core.initConfiguration(null))
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,6 +27,7 @@ import java.util.regex.Pattern;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.command.CommandBase;
|
import net.minecraft.command.CommandBase;
|
||||||
import net.minecraft.command.CommandException;
|
import net.minecraft.command.CommandException;
|
||||||
|
@ -179,31 +180,43 @@ public class DynmapPlugin
|
||||||
String bn = ui.getResourceDomain() + ":" + ui.getResourcePath();
|
String bn = ui.getResourceDomain() + ":" + ui.getResourcePath();
|
||||||
// Only do defined names, and not "air"
|
// Only do defined names, and not "air"
|
||||||
if (!bn.equals(DynmapBlockState.AIR_BLOCK)) {
|
if (!bn.equals(DynmapBlockState.AIR_BLOCK)) {
|
||||||
DynmapBlockState basebs = new DynmapBlockState(null, 0, bn, "meta=0");
|
DynmapBlockState basebs = null;
|
||||||
stateByID[i << 4] = basebs;
|
for (int m = 0; m < 16; m++) {
|
||||||
for (int m = 1; m < 16; m++) {
|
Material mat = Material.AIR;
|
||||||
DynmapBlockState bs = new DynmapBlockState(basebs, m, bn, "meta=" + m);
|
|
||||||
stateByID[(i << 4) + m] = bs;
|
|
||||||
IBlockState blkstate = null;
|
IBlockState blkstate = null;
|
||||||
try {
|
try {
|
||||||
blkstate = b.getStateFromMeta(m);
|
blkstate = b.getStateFromMeta(m);
|
||||||
} catch (Exception x) {
|
} catch (Exception x) {
|
||||||
// Invalid metadata
|
// Invalid metadata
|
||||||
}
|
}
|
||||||
|
String statename = "meta=" + m;
|
||||||
if (blkstate != null) {
|
if (blkstate != null) {
|
||||||
Material mat = blkstate.getMaterial();
|
mat = blkstate.getMaterial();
|
||||||
if (mat.isSolid()) {
|
String pstate = null;
|
||||||
bs.setSolid();
|
for(Entry<IProperty<?>, Comparable<?>> p : blkstate.getProperties().entrySet()) {
|
||||||
}
|
if (pstate == null)
|
||||||
if (mat == Material.AIR) {
|
pstate = "";
|
||||||
bs.setAir();
|
else
|
||||||
}
|
pstate += ",";
|
||||||
if (mat == Material.WOOD) {
|
pstate += p.getKey().getName() + "=" + p.getValue().toString();
|
||||||
bs.setLog();
|
|
||||||
}
|
|
||||||
if (mat == Material.LEAVES) {
|
|
||||||
bs.setLeaves();
|
|
||||||
}
|
}
|
||||||
|
if (pstate != null)
|
||||||
|
statename = pstate;
|
||||||
|
}
|
||||||
|
DynmapBlockState bs = new DynmapBlockState(basebs, m, bn, statename, mat.toString(), i);
|
||||||
|
if (basebs == null) basebs = bs;
|
||||||
|
stateByID[(i << 4) + m] = bs;
|
||||||
|
if (mat.isSolid()) {
|
||||||
|
bs.setSolid();
|
||||||
|
}
|
||||||
|
if (mat == Material.AIR) {
|
||||||
|
bs.setAir();
|
||||||
|
}
|
||||||
|
if (mat == Material.WOOD) {
|
||||||
|
bs.setLog();
|
||||||
|
}
|
||||||
|
if (mat == Material.LEAVES) {
|
||||||
|
bs.setLeaves();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -212,7 +225,7 @@ public class DynmapPlugin
|
||||||
|
|
||||||
//for (int gidx = 0; gidx < DynmapBlockState.getGlobalIndexMax(); gidx++) {
|
//for (int gidx = 0; gidx < DynmapBlockState.getGlobalIndexMax(); gidx++) {
|
||||||
// DynmapBlockState bs = DynmapBlockState.getStateByGlobalIndex(gidx);
|
// DynmapBlockState bs = DynmapBlockState.getStateByGlobalIndex(gidx);
|
||||||
// Log.verboseinfo(gidx + ":" + bs.toString() + ", gidx=" + bs.globalStateIndex + ", sidx=" + bs.stateIndex);
|
// Log.info(gidx + ":" + bs.toString() + ", gidx=" + bs.globalStateIndex + ", sidx=" + bs.stateIndex);
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1408,31 +1421,6 @@ public class DynmapPlugin
|
||||||
return lst;
|
return lst;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int[] getBlockMaterialMap() {
|
|
||||||
int[] map = new int[512];
|
|
||||||
ArrayList<Material> mats = new ArrayList<Material>();
|
|
||||||
Iterator<Block> iter = Block.REGISTRY.iterator();
|
|
||||||
while (iter.hasNext()) {
|
|
||||||
Block b = iter.next();
|
|
||||||
int i = Block.getIdFromBlock(b);
|
|
||||||
if (i >= map.length) {
|
|
||||||
map = Arrays.copyOf(map, i+1);
|
|
||||||
}
|
|
||||||
Material mat = b.getBlockState().getBaseState().getMaterial();
|
|
||||||
if (mat != null) {
|
|
||||||
map[i] = mats.indexOf(mat);
|
|
||||||
if (map[i] < 0) {
|
|
||||||
map[i] = mats.size();
|
|
||||||
mats.add(mat);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
map[i] = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onEnable()
|
public void onEnable()
|
||||||
{
|
{
|
||||||
/* Get MC version */
|
/* Get MC version */
|
||||||
|
@ -1470,7 +1458,6 @@ public class DynmapPlugin
|
||||||
ForgeMapChunkCache.init();
|
ForgeMapChunkCache.init();
|
||||||
core.setTriggerDefault(TRIGGER_DEFAULTS);
|
core.setTriggerDefault(TRIGGER_DEFAULTS);
|
||||||
core.setBiomeNames(getBiomeNames());
|
core.setBiomeNames(getBiomeNames());
|
||||||
core.setBlockMaterialMap(getBlockMaterialMap());
|
|
||||||
|
|
||||||
if(!core.initConfiguration(null))
|
if(!core.initConfiguration(null))
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,6 +27,7 @@ import java.util.regex.Pattern;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.command.CommandBase;
|
import net.minecraft.command.CommandBase;
|
||||||
import net.minecraft.command.CommandHandler;
|
import net.minecraft.command.CommandHandler;
|
||||||
|
@ -173,12 +174,31 @@ public class DynmapPlugin
|
||||||
String bn = ui.modId + ":" + ui.name;
|
String bn = ui.modId + ":" + ui.name;
|
||||||
// Only do defined names, and not "air"
|
// Only do defined names, and not "air"
|
||||||
if (!bn.equals(DynmapBlockState.AIR_BLOCK)) {
|
if (!bn.equals(DynmapBlockState.AIR_BLOCK)) {
|
||||||
DynmapBlockState basebs = new DynmapBlockState(null, 0, bn, "meta=0");
|
DynmapBlockState basebs = null;
|
||||||
stateByID[i << 4] = basebs;
|
for (int m = 0; m < 16; m++) {
|
||||||
for (int m = 1; m < 16; m++) {
|
|
||||||
DynmapBlockState bs = new DynmapBlockState(basebs, m, bn, "meta=" + m);
|
|
||||||
stateByID[(i << 4) + m] = bs;
|
|
||||||
Material mat = b.getMaterial();
|
Material mat = b.getMaterial();
|
||||||
|
IBlockState blkstate = null;
|
||||||
|
try {
|
||||||
|
blkstate = b.getStateFromMeta(m);
|
||||||
|
} catch (Exception x) {
|
||||||
|
// Invalid metadata
|
||||||
|
}
|
||||||
|
String statename = "meta=" + m;
|
||||||
|
if (blkstate != null) {
|
||||||
|
String pstate = null;
|
||||||
|
for(Entry<IProperty, Comparable> p : blkstate.getProperties().entrySet()) {
|
||||||
|
if (pstate == null)
|
||||||
|
pstate = "";
|
||||||
|
else
|
||||||
|
pstate += ",";
|
||||||
|
pstate += p.getKey().getName() + "=" + p.getValue().toString();
|
||||||
|
}
|
||||||
|
if (pstate != null)
|
||||||
|
statename = pstate;
|
||||||
|
}
|
||||||
|
DynmapBlockState bs = new DynmapBlockState(basebs, m, bn, statename, mat.toString(), i);
|
||||||
|
if (basebs == null) basebs = bs;
|
||||||
|
stateByID[(i << 4) + m] = bs;
|
||||||
if (mat.isSolid()) {
|
if (mat.isSolid()) {
|
||||||
bs.setSolid();
|
bs.setSolid();
|
||||||
}
|
}
|
||||||
|
@ -1395,28 +1415,6 @@ public class DynmapPlugin
|
||||||
return lst;
|
return lst;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int[] getBlockMaterialMap() {
|
|
||||||
int[] map = new int[4096];
|
|
||||||
ArrayList<Material> mats = new ArrayList<Material>();
|
|
||||||
for (int i = 0; i < map.length; i++) {
|
|
||||||
Block b = getBlockByID(i);
|
|
||||||
if(b != null) {
|
|
||||||
Material mat = getBlockMaterial(b);
|
|
||||||
if (mat != null) {
|
|
||||||
map[i] = mats.indexOf(mat);
|
|
||||||
if (map[i] < 0) {
|
|
||||||
map[i] = mats.size();
|
|
||||||
mats.add(mat);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
map[i] = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onEnable()
|
public void onEnable()
|
||||||
{
|
{
|
||||||
server = MinecraftServer.getServer();
|
server = MinecraftServer.getServer();
|
||||||
|
@ -1456,7 +1454,6 @@ public class DynmapPlugin
|
||||||
ForgeMapChunkCache.init();
|
ForgeMapChunkCache.init();
|
||||||
core.setTriggerDefault(TRIGGER_DEFAULTS);
|
core.setTriggerDefault(TRIGGER_DEFAULTS);
|
||||||
core.setBiomeNames(getBiomeNames());
|
core.setBiomeNames(getBiomeNames());
|
||||||
core.setBlockMaterialMap(getBlockMaterialMap());
|
|
||||||
|
|
||||||
if(!core.initConfiguration(null))
|
if(!core.initConfiguration(null))
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,6 +27,7 @@ import java.util.regex.Pattern;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.block.properties.IProperty;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.command.CommandBase;
|
import net.minecraft.command.CommandBase;
|
||||||
import net.minecraft.command.CommandException;
|
import net.minecraft.command.CommandException;
|
||||||
|
@ -171,31 +172,42 @@ public class DynmapPlugin
|
||||||
String bn = ui.getResourceDomain() + ":" + ui.getResourcePath();
|
String bn = ui.getResourceDomain() + ":" + ui.getResourcePath();
|
||||||
// Only do defined names, and not "air"
|
// Only do defined names, and not "air"
|
||||||
if (!bn.equals(DynmapBlockState.AIR_BLOCK)) {
|
if (!bn.equals(DynmapBlockState.AIR_BLOCK)) {
|
||||||
DynmapBlockState basebs = new DynmapBlockState(null, 0, bn, "meta=0");
|
DynmapBlockState basebs = null;
|
||||||
stateByID[i << 4] = basebs;
|
for (int m = 0; m < 16; m++) {
|
||||||
for (int m = 1; m < 16; m++) {
|
|
||||||
DynmapBlockState bs = new DynmapBlockState(basebs, m, bn, "meta=" + m);
|
|
||||||
stateByID[(i << 4) + m] = bs;
|
|
||||||
IBlockState blkstate = null;
|
IBlockState blkstate = null;
|
||||||
try {
|
try {
|
||||||
blkstate = b.getStateFromMeta(m);
|
blkstate = b.getStateFromMeta(m);
|
||||||
} catch (Exception x) {
|
} catch (Exception x) {
|
||||||
// Invalid meta
|
// Invalid meta
|
||||||
}
|
}
|
||||||
|
String statename = "meta=" + m;
|
||||||
if (blkstate != null) {
|
if (blkstate != null) {
|
||||||
Material mat = blkstate.getMaterial();
|
String pstate = null;
|
||||||
if (mat.isSolid()) {
|
for(Entry<IProperty<?>, Comparable<?>> p : blkstate.getProperties().entrySet()) {
|
||||||
bs.setSolid();
|
if (pstate == null)
|
||||||
}
|
pstate = "";
|
||||||
if (mat == Material.AIR) {
|
else
|
||||||
bs.setAir();
|
pstate += ",";
|
||||||
}
|
pstate += p.getKey().getName() + "=" + p.getValue().toString();
|
||||||
if (mat == Material.WOOD) {
|
|
||||||
bs.setLog();
|
|
||||||
}
|
|
||||||
if (mat == Material.LEAVES) {
|
|
||||||
bs.setLeaves();
|
|
||||||
}
|
}
|
||||||
|
if (pstate != null)
|
||||||
|
statename = pstate;
|
||||||
|
}
|
||||||
|
Material mat = (blkstate != null) ? blkstate.getMaterial() : Material.AIR;
|
||||||
|
DynmapBlockState bs = new DynmapBlockState(basebs, m, bn, statename, mat.toString(), i);
|
||||||
|
if (basebs == null) basebs = bs;
|
||||||
|
stateByID[(i << 4) + m] = bs;
|
||||||
|
if (mat.isSolid()) {
|
||||||
|
bs.setSolid();
|
||||||
|
}
|
||||||
|
if (mat == Material.AIR) {
|
||||||
|
bs.setAir();
|
||||||
|
}
|
||||||
|
if (mat == Material.WOOD) {
|
||||||
|
bs.setLog();
|
||||||
|
}
|
||||||
|
if (mat == Material.LEAVES) {
|
||||||
|
bs.setLeaves();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1386,28 +1398,6 @@ public class DynmapPlugin
|
||||||
return lst;
|
return lst;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int[] getBlockMaterialMap() {
|
|
||||||
int[] map = new int[4096];
|
|
||||||
ArrayList<Material> mats = new ArrayList<Material>();
|
|
||||||
for (int i = 0; i < map.length; i++) {
|
|
||||||
Block b = getBlockByID(i);
|
|
||||||
if(b != null) {
|
|
||||||
Material mat = b.getBlockState().getBaseState().getMaterial();
|
|
||||||
if (mat != null) {
|
|
||||||
map[i] = mats.indexOf(mat);
|
|
||||||
if (map[i] < 0) {
|
|
||||||
map[i] = mats.size();
|
|
||||||
mats.add(mat);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
map[i] = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onEnable()
|
public void onEnable()
|
||||||
{
|
{
|
||||||
/* Get MC version */
|
/* Get MC version */
|
||||||
|
@ -1445,7 +1435,6 @@ public class DynmapPlugin
|
||||||
ForgeMapChunkCache.init();
|
ForgeMapChunkCache.init();
|
||||||
core.setTriggerDefault(TRIGGER_DEFAULTS);
|
core.setTriggerDefault(TRIGGER_DEFAULTS);
|
||||||
core.setBiomeNames(getBiomeNames());
|
core.setBiomeNames(getBiomeNames());
|
||||||
core.setBlockMaterialMap(getBlockMaterialMap());
|
|
||||||
|
|
||||||
if(!core.initConfiguration(null))
|
if(!core.initConfiguration(null))
|
||||||
{
|
{
|
||||||
|
|
|
@ -844,7 +844,6 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||||
core.setMinecraftVersion(mcver);
|
core.setMinecraftVersion(mcver);
|
||||||
core.setDataFolder(dataDirectory);
|
core.setDataFolder(dataDirectory);
|
||||||
core.setServer(new BukkitServer());
|
core.setServer(new BukkitServer());
|
||||||
core.setBlockMaterialMap(helper.getBlockMaterialMap());
|
|
||||||
core.setBiomeNames(helper.getBiomeNames());
|
core.setBiomeNames(helper.getBiomeNames());
|
||||||
|
|
||||||
/* Load configuration */
|
/* Load configuration */
|
||||||
|
|
Loading…
Reference in New Issue