From bd182ef9df5d0d45aa8dd5a707f8d43d50f9cf91 Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Sat, 1 Oct 2011 07:49:28 +0800 Subject: [PATCH] Add 'fence-to-block-join' flag to enable 1.9+ fence rendering behavior --- src/main/java/org/dynmap/DynmapPlugin.java | 4 ++++ src/main/java/org/dynmap/MapManager.java | 6 +++++- .../java/org/dynmap/hdmap/IsoHDPerspective.java | 15 +++++++++++---- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/dynmap/DynmapPlugin.java b/src/main/java/org/dynmap/DynmapPlugin.java index 20d6340a..d3003747 100644 --- a/src/main/java/org/dynmap/DynmapPlugin.java +++ b/src/main/java/org/dynmap/DynmapPlugin.java @@ -84,6 +84,8 @@ public class DynmapPlugin extends JavaPlugin { public Events events = new Events(); public String deftemplatesuffix = ""; boolean swampshading = false; + boolean fencejoin = false; + /* Flag to let code know that we're doing reload - make sure we don't double-register event handlers */ public boolean is_reload = false; private boolean generate_only = false; @@ -251,6 +253,8 @@ public class DynmapPlugin extends JavaPlugin { deftemplatesuffix = configuration.getString("deftemplatesuffix", ""); /* Default swamp shading off for 1.8, on after */ swampshading = configuration.getBoolean("swampshaded", !getServer().getVersion().contains("(MC: 1.8")); + /* Default fence-to-block-join off for 1.8, on after */ + fencejoin = configuration.getBoolean("fence-to-block-join", !getServer().getVersion().contains("(MC: 1.8")); loadDebuggers(); diff --git a/src/main/java/org/dynmap/MapManager.java b/src/main/java/org/dynmap/MapManager.java index 55df549b..607dc48b 100644 --- a/src/main/java/org/dynmap/MapManager.java +++ b/src/main/java/org/dynmap/MapManager.java @@ -1144,7 +1144,11 @@ public class MapManager { public boolean getSwampShading() { return plug_in.swampshading; } - + + public boolean getFenceJoin() { + return plug_in.fencejoin; + } + public boolean getHideOres() { return hideores; } diff --git a/src/main/java/org/dynmap/hdmap/IsoHDPerspective.java b/src/main/java/org/dynmap/hdmap/IsoHDPerspective.java index fbc8f896..a656d69c 100644 --- a/src/main/java/org/dynmap/hdmap/IsoHDPerspective.java +++ b/src/main/java/org/dynmap/hdmap/IsoHDPerspective.java @@ -45,6 +45,7 @@ public class IsoHDPerspective implements HDPerspective { public double scale; /* Scale - tile pixel widths per block */ public double maxheight; public double minheight; + private boolean fencejoin; /* Coordinate space for tiles consists of a plane (X, Y), corresponding to the projection of each tile on to the * plane of the bottom of the world (X positive to the right, Y positive to the top), with Z+ corresponding to the * height above this plane on a vector towards the viewer). Logically, this makes the parallelogram representing the @@ -345,22 +346,26 @@ public class IsoHDPerspective implements HDPerspective { int id; /* Check north */ id = mapiter.getBlockTypeIDAt(BlockStep.X_MINUS); - if((id == blkid) || (id == FENCEGATE_BLKTYPEID)) { /* Fence? */ + if((id == blkid) || (id == FENCEGATE_BLKTYPEID) || + (fencejoin && (id > 0) && (HDTextureMap.getTransparency(id) == BlockTransparency.OPAQUE))) { /* Fence? */ blockdata |= 1; } /* Look east */ id = mapiter.getBlockTypeIDAt(BlockStep.Z_MINUS); - if((id == blkid) || (id == FENCEGATE_BLKTYPEID)) { /* Fence? */ + if((id == blkid) || (id == FENCEGATE_BLKTYPEID) || + (fencejoin && (id > 0) && (HDTextureMap.getTransparency(id) == BlockTransparency.OPAQUE))) { /* Fence? */ blockdata |= 2; } /* Look south */ id = mapiter.getBlockTypeIDAt(BlockStep.X_PLUS); - if((id == blkid) || (id == FENCEGATE_BLKTYPEID)) { /* Fence? */ + if((id == blkid) || (id == FENCEGATE_BLKTYPEID) || + (fencejoin && (id > 0) && (HDTextureMap.getTransparency(id) == BlockTransparency.OPAQUE))) { /* Fence? */ blockdata |= 4; } /* Look west */ id = mapiter.getBlockTypeIDAt(BlockStep.Z_PLUS); - if((id == blkid) || (id == FENCEGATE_BLKTYPEID)) { /* Fence? */ + if((id == blkid) || (id == FENCEGATE_BLKTYPEID) || + (fencejoin && (id > 0) && (HDTextureMap.getTransparency(id) == BlockTransparency.OPAQUE))) { /* Fence? */ blockdata |= 8; } return blockdata; @@ -739,6 +744,8 @@ public class IsoHDPerspective implements HDPerspective { if(maxheight > 127) maxheight = 127; minheight = configuration.getInteger("minimumheight", 0); if(minheight < 0) minheight = 0; + /* Fence-to-block-join setting */ + fencejoin = configuration.getBoolean("fence-to-block-join", MapManager.mapman.getFenceJoin()); /* Generate transform matrix for world-to-tile coordinate mapping */ /* First, need to fix basic coordinate mismatches before rotation - we want zero azimuth to have north to top