mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-09-28 21:57:25 +02:00
Get 1.12.2 blockname based textures working
This commit is contained in:
parent
b4920e0246
commit
58d5e59616
@ -1,5 +1,6 @@
|
|||||||
package org.dynmap.bukkit;
|
package org.dynmap.bukkit;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -47,7 +48,7 @@ public abstract class BukkitVersionHelper {
|
|||||||
return helper;
|
return helper;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DynIntHashMap stateByID = new DynIntHashMap();
|
public static DynmapBlockState[] stateByID = new DynmapBlockState[65536];
|
||||||
|
|
||||||
protected BukkitVersionHelper() {
|
protected BukkitVersionHelper() {
|
||||||
|
|
||||||
@ -121,9 +122,9 @@ public abstract class BukkitVersionHelper {
|
|||||||
*/
|
*/
|
||||||
public abstract void unloadChunkNoSave(World w, Chunk c, int cx, int cz);
|
public abstract void unloadChunkNoSave(World w, Chunk c, int cx, int cz);
|
||||||
/**
|
/**
|
||||||
* Get block short name list
|
* Get block name list
|
||||||
*/
|
*/
|
||||||
public abstract String[] getBlockShortNames();
|
public abstract String[] getBlockNames();
|
||||||
/**
|
/**
|
||||||
* Get biome name list
|
* Get biome name list
|
||||||
*/
|
*/
|
||||||
@ -157,21 +158,28 @@ public abstract class BukkitVersionHelper {
|
|||||||
* Initialize block states (org.dynmap.blockstate.DynmapBlockState)
|
* Initialize block states (org.dynmap.blockstate.DynmapBlockState)
|
||||||
*/
|
*/
|
||||||
public void initializeBlockStates() {
|
public void initializeBlockStates() {
|
||||||
String[] blkname = getBlockShortNames();
|
String[] blkname = getBlockNames();
|
||||||
// Keep it simple for now - just assume 16 meta states for each
|
// Keep it simple for now - just assume 16 meta states for each
|
||||||
|
Arrays.fill(stateByID, DynmapBlockState.AIR);
|
||||||
for (int i = 0; i < blkname.length; i++) {
|
for (int i = 0; i < blkname.length; i++) {
|
||||||
|
if (blkname[i] == null) continue;
|
||||||
|
String bn = blkname[i];
|
||||||
|
if (bn.indexOf(':') < 0) {
|
||||||
|
bn = "minecraft:" + bn;
|
||||||
|
}
|
||||||
// Only do defined names, and not "air"
|
// Only do defined names, and not "air"
|
||||||
if ((blkname[i] != null) && (!blkname[i].equals("air"))) {
|
if (!bn.equals(DynmapBlockState.AIR_BLOCK)) {
|
||||||
Log.info("block " + blkname[i]);
|
DynmapBlockState basebs = new DynmapBlockState(null, 0, bn, "meta=0");
|
||||||
DynmapBlockState basebs = new DynmapBlockState(null, 0, "minecraft:" + blkname, "meta=0");
|
stateByID[i << 4] = basebs;
|
||||||
stateByID.put((i << 4), basebs);
|
|
||||||
for (int m = 1; m < 16; m++) {
|
for (int m = 1; m < 16; m++) {
|
||||||
DynmapBlockState bs = new DynmapBlockState(basebs, m, "minecraft:" + blkname, "meta=" + m);
|
DynmapBlockState bs = new DynmapBlockState(basebs, m, bn, "meta=" + m);
|
||||||
stateByID.put((i << 4) + m, bs);
|
stateByID[(i << 4) + m] = bs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stateByID.put(0, DynmapBlockState.AIR); // Include air block;
|
for (int gidx = 0; gidx < DynmapBlockState.getGlobalIndexMax(); gidx++) {
|
||||||
|
DynmapBlockState bs = DynmapBlockState.getStateByGlobalIndex(gidx);
|
||||||
|
Log.info(gidx + ":" + bs.toString() + ", gidx=" + bs.globalStateIndex + ", sidx=" + bs.stateIndex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -186,18 +186,25 @@ public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric {
|
|||||||
public void unloadChunkNoSave(World w, Chunk c, int cx, int cz) {
|
public void unloadChunkNoSave(World w, Chunk c, int cx, int cz) {
|
||||||
w.unloadChunk(cx, cz, false, false);
|
w.unloadChunk(cx, cz, false, false);
|
||||||
}
|
}
|
||||||
|
private String stripBlockString(String bname) {
|
||||||
|
int idx = bname.indexOf('{');
|
||||||
|
if (idx >= 0) bname = bname.substring(idx+1);
|
||||||
|
idx = bname.indexOf('}');
|
||||||
|
if (idx >= 0) bname = bname.substring(0, idx);
|
||||||
|
return bname;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Get block short name list
|
* Get block short name list
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String[] getBlockShortNames() {
|
public String[] getBlockNames() {
|
||||||
try {
|
try {
|
||||||
String[] names = new String[4096];
|
String[] names = new String[4096];
|
||||||
if (blockbyid != null) {
|
if (blockbyid != null) {
|
||||||
Object[] byid = (Object[])blockbyid.get(nmsblock);
|
Object[] byid = (Object[])blockbyid.get(nmsblock);
|
||||||
for (int i = 0; i < names.length; i++) {
|
for (int i = 0; i < names.length; i++) {
|
||||||
if (byid[i] != null) {
|
if (byid[i] != null) {
|
||||||
names[i] = (String)blockname.get(byid[i]);
|
names[i] = stripBlockString(byid[i].toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -205,7 +212,7 @@ public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric {
|
|||||||
for (int i = 0; i < names.length; i++) {
|
for (int i = 0; i < names.length; i++) {
|
||||||
Object blk = blockbyidfunc.invoke(nmsblock, i);
|
Object blk = blockbyidfunc.invoke(nmsblock, i);
|
||||||
if (blk != null) {
|
if (blk != null) {
|
||||||
names[i] = (String)blockname.get(blk);
|
names[i] = stripBlockString(blk.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,7 @@ public class BukkitVersionHelperGlowstone extends BukkitVersionHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getBlockShortNames() {
|
public String[] getBlockNames() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -545,11 +545,14 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<Integer, String> getBlockIDMap() {
|
public Map<Integer, String> getBlockIDMap() {
|
||||||
String[] bsn = helper.getBlockShortNames();
|
String[] bsn = helper.getBlockNames();
|
||||||
HashMap<Integer, String> map = new HashMap<Integer, String>();
|
HashMap<Integer, String> map = new HashMap<Integer, String>();
|
||||||
for (int i = 0; i < bsn.length; i++) {
|
for (int i = 0; i < bsn.length; i++) {
|
||||||
if (bsn[i] != null) {
|
if (bsn[i] != null) {
|
||||||
map.put(i, "minecraft:" + bsn[i]);
|
if (bsn[i].indexOf(':') < 0)
|
||||||
|
map.put(i, "minecraft:" + bsn[i]);
|
||||||
|
else
|
||||||
|
map.put(i, bsn[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
|
@ -63,7 +63,7 @@ public class NewMapChunkCache extends MapChunkCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static DynmapBlockState getTypeAt(ChunkSnapshot ss, int x, int y, int z) {
|
private static DynmapBlockState getTypeAt(ChunkSnapshot ss, int x, int y, int z) {
|
||||||
return (DynmapBlockState) BukkitVersionHelper.stateByID.get((ss.getBlockTypeId(x, y, z) << 4) | ss.getBlockData(x, y, z));
|
return BukkitVersionHelper.stateByID[(ss.getBlockTypeId(x, y, z) << 4) | ss.getBlockData(x, y, z)];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user