Add 'hideores' option to make ore blocks look like plain stone

This commit is contained in:
Mike Primm 2011-09-29 10:45:49 +08:00 committed by mikeprimm
parent 560fe3c539
commit 515b2f4afc
6 changed files with 62 additions and 0 deletions

View File

@ -28,6 +28,15 @@ public class ColorScheme {
this.biomecolors = biomecolors; this.biomecolors = biomecolors;
this.raincolors = raincolors; this.raincolors = raincolors;
this.tempcolors = tempcolors; this.tempcolors = tempcolors;
if(MapManager.mapman.getHideOres()) {
for(int i = 0; i < colors.length; i++) {
int id = MapManager.mapman.getBlockIDAlias(i);
if(id != i) {
this.colors[i] = this.colors[id];
this.datacolors[i] = this.datacolors[id];
}
}
}
} }
private static File getColorSchemeDirectory() { private static File getColorSchemeDirectory() {

View File

@ -20,6 +20,7 @@ import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitScheduler;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -46,6 +47,7 @@ public class MapManager {
private int parallelrendercnt = 0; private int parallelrendercnt = 0;
private int progressinterval = 100; private int progressinterval = 100;
private boolean saverestorepending = true; private boolean saverestorepending = true;
private boolean hideores = false;
private int zoomout_period = DEFAULT_ZOOMOUT_PERIOD; /* Zoom-out tile processing period, in seconds */ private int zoomout_period = DEFAULT_ZOOMOUT_PERIOD; /* Zoom-out tile processing period, in seconds */
/* Which fullrenders are active */ /* Which fullrenders are active */
@ -597,8 +599,13 @@ public class MapManager {
public MapManager(DynmapPlugin plugin, ConfigurationNode configuration) { public MapManager(DynmapPlugin plugin, ConfigurationNode configuration) {
plug_in = plugin; plug_in = plugin;
mapman = this; mapman = this;
/* Get block hiding data, if any */
hideores = configuration.getBoolean("hideores", false);
/* Clear color scheme */ /* Clear color scheme */
ColorScheme.reset(); ColorScheme.reset();
/* Initialize HD map manager */ /* Initialize HD map manager */
hdmapman = new HDMapManager(); hdmapman = new HDMapManager();
hdmapman.loadHDShaders(plugin); hdmapman.loadHDShaders(plugin);
@ -1137,4 +1144,22 @@ public class MapManager {
public boolean getSwampShading() { public boolean getSwampShading() {
return plug_in.swampshading; return plug_in.swampshading;
} }
public boolean getHideOres() {
return hideores;
}
/* Map block ID to aliased ID - used to hide ores */
public int getBlockIDAlias(int id) {
if(!hideores) return id;
switch(id) {
case 14: /* Gold Ore */
case 15: /* Iron Ore */
case 16: /* Coal Ore */
case 21: /* Lapis Lazuli Ore */
case 56: /* Diamond Ore */
case 73: /* Redstone ore */
return 1; /* Stone */
}
return id;
}
} }

View File

@ -57,6 +57,8 @@ public class HDMapManager {
} }
} }
Log.info("Loaded " + shaders.size() + " shaders."); Log.info("Loaded " + shaders.size() + " shaders.");
/* Update ore mappings, if needed */
TexturePack.handleHideOres();
} }
public void loadHDPerspectives(DynmapPlugin plugin) { public void loadHDPerspectives(DynmapPlugin plugin) {

View File

@ -23,6 +23,7 @@ import org.bukkit.block.Biome;
import org.dynmap.Color; import org.dynmap.Color;
import org.dynmap.DynmapPlugin; import org.dynmap.DynmapPlugin;
import org.dynmap.Log; import org.dynmap.Log;
import org.dynmap.MapManager;
import org.dynmap.utils.DynmapBufferedImage; import org.dynmap.utils.DynmapBufferedImage;
import org.dynmap.utils.MapIterator.BlockStep; import org.dynmap.utils.MapIterator.BlockStep;
import org.dynmap.kzedmap.KzedMap; import org.dynmap.kzedmap.KzedMap;
@ -183,6 +184,13 @@ public class TexturePack {
public static BlockTransparency getTransparency(int blkid) { public static BlockTransparency getTransparency(int blkid) {
return transp[blkid]; return transp[blkid];
} }
private static void remapTexture(int id, int srcid) {
for(int i = 0; i < 16; i++) {
texmaps[(id<<4)+i] = texmaps[(srcid<<4)+i];
}
}
} }
/** Get or load texture pack */ /** Get or load texture pack */
public static TexturePack getTexturePack(String tpname) { public static TexturePack getTexturePack(String tpname) {
@ -837,6 +845,20 @@ public class TexturePack {
} }
} }
} }
/* Process any ore hiding mappings */
public static void handleHideOres() {
/* Now, fix mapping if we're hiding any ores */
if(MapManager.mapman.getHideOres()) {
for(int i = 0; i < 256; i++) {
int id = MapManager.mapman.getBlockIDAlias(i);
if(id != i) { /* New mapping? */
HDTextureMap.remapTexture(i, id);
}
}
}
}
/** /**
* Read color for given subblock coordinate, with given block id and data and face * Read color for given subblock coordinate, with given block id and data and face
*/ */

View File

@ -240,6 +240,9 @@ enabletilehash: true
# Optional - control darkening of biome-shaded colors in swamp biomes (1.9+) - default is true for 1.9+, false for 1.8.x # Optional - control darkening of biome-shaded colors in swamp biomes (1.9+) - default is true for 1.9+, false for 1.8.x
#swampshaded: false #swampshaded: false
# Optional - hide ores: render as normal stone (so that they aren't revealed by maps)
#hideores: true
render-triggers: render-triggers:
#- chunkloaded #- chunkloaded
#- playermove #- playermove

View File

@ -50,6 +50,7 @@ worlds:
# Use 'template: mycustomtemplate' to use the properties specified in the template 'mycustomtemplate' to this world. Default it is set to the environment-name (normal or nether). # Use 'template: mycustomtemplate' to use the properties specified in the template 'mycustomtemplate' to this world. Default it is set to the environment-name (normal or nether).
# template: mycustomtemplate # template: mycustomtemplate
# Rest of comes from template - uncomment to tailor for world specifically # Rest of comes from template - uncomment to tailor for world specifically
# # World center - default is spawn point
# center: # center:
# x: 0 # x: 0
# y: 64 # y: 64