diff --git a/renderdata/ic2-models.txt-disabled b/renderdata/ic2-models.txt similarity index 97% rename from renderdata/ic2-models.txt-disabled rename to renderdata/ic2-models.txt index 2aa083f9..007cdac3 100644 --- a/renderdata/ic2-models.txt-disabled +++ b/renderdata/ic2-models.txt @@ -1,3 +1,6 @@ +# Industrial Craft 2 Texture mapping +# define ic2-support: true in configuration.txt to enable +enabled:ic2-support # Wire - set render alg linkmap:id=228,linkalg=5,linkid=223,linkid=225,linkid=226,linkid=227,linkid=228,linkid=233,linkid=237,linkid=246,linkid=250 # Wire - (data is faked: 1=north,2=east,4=south,8=west) @@ -195,4 +198,4 @@ block:id=232,data=11,scale=16 rotate:id=232,data=7,rot=270 # Iron Fence - north, south, east, west neightbors block:id=232,data=15,scale=16 -layer:id=232,data=15,rot=0 +rotate:id=232,data=15,rot=0 diff --git a/renderdata/ic2-texture.txt-disabled b/renderdata/ic2-texture.txt similarity index 98% rename from renderdata/ic2-texture.txt-disabled rename to renderdata/ic2-texture.txt index aba4f646..e5a1614d 100644 --- a/renderdata/ic2-texture.txt-disabled +++ b/renderdata/ic2-texture.txt @@ -1,6 +1,6 @@ # Industrial Craft 2 Block mapping -# rename file to ic2-texture.txt to make active -# +# define ic2-support: true in configuration.txt to enable +enabled:ic2-support # Files texturefile:id=blk0,filename=ic2/sprites/block_0.png,xcount=16,ycount=16 texturefile:id=cable,filename=ic2/sprites/block_cable.png,xcount=16,ycount=16 diff --git a/src/main/java/org/dynmap/DynmapPlugin.java b/src/main/java/org/dynmap/DynmapPlugin.java index d6c6d897..c56502fc 100644 --- a/src/main/java/org/dynmap/DynmapPlugin.java +++ b/src/main/java/org/dynmap/DynmapPlugin.java @@ -221,11 +221,6 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI { dataDirectory = this.getDataFolder(); - /* Load block models */ - HDBlockModels.loadModels(dataDirectory); - /* Load texture mappings */ - TexturePack.loadTextureMapping(dataDirectory); - /* Initialize confguration.txt if needed */ File f = new File(this.getDataFolder(), "configuration.txt"); if(!createDefaultFileFromResource("/configuration.txt", f)) { @@ -237,6 +232,11 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI { bukkitConfiguration.load(); configuration = new ConfigurationNode(bukkitConfiguration); + /* Load block models */ + HDBlockModels.loadModels(dataDirectory, configuration); + /* Load texture mappings */ + TexturePack.loadTextureMapping(dataDirectory, configuration); + /* Now, process worlds.txt - merge it in as an override of existing values (since it is only user supplied values) */ f = new File(this.getDataFolder(), "worlds.txt"); if(!createDefaultFileFromResource("/worlds.txt", f)) { diff --git a/src/main/java/org/dynmap/hdmap/HDBlockModels.java b/src/main/java/org/dynmap/hdmap/HDBlockModels.java index 62c6599c..3a929f4b 100644 --- a/src/main/java/org/dynmap/hdmap/HDBlockModels.java +++ b/src/main/java/org/dynmap/hdmap/HDBlockModels.java @@ -14,6 +14,7 @@ import java.util.HashMap; import java.util.List; import org.bukkit.Material; +import org.dynmap.ConfigurationNode; import org.dynmap.Log; /** @@ -279,7 +280,7 @@ public class HDBlockModels { /** * Load models */ - public static void loadModels(File datadir) { + public static void loadModels(File datadir, ConfigurationNode config) { /* Reset models-by-ID-Data cache */ models_by_id_data.clear(); /* Reset scaled models by scale cache */ @@ -288,7 +289,7 @@ public class HDBlockModels { /* Load block models */ InputStream in = TexturePack.class.getResourceAsStream("/models.txt"); if(in != null) { - loadModelFile(in, "models.txt"); + loadModelFile(in, "models.txt", config); try { in.close(); } catch (IOException iox) {} in = null; } File customdir = new File(datadir, "renderdata"); @@ -301,7 +302,7 @@ public class HDBlockModels { if(custom.canRead()) { try { in = new FileInputStream(custom); - loadModelFile(in, custom.getPath()); + loadModelFile(in, custom.getPath(), config); } catch (IOException iox) { Log.severe("Error loading " + custom.getPath()); } finally { @@ -317,7 +318,7 @@ public class HDBlockModels { /** * Load models from file */ - private static void loadModelFile(InputStream in, String fname) { + private static void loadModelFile(InputStream in, String fname, ConfigurationNode config) { LineNumberReader rdr = null; int cnt = 0; try { @@ -446,6 +447,22 @@ public class HDBlockModels { } else if(line.startsWith("#") || line.startsWith(";")) { } + else if(line.startsWith("enabled:")) { /* Test if texture file is enabled */ + line = line.substring(8).trim(); + if(line.startsWith("true")) { /* We're enabled? */ + /* Nothing to do - keep processing */ + } + else if(line.startsWith("false")) { /* Disabled */ + return; /* Quit */ + } + /* If setting is not defined or false, quit */ + else if(config.getBoolean(line, false) == false) { + return; + } + else { + Log.info(line + " models enabled"); + } + } else if(layerbits != 0) { /* If we're working pattern lines */ /* Layerbits determine Y, rows count from North to South (X=0 to X=N-1), columns Z are West to East (N-1 to 0) */ for(int i = 0; (i < scale) && (i < line.length()); i++) { diff --git a/src/main/java/org/dynmap/hdmap/TexturePack.java b/src/main/java/org/dynmap/hdmap/TexturePack.java index de55e530..d95cfa89 100644 --- a/src/main/java/org/dynmap/hdmap/TexturePack.java +++ b/src/main/java/org/dynmap/hdmap/TexturePack.java @@ -21,6 +21,7 @@ import javax.imageio.ImageIO; import org.bukkit.block.Biome; import org.dynmap.Color; +import org.dynmap.ConfigurationNode; import org.dynmap.DynmapPlugin; import org.dynmap.Log; import org.dynmap.MapManager; @@ -772,7 +773,7 @@ public class TexturePack { /** * Load texture pack mappings */ - public static void loadTextureMapping(File datadir) { + public static void loadTextureMapping(File datadir, ConfigurationNode config) { /* Start clean with texture packs - need to be loaded after mapping */ packs.clear(); /* Initialize map with blank map for all entries */ @@ -780,7 +781,7 @@ public class TexturePack { /* Load block models */ InputStream in = TexturePack.class.getResourceAsStream("/texture.txt"); if(in != null) { - loadTextureFile(in, "texture.txt"); + loadTextureFile(in, "texture.txt", config); if(in != null) { try { in.close(); } catch (IOException x) {} in = null; } } else @@ -795,7 +796,7 @@ public class TexturePack { if(custom.canRead()) { try { in = new FileInputStream(custom); - loadTextureFile(in, custom.getPath()); + loadTextureFile(in, custom.getPath(), config); } catch (IOException iox) { Log.severe("Error loading " + custom.getPath() + " - " + iox); } finally { @@ -810,7 +811,7 @@ public class TexturePack { /** * Load texture pack mappings from texture.txt file */ - private static void loadTextureFile(InputStream txtfile, String txtname) { + private static void loadTextureFile(InputStream txtfile, String txtname, ConfigurationNode config) { LineNumberReader rdr = null; int cnt = 0; HashMap filetoidx = new HashMap(); @@ -946,6 +947,22 @@ public class TexturePack { } else if(line.startsWith("#") || line.startsWith(";")) { } + else if(line.startsWith("enabled:")) { /* Test if texture file is enabled */ + line = line.substring(8).trim(); + if(line.startsWith("true")) { /* We're enabled? */ + /* Nothing to do - keep processing */ + } + else if(line.startsWith("false")) { /* Disabled */ + return; /* Quit */ + } + /* If setting is not defined or false, quit */ + else if(config.getBoolean(line, false) == false) { + return; + } + else { + Log.info(line + " textures enabled"); + } + } } Log.verboseinfo("Loaded " + cnt + " texture mappings from " + txtname); } catch (IOException iox) { diff --git a/src/main/resources/configuration.txt b/src/main/resources/configuration.txt index 9f9887b0..e0b71ee1 100644 --- a/src/main/resources/configuration.txt +++ b/src/main/resources/configuration.txt @@ -278,6 +278,9 @@ enabletilehash: true # 'newnorth' is used to rotate maps and rose (requires fullrender of any HDMap map - same as 'newrose' for FlatMap or KzedMap) #compass-mode: newnorth +# Enable Industrial Craft 2 block rendering support +#ic2-support: true + render-triggers: #- chunkloaded #- playermove