Fix block state iterator

This commit is contained in:
Mike Primm 2020-04-25 19:58:19 -05:00
parent 745f8bc947
commit 27d767ac35
9 changed files with 30 additions and 17 deletions

View File

@ -188,7 +188,7 @@ public class HDBlockModels {
/* Check mods to see if model files defined there: do these first, as they trump other sources */
for (String modid : core.getServer().getModList()) {
File f = core.getServer().getModContainerFile(modid); // Get mod file
if (f.isFile()) {
if ((f != null) && f.isFile()) {
zf = null;
in = null;
try {

View File

@ -17,6 +17,8 @@ apply plugin: 'com.github.johnrengelman.shadow'
dependencies {
compile project(path: ":DynmapCore", configuration: "shadow")
compile 'com.googlecode.json-simple:json-simple:1.1.1'
compile 'org.yaml:snakeyaml:1.23'
}
sourceCompatibility = 1.8

View File

@ -17,6 +17,8 @@ apply plugin: 'com.github.johnrengelman.shadow'
dependencies {
compile project(path: ":DynmapCore", configuration: "shadow")
compile 'com.googlecode.json-simple:json-simple:1.1.1'
compile 'org.yaml:snakeyaml:1.23'
}
sourceCompatibility = 1.8

View File

@ -1,10 +1,8 @@
buildscript {
repositories {
maven { url = 'https://files.minecraftforge.net/maven' }
jcenter()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
mavenCentral()
maven {url = "https://oss.sonatype.org/content/repositories/snapshots/"}
}
dependencies {
@ -17,6 +15,8 @@ apply plugin: 'com.github.johnrengelman.shadow'
dependencies {
compile project(path: ":DynmapCore", configuration: "shadow")
compile 'com.googlecode.json-simple:json-simple:1.1.1'
compile 'org.yaml:snakeyaml:1.23'
}
sourceCompatibility = 1.8

View File

@ -1,10 +1,8 @@
buildscript {
repositories {
maven { url = 'https://files.minecraftforge.net/maven' }
jcenter()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
mavenCentral()
maven {url = "https://oss.sonatype.org/content/repositories/snapshots/"}
}
dependencies {

View File

@ -2,7 +2,7 @@ package org.dynmap.forge_1_13_2;
import java.io.File;
import org.dynmap.DynmapCommonAPI;
import org.dynmap.DynmapCommonAPI;
import org.dynmap.DynmapCommonAPIListener;
import org.dynmap.Log;
import org.dynmap.forge_1_13_2.DynmapPlugin.OurLog;
@ -12,6 +12,7 @@ import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent;
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
@ -71,7 +72,7 @@ public class DynmapMod
public void setup(final FMLCommonSetupEvent event)
{
//TOOO
//jarfile = event.getSourceFile();
jarfile = ModList.get().getModFileById("dynmap").getFile().getFilePath().toFile();
//// Load configuration file - use suggested (config/WesterosBlocks.cfg)
//Configuration cfg = new Configuration(event.getSuggestedConfigurationFile());
//try {

View File

@ -177,7 +177,7 @@ public class DynmapPlugin
* Initialize block states (org.dynmap.blockstate.DynmapBlockState)
*/
public void initializeBlockStates() {
stateByID = new DynmapBlockState[512*16]; // Simple map - scale as needed
stateByID = new DynmapBlockState[512*32]; // Simple map - scale as needed
Arrays.fill(stateByID, DynmapBlockState.AIR); // Default to air
ObjectIntIdentityMap<IBlockState> bsids = Block.BLOCK_STATE_IDS;
@ -198,15 +198,16 @@ public class DynmapPlugin
Block b = bs.getBlock();
// If this is new block vs last, it's the base block state
if (b != baseb) {
basebs = b;
baseidx = idx;
basebs = null;
baseidx = idx;
baseb = b;
}
ResourceLocation ui = b.getRegistryName();
if (ui == null) {
continue;
}
String bn = ui.getNamespace() + ":" + ui.getPath();
String bn = ui.getNamespace() + ":" + ui.getPath();
// Only do defined names, and not "air"
if (!bn.equals(DynmapBlockState.AIR_BLOCK)) {
Material mat = bs.getMaterial();
@ -217,8 +218,10 @@ public class DynmapPlugin
}
statename += p.getName() + "=" + bs.get(p).toString();
}
//Log.info("bn=" + bn + ", statenme=" + statename + ",idx=" + idx + ",baseidx=" + baseidx);
DynmapBlockState dbs = new DynmapBlockState(basebs, idx - baseidx, bn, statename, mat.toString(), idx);
stateByID[idx] = dbs;
if (basebs == null) { basebs = dbs; }
if (mat.isSolid()) {
dbs.setSolid();
}
@ -235,7 +238,7 @@ public class DynmapPlugin
}
for (int gidx = 0; gidx < DynmapBlockState.getGlobalIndexMax(); gidx++) {
DynmapBlockState bs = DynmapBlockState.getStateByGlobalIndex(gidx);
Log.info(gidx + ":" + bs.toString() + ", gidx=" + bs.globalStateIndex + ", sidx=" + bs.stateIndex);
//Log.info(gidx + ":" + bs.toString() + ", gidx=" + bs.globalStateIndex + ", sidx=" + bs.stateIndex);
}
}
@ -1008,8 +1011,11 @@ public class DynmapPlugin
public File getModContainerFile(String name) {
ModFileInfo mfi = ModList.get().getModFileById(name); // Try case sensitive lookup
if (mfi != null) {
return mfi.getFile().getFilePath().toFile();
File f = mfi.getFile().getFilePath().toFile();
Log.info("getModContainferFile(" + name + ")=" + f.getAbsolutePath());
return f;
}
Log.info("getModContainferFile(" + name + ")=null");
return null;
}
@Override

View File

@ -17,6 +17,8 @@ apply plugin: 'com.github.johnrengelman.shadow'
dependencies {
compile project(path: ":DynmapCore", configuration: "shadow")
compile 'com.googlecode.json-simple:json-simple:1.1.1'
compile 'org.yaml:snakeyaml:1.23'
}
sourceCompatibility = 1.8

View File

@ -17,6 +17,8 @@ apply plugin: 'com.github.johnrengelman.shadow'
dependencies {
compile project(path: ":DynmapCore", configuration: "shadow")
compile 'com.googlecode.json-simple:json-simple:1.1.1'
compile 'org.yaml:snakeyaml:1.23'
}
sourceCompatibility = 1.8