More 1.14 and 1.14.1 fixes

This commit is contained in:
Mike Primm 2019-05-14 19:51:42 -05:00
parent 1811be0410
commit 7bf0743c8c
5 changed files with 122 additions and 57 deletions

View File

@ -18,6 +18,7 @@ public class DynmapBlockState {
public final String blockName; public final String blockName;
// Block state string (attrib=value, attrib=value, etc for 1.13+, meta=value for 1.12 or earlier) // Block state string (attrib=value, attrib=value, etc for 1.13+, meta=value for 1.12 or earlier)
public final String stateName; public final String stateName;
public final String[] stateList;
// 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) // Legacy block ID (if defined - otherwise -1)
@ -132,6 +133,7 @@ public class DynmapBlockState {
} }
base.states[stateidx] = this; base.states[stateidx] = this;
} }
stateList = stateName.split(",");
// 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);
@ -221,8 +223,23 @@ public class DynmapBlockState {
DynmapBlockState blk = getBaseStateByName(name); DynmapBlockState blk = getBaseStateByName(name);
if (blk != null) { if (blk != null) {
if (blk.states != null) { if (blk.states != null) {
String[] statelist = statename.split(",");
for (DynmapBlockState bb : blk.states) { for (DynmapBlockState bb : blk.states) {
if (bb.stateName.contains(statename)) { boolean match = true;
for (int i = 0; i < statelist.length; i++) {
boolean valmatch = false;
for (int j = 0; j < bb.stateList.length; j++) {
if (statelist[i].equals(bb.stateList[j])) {
valmatch = true;
break;
}
}
if (!valmatch) {
match = false;
break;
}
}
if (match) {
return bb; return bb;
} }
} }

View File

@ -1,2 +1,2 @@
connection.project.dir=../forge-1.10.2 connection.project.dir=..
eclipse.preferences.version=1 eclipse.preferences.version=1

View File

@ -10,7 +10,6 @@ import org.bukkit.ChunkSnapshot;
import org.bukkit.World; import org.bukkit.World;
import org.dynmap.DynmapChunk; import org.dynmap.DynmapChunk;
import org.dynmap.DynmapCore; import org.dynmap.DynmapCore;
import org.dynmap.Log;
import org.dynmap.bukkit.helper.AbstractMapChunkCache; import org.dynmap.bukkit.helper.AbstractMapChunkCache;
import org.dynmap.bukkit.helper.SnapshotCache; import org.dynmap.bukkit.helper.SnapshotCache;
import org.dynmap.bukkit.helper.SnapshotCache.SnapshotRec; import org.dynmap.bukkit.helper.SnapshotCache.SnapshotRec;
@ -18,7 +17,9 @@ import org.dynmap.renderer.DynmapBlockState;
import org.dynmap.utils.DynIntHashMap; import org.dynmap.utils.DynIntHashMap;
import org.dynmap.utils.VisibilityLimit; import org.dynmap.utils.VisibilityLimit;
import net.minecraft.server.v1_14_R1.Chunk;
import net.minecraft.server.v1_14_R1.ChunkCoordIntPair; import net.minecraft.server.v1_14_R1.ChunkCoordIntPair;
import net.minecraft.server.v1_14_R1.ChunkRegionLoader;
import net.minecraft.server.v1_14_R1.DataBits; import net.minecraft.server.v1_14_R1.DataBits;
import net.minecraft.server.v1_14_R1.NBTTagCompound; import net.minecraft.server.v1_14_R1.NBTTagCompound;
import net.minecraft.server.v1_14_R1.NBTTagList; import net.minecraft.server.v1_14_R1.NBTTagList;
@ -156,7 +157,7 @@ public class MapChunkCache114_1 extends AbstractMapChunkCache {
NBTTagCompound sec = sect.getCompound(i); NBTTagCompound sec = sect.getCompound(i);
int secnum = sec.getByte("Y"); int secnum = sec.getByte("Y");
if (secnum >= this.sectionCnt) { if (secnum >= this.sectionCnt) {
Log.info("Section " + (int) secnum + " above world height " + worldheight); //Log.info("Section " + (int) secnum + " above world height " + worldheight);
continue; continue;
} }
if (secnum < 0) if (secnum < 0)
@ -175,14 +176,14 @@ public class MapChunkCache114_1 extends AbstractMapChunkCache {
for (int pi = 0; pi < plist.size(); pi++) { for (int pi = 0; pi < plist.size(); pi++) {
NBTTagCompound tc = plist.getCompound(pi); NBTTagCompound tc = plist.getCompound(pi);
String pname = tc.getString("Name"); String pname = tc.getString("Name");
String statestr = ""; if (tc.hasKey("Properties")) {
if (tc.hasKey("Properties")) { StringBuilder statestr = new StringBuilder();
NBTTagCompound prop = tc.getCompound("Properties"); NBTTagCompound prop = tc.getCompound("Properties");
for (String pid : prop.getKeys()) { for (String pid : prop.getKeys()) {
if (statestr.length() > 0) statestr += ","; if (statestr.length() > 0) statestr.append(',');
statestr += pid + "=" + prop.get(pid).asString(); statestr.append(pid).append('=').append(prop.get(pid).asString());
} }
palette[pi] = DynmapBlockState.getStateByNameAndState(pname, statestr); palette[pi] = DynmapBlockState.getStateByNameAndState(pname, statestr.toString());
} }
if (palette[pi] == null) { if (palette[pi] == null) {
palette[pi] = DynmapBlockState.getBaseStateByName(pname); palette[pi] = DynmapBlockState.getBaseStateByName(pname);
@ -287,28 +288,43 @@ public class MapChunkCache114_1 extends AbstractMapChunkCache {
} }
} }
private NBTTagCompound loadChunkNBT(World w, int x, int z) { private NBTTagCompound fetchLoadedChunkNBT(World w, int x, int z) {
CraftWorld cw = (CraftWorld) w; CraftWorld cw = (CraftWorld) w;
ChunkCoordIntPair cc = new ChunkCoordIntPair(x, z); NBTTagCompound nbt = null;
NBTTagCompound nbt = null; if (cw.isChunkLoaded(x, z)) {
try { Chunk c = cw.getHandle().getChunkAt(x, z);
nbt = cw.getHandle().getChunkProvider().playerChunkMap.read(cc); if ((c != null) && c.loaded) {
} catch (IOException iox) { nbt = ChunkRegionLoader.saveChunk(cw.getHandle(), c);
} }
if (nbt != null) { }
nbt = nbt.getCompound("Level"); if (nbt != null) {
} nbt = nbt.getCompound("Level");
return nbt; }
} return nbt;
}
@Override
public Snapshot wrapChunkSnapshot(ChunkSnapshot css) { private NBTTagCompound loadChunkNBT(World w, int x, int z) {
// TODO Auto-generated method stub CraftWorld cw = (CraftWorld) w;
return null; NBTTagCompound nbt = null;
} ChunkCoordIntPair cc = new ChunkCoordIntPair(x, z);
try {
nbt = cw.getHandle().getChunkProvider().playerChunkMap.read(cc);
} catch (IOException iox) {
}
if (nbt != null) {
nbt = nbt.getCompound("Level");
}
return nbt;
}
@Override
public Snapshot wrapChunkSnapshot(ChunkSnapshot css) {
// TODO Auto-generated method stub
return null;
}
// Load chunk snapshots // Load chunk snapshots
@Override @Override
public int loadChunks(int max_to_load) { public int loadChunks(int max_to_load) {
if(dw.isLoaded() == false) if(dw.isLoaded() == false)
return 0; return 0;
@ -356,7 +372,7 @@ public class MapChunkCache114_1 extends AbstractMapChunkCache {
ss = EMPTY; ss = EMPTY;
} }
else { else {
ss = ssr.ss; ss = ssr.ss;
} }
snaparray[idx] = ss; snaparray[idx] = ss;
snaptile[idx] = ssr.tileData; snaptile[idx] = ssr.tileData;
@ -365,12 +381,18 @@ public class MapChunkCache114_1 extends AbstractMapChunkCache {
endChunkLoad(startTime, ChunkStats.CACHED_SNAPSHOT_HIT); endChunkLoad(startTime, ChunkStats.CACHED_SNAPSHOT_HIT);
continue; continue;
} }
// Load NTB for chunk, if it exists // Fetch NTB for chunk if loaded
NBTTagCompound nbt = loadChunkNBT(w, chunk.x, chunk.z); NBTTagCompound nbt = fetchLoadedChunkNBT(w, chunk.x, chunk.z);
boolean did_load = false;
if (nbt == null) {
// Load NTB for chunk, if it exists
nbt = loadChunkNBT(w, chunk.x, chunk.z);
did_load = true;
}
if (nbt != null) { if (nbt != null) {
NBTSnapshot nss = new NBTSnapshot(nbt, w.getMaxHeight()); NBTSnapshot nss = new NBTSnapshot(nbt, w.getMaxHeight());
ss = nss; ss = nss;
inhabited_ticks = nss.getInhabitedTicks(); inhabited_ticks = nss.getInhabitedTicks();
if(!vis) { if(!vis) {
if(hidestyle == HiddenChunkStyle.FILL_STONE_PLAIN) if(hidestyle == HiddenChunkStyle.FILL_STONE_PLAIN)
ss = STONE; ss = STONE;
@ -381,7 +403,7 @@ public class MapChunkCache114_1 extends AbstractMapChunkCache {
} }
} }
else { else {
ss = EMPTY; ss = EMPTY;
} }
ssr = new SnapshotRec(); ssr = new SnapshotRec();
ssr.ss = ss; ssr.ss = ss;
@ -391,10 +413,12 @@ public class MapChunkCache114_1 extends AbstractMapChunkCache {
snaparray[idx] = ss; snaparray[idx] = ss;
snaptile[idx] = ssr.tileData; snaptile[idx] = ssr.tileData;
inhabitedTicks[idx] = inhabited_ticks; inhabitedTicks[idx] = inhabited_ticks;
if (ss == EMPTY) if (nbt == null)
endChunkLoad(startTime, ChunkStats.UNGENERATED_CHUNKS); endChunkLoad(startTime, ChunkStats.UNGENERATED_CHUNKS);
else if (did_load)
endChunkLoad(startTime, ChunkStats.UNLOADED_CHUNKS);
else else
endChunkLoad(startTime, ChunkStats.UNLOADED_CHUNKS); endChunkLoad(startTime, ChunkStats.LOADED_CHUNKS);
cnt++; cnt++;
} }
DynmapCore.setIgnoreChunkLoads(false); DynmapCore.setIgnoreChunkLoads(false);

View File

@ -10,7 +10,6 @@ import org.bukkit.ChunkSnapshot;
import org.bukkit.World; import org.bukkit.World;
import org.dynmap.DynmapChunk; import org.dynmap.DynmapChunk;
import org.dynmap.DynmapCore; import org.dynmap.DynmapCore;
import org.dynmap.Log;
import org.dynmap.bukkit.helper.AbstractMapChunkCache; import org.dynmap.bukkit.helper.AbstractMapChunkCache;
import org.dynmap.bukkit.helper.SnapshotCache; import org.dynmap.bukkit.helper.SnapshotCache;
import org.dynmap.bukkit.helper.SnapshotCache.SnapshotRec; import org.dynmap.bukkit.helper.SnapshotCache.SnapshotRec;
@ -18,7 +17,9 @@ import org.dynmap.renderer.DynmapBlockState;
import org.dynmap.utils.DynIntHashMap; import org.dynmap.utils.DynIntHashMap;
import org.dynmap.utils.VisibilityLimit; import org.dynmap.utils.VisibilityLimit;
import net.minecraft.server.v1_14_R1.Chunk;
import net.minecraft.server.v1_14_R1.ChunkCoordIntPair; import net.minecraft.server.v1_14_R1.ChunkCoordIntPair;
import net.minecraft.server.v1_14_R1.ChunkRegionLoader;
import net.minecraft.server.v1_14_R1.DataBits; import net.minecraft.server.v1_14_R1.DataBits;
import net.minecraft.server.v1_14_R1.NBTTagCompound; import net.minecraft.server.v1_14_R1.NBTTagCompound;
import net.minecraft.server.v1_14_R1.NBTTagList; import net.minecraft.server.v1_14_R1.NBTTagList;
@ -156,7 +157,7 @@ public class MapChunkCache114 extends AbstractMapChunkCache {
NBTTagCompound sec = sect.getCompound(i); NBTTagCompound sec = sect.getCompound(i);
int secnum = sec.getByte("Y"); int secnum = sec.getByte("Y");
if (secnum >= this.sectionCnt) { if (secnum >= this.sectionCnt) {
Log.info("Section " + (int) secnum + " above world height " + worldheight); //Log.info("Section " + (int) secnum + " above world height " + worldheight);
continue; continue;
} }
if (secnum < 0) if (secnum < 0)
@ -175,14 +176,14 @@ public class MapChunkCache114 extends AbstractMapChunkCache {
for (int pi = 0; pi < plist.size(); pi++) { for (int pi = 0; pi < plist.size(); pi++) {
NBTTagCompound tc = plist.getCompound(pi); NBTTagCompound tc = plist.getCompound(pi);
String pname = tc.getString("Name"); String pname = tc.getString("Name");
String statestr = "";
if (tc.hasKey("Properties")) { if (tc.hasKey("Properties")) {
StringBuilder statestr = new StringBuilder();
NBTTagCompound prop = tc.getCompound("Properties"); NBTTagCompound prop = tc.getCompound("Properties");
for (String pid : prop.getKeys()) { for (String pid : prop.getKeys()) {
if (statestr.length() > 0) statestr += ","; if (statestr.length() > 0) statestr.append(',');
statestr += pid + "=" + prop.get(pid).asString(); statestr.append(pid).append('=').append(prop.get(pid).asString());
} }
palette[pi] = DynmapBlockState.getStateByNameAndState(pname, statestr); palette[pi] = DynmapBlockState.getStateByNameAndState(pname, statestr.toString());
} }
if (palette[pi] == null) { if (palette[pi] == null) {
palette[pi] = DynmapBlockState.getBaseStateByName(pname); palette[pi] = DynmapBlockState.getBaseStateByName(pname);
@ -287,16 +288,31 @@ public class MapChunkCache114 extends AbstractMapChunkCache {
} }
} }
private NBTTagCompound fetchLoadedChunkNBT(World w, int x, int z) {
CraftWorld cw = (CraftWorld) w;
NBTTagCompound nbt = null;
if (cw.isChunkLoaded(x, z)) {
Chunk c = cw.getHandle().getChunkAt(x, z);
if ((c != null) && c.loaded) {
nbt = ChunkRegionLoader.saveChunk(cw.getHandle(), c);
}
}
if (nbt != null) {
nbt = nbt.getCompound("Level");
}
return nbt;
}
private NBTTagCompound loadChunkNBT(World w, int x, int z) { private NBTTagCompound loadChunkNBT(World w, int x, int z) {
CraftWorld cw = (CraftWorld) w; CraftWorld cw = (CraftWorld) w;
NBTTagCompound nbt = null;
ChunkCoordIntPair cc = new ChunkCoordIntPair(x, z); ChunkCoordIntPair cc = new ChunkCoordIntPair(x, z);
NBTTagCompound nbt = null;
try { try {
nbt = cw.getHandle().getChunkProvider().playerChunkMap.read(cc); nbt = cw.getHandle().getChunkProvider().playerChunkMap.read(cc);
} catch (IOException iox) { } catch (IOException iox) {
} }
if (nbt != null) { if (nbt != null) {
nbt = nbt.getCompound("Level"); nbt = nbt.getCompound("Level");
} }
return nbt; return nbt;
} }
@ -365,8 +381,14 @@ public class MapChunkCache114 extends AbstractMapChunkCache {
endChunkLoad(startTime, ChunkStats.CACHED_SNAPSHOT_HIT); endChunkLoad(startTime, ChunkStats.CACHED_SNAPSHOT_HIT);
continue; continue;
} }
// Load NTB for chunk, if it exists // Fetch NTB for chunk if loaded
NBTTagCompound nbt = loadChunkNBT(w, chunk.x, chunk.z); NBTTagCompound nbt = fetchLoadedChunkNBT(w, chunk.x, chunk.z);
boolean did_load = false;
if (nbt == null) {
// Load NTB for chunk, if it exists
nbt = loadChunkNBT(w, chunk.x, chunk.z);
did_load = true;
}
if (nbt != null) { if (nbt != null) {
NBTSnapshot nss = new NBTSnapshot(nbt, w.getMaxHeight()); NBTSnapshot nss = new NBTSnapshot(nbt, w.getMaxHeight());
ss = nss; ss = nss;
@ -391,10 +413,12 @@ public class MapChunkCache114 extends AbstractMapChunkCache {
snaparray[idx] = ss; snaparray[idx] = ss;
snaptile[idx] = ssr.tileData; snaptile[idx] = ssr.tileData;
inhabitedTicks[idx] = inhabited_ticks; inhabitedTicks[idx] = inhabited_ticks;
if (ss == EMPTY) if (nbt == null)
endChunkLoad(startTime, ChunkStats.UNGENERATED_CHUNKS); endChunkLoad(startTime, ChunkStats.UNGENERATED_CHUNKS);
else if (did_load)
endChunkLoad(startTime, ChunkStats.UNLOADED_CHUNKS);
else else
endChunkLoad(startTime, ChunkStats.UNLOADED_CHUNKS); endChunkLoad(startTime, ChunkStats.LOADED_CHUNKS);
cnt++; cnt++;
} }
DynmapCore.setIgnoreChunkLoads(false); DynmapCore.setIgnoreChunkLoads(false);

View File

@ -1,2 +1,2 @@
connection.project.dir=../forge-1.10.2 connection.project.dir=..
eclipse.preferences.version=1 eclipse.preferences.version=1