From 2ebab4b7fc43132925bb7c3b120840212db17903 Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Mon, 20 Aug 2018 16:19:44 -0400 Subject: [PATCH] Handle waterlogged/water-filled blocks, fix turtle eggs, pickles --- .../org/dynmap/hdmap/IsoHDPerspective.java | 33 +++++++++---------- .../java/org/dynmap/hdmap/TexturePack.java | 6 ++-- DynmapCore/src/main/resources/models_1.txt | 18 ++++++++-- DynmapCore/src/main/resources/texture_1.txt | 26 +++++++-------- .../org/dynmap/renderer/DynmapBlockState.java | 7 +++- .../v113/BukkitVersionHelperSpigot113.java | 6 +++- 6 files changed, 59 insertions(+), 37 deletions(-) diff --git a/DynmapCore/src/main/java/org/dynmap/hdmap/IsoHDPerspective.java b/DynmapCore/src/main/java/org/dynmap/hdmap/IsoHDPerspective.java index 70787cba..185654ef 100644 --- a/DynmapCore/src/main/java/org/dynmap/hdmap/IsoHDPerspective.java +++ b/DynmapCore/src/main/java/org/dynmap/hdmap/IsoHDPerspective.java @@ -512,6 +512,7 @@ public class IsoHDPerspective implements HDPerspective { * Process visit of ray to block */ private final boolean visit_block(HDShaderState[] shaderstate, boolean[] shaderdone) { + boolean done = false; lastblocktype = blocktype; blocktype = mapiter.getBlockType(); if(skiptoair) { /* If skipping until we see air */ @@ -520,6 +521,7 @@ public class IsoHDPerspective implements HDPerspective { } } else if(nonairhit || blocktype.isNotAir()) { + done = true; // If waterlogged, start by rendering as if full water block if (blocktype.isWaterlogged()) { DynmapBlockState saved_type = blocktype; @@ -527,7 +529,6 @@ public class IsoHDPerspective implements HDPerspective { full_water = DynmapBlockState.getBaseStateByName(DynmapBlockState.WATER_BLOCK); } blocktype = full_water; // Switch to water state - boolean done = true; subalpha = -1; for (int i = 0; i < shaderstate.length; i++) { if(!shaderdone[i]) { @@ -535,20 +536,22 @@ public class IsoHDPerspective implements HDPerspective { } done = done && shaderdone[i]; } + /* If all are done, we're out */ + if (done) { + return true; + } // Restore block type blocktype = saved_type; - /* If all are done, we're out */ - if (done) - return true; nonairhit = true; } + short[] model; RenderPatch[] patches = scalemodels.getPatchModel(blocktype); /* If no patches, see if custom model */ - if(patches == null) { + if (patches == null) { CustomBlockModel cbm = scalemodels.getCustomBlockModel(blocktype); - if(cbm != null) { /* If found, see if cached already */ + if (cbm != null) { /* If found, see if cached already */ patches = this.getCustomMesh(); - if(patches == null) { + if (patches == null) { patches = cbm.getMeshForBlock(mapiter); this.setCustomMesh(patches); } @@ -556,14 +559,12 @@ public class IsoHDPerspective implements HDPerspective { } /* Look up to see if block is modelled */ if(patches != null) { - return handlePatches(patches, shaderstate, shaderdone); + done = handlePatches(patches, shaderstate, shaderdone); } - short[] model = scalemodels.getScaledModel(blocktype); - if(model != null) { - return handleSubModel(model, shaderstate, shaderdone); + else if ((model = scalemodels.getScaledModel(blocktype)) != null) { + done = handleSubModel(model, shaderstate, shaderdone); } else { - boolean done = true; subalpha = -1; for(int i = 0; i < shaderstate.length; i++) { if(!shaderdone[i]) { @@ -571,13 +572,11 @@ public class IsoHDPerspective implements HDPerspective { } done = done && shaderdone[i]; } - /* If all are done, we're out */ - if(done) - return true; - nonairhit = true; + if (!done) + nonairhit = true; } } - return false; + return done; } /* Skip empty : return false if exited */ diff --git a/DynmapCore/src/main/java/org/dynmap/hdmap/TexturePack.java b/DynmapCore/src/main/java/org/dynmap/hdmap/TexturePack.java index 35914903..e8825ff2 100644 --- a/DynmapCore/src/main/java/org/dynmap/hdmap/TexturePack.java +++ b/DynmapCore/src/main/java/org/dynmap/hdmap/TexturePack.java @@ -2727,7 +2727,7 @@ public class TexturePack { /* If clear-inside op, get out early */ if((textop == COLORMOD_CLEARINSIDE) || (textop == COLORMOD_MULTTONED_CLEARINSIDE)) { /* Check if previous block is same block type as we are: surface is transparent if it is */ - if (blk.matchingBaseState(lastblocktype)) { + if (blk.matchingBaseState(lastblocktype) || (blk.isWater() && lastblocktype.isWaterlogged())) { rslt.setTransparent(); return; } @@ -3480,10 +3480,10 @@ public class TexturePack { textid = textid % COLORMOD_MULT_INTERNAL; BlockStep step = steps[patchidx]; /* If clear-inside op, get out early */ - if((mod == COLORMOD_CLEARINSIDE) || (mod == COLORMOD_MULTTONED_CLEARINSIDE)) { + if ((mod == COLORMOD_CLEARINSIDE) || (mod == COLORMOD_MULTTONED_CLEARINSIDE)) { BlockStep dir = step.opposite(); /* Check if previous block is same block type as we are: surface is transparent if it is */ - if (blk == mapiter.getBlockTypeAt(dir)) { + if (blk.matchingBaseState(mapiter.getBlockTypeAt(dir))) { continue; // Skip: no texture } /* If water block, to watercolor tone op */ diff --git a/DynmapCore/src/main/resources/models_1.txt b/DynmapCore/src/main/resources/models_1.txt index 8469a867..ffa8eb4c 100644 --- a/DynmapCore/src/main/resources/models_1.txt +++ b/DynmapCore/src/main/resources/models_1.txt @@ -1328,8 +1328,14 @@ boxblock:id=grass_path,ymax=0.9375 # Kelp Plant patchblock:id=kelp,id=kelp_plant,patch0=VertX1Z0ToX0Z1,patch1=VertX1Z0ToX0Z1@90 -# Turtle egg -boxblock:id=turtle_egg,xmin=0.3125,xmax=0.625,ymax=0.4375,zmin=0.25,zmax=0.5625 +# Turtle egg - single +customblock:id=turtle_egg,data=0,data=1,data=2,class=org.dynmap.hdmap.renderer.CuboidRenderer,cuboid0=0.3125:0:0.25/0.625:0.4275:0.5625 +# Turtle egg - double +customblock:id=turtle_egg,data=3,data=4,data=5,class=org.dynmap.hdmap.renderer.CuboidRenderer,cuboid0=0.3125:0:0.25/0.625:0.4275:0.5625,cuboid1=0.0625:0:0.4275/0.3125:0.3125:0.6875 +# Turtle egg - triple +customblock:id=turtle_egg,data=6,data=7,data=8,class=org.dynmap.hdmap.renderer.CuboidRenderer,cuboid0=0.3125:0:0.25/0.625:0.4275:0.5625,cuboid1=0.0625:0:0.4275/0.3125:0.3125:0.6875,cuboid2=0.6875:0:0.4275/0.875:0.25:0.625 +# Turtle egg - quad +customblock:id=turtle_egg,data=9,data=10,data=11,class=org.dynmap.hdmap.renderer.CuboidRenderer,cuboid0=0.3125:0:0.25/0.625:0.4275:0.5625,cuboid1=0.0625:0:0.4275/0.3125:0.3125:0.6875,cuboid2=0.6875:0:0.4275/0.875:0.25:0.625,cuboid3=0.4275:0:0.625/0.625:0.1875:0.8125 # Patch for coral wall fan - 22.5 degrees up patch:id=CoralFan0u,Ox=0.0,Oy=0.4375,Oz=0.0,Ux=1.0,Uy=0.4375,Uz=0.0,Vx=0.0,Vy=0.9375,Vz=1.0 @@ -1358,3 +1364,11 @@ patchblock:id=dead_tube_coral_wall_fan,id=dead_fire_coral_wall_fan,id=dead_brain # Coral fan on bottom patchblock:id=dead_tube_coral_fan,id=dead_fire_coral_fan,id=dead_brain_coral_fan,id=dead_horn_coral_fan,id=dead_bubble_coral_fan,id=tube_coral_fan,id=fire_coral_fan,id=brain_coral_fan,id=horn_coral_fan,id=bubble_coral_fan,data=0,data=1,patch0=CoralFan0f,patch1=CoralFan1f,patch2=CoralFan2f,patch3=CoralFan3f +# Sea pickle - single +customblock:id=sea_pickle,data=0,data=1,class=org.dynmap.hdmap.renderer.CuboidRenderer,cuboid0=0.375:0:0.375/0.625:0.375:0.625 +# Sea pickle - double +customblock:id=sea_pickle,data=2,data=3,class=org.dynmap.hdmap.renderer.CuboidRenderer,cuboid0=0.1875:0:0.1875/0.4375:0.375:0.4375,cuboid1=0.5:0:0.5/0.75:0.25:0.75 +# Sea pickle - triple +customblock:id=sea_pickle,data=4,data=5,class=org.dynmap.hdmap.renderer.CuboidRenderer,cuboid0=0.375:0:0.5625/0.625:0.375:0.8125,cuboid1=0.125:0:0.125/0.375:0.25:0.375,cuboid2=0.5:0:0.25/0.75:0.375:0.5 +# Sea pickle - quad +customblock:id=sea_pickle,data=6,data=7,class=org.dynmap.hdmap.renderer.CuboidRenderer,cuboid0=0.125:0:0.125/0.375:0.375:0.375,cuboid1=0.5625:0:0.625/0.8125:0.25:0.875,cuboid2=0.5625:0:0.125/0.8125:0.375:0.375,cuboid3=0.125:0:0.5/0.375:0.4275:0.75 diff --git a/DynmapCore/src/main/resources/texture_1.txt b/DynmapCore/src/main/resources/texture_1.txt index 569d8f8b..ee6ddb4c 100644 --- a/DynmapCore/src/main/resources/texture_1.txt +++ b/DynmapCore/src/main/resources/texture_1.txt @@ -1628,7 +1628,7 @@ block:id=prismarine_bricks,allfaces=0:prismarine_bricks,stdrot=true # Dark Prismarine block:id=dark_prismarine,allfaces=0:dark_prismarine,stdrot=true # Sea Lantern -block:id=sea_lantern,data=*,allfaces=0:sea_lantern,stdrot=true +block:id=sea_lantern,allfaces=0:sea_lantern,stdrot=true # Red Sandstone @@ -2006,6 +2006,8 @@ texture:id=dried_kelp_side texture:id=dried_kelp_top texture:id=dried_kelp_bottom texture:id=turtle_egg +texture:id=turtle_egg_slightly_cracked +texture:id=turtle_egg_very_cracked texture:id=dead_tube_coral_block texture:id=dead_brain_coral_block texture:id=dead_bubble_coral_block @@ -2027,7 +2029,7 @@ texture:id=bubble_coral_fan texture:id=fire_coral_fan texture:id=horn_coral_fan texture:id=blue_ice -tecture:id=sea_pickles +texture:id=sea_pickle # Kelp block:id=kelp,patch0-1=1000:kelp,stdrot=true,transparency=TRANSPARENT @@ -2036,10 +2038,14 @@ block:id=kelp,patch0-1=1000:kelp,stdrot=true,transparency=TRANSPARENT block:id=kelp,patch0-1=1000:kelp_plant,stdrot=true,transparency=TRANSPARENT # Dried kelp block -block:id=dried_kelp,allsides=0:dried_kelp_side,top=0:dried_kelp_top,bottom=0:dried_kelp_bottom,stdrot=true +block:id=dried_kelp_block,allsides=0:dried_kelp_side,top=0:dried_kelp_top,bottom=0:dried_kelp_bottom,stdrot=true # Turtle egg -block:id=turtle_egg,allfaces=0:turtle_egg,stdrot=true,transparency=TRANSPARENT +block:id=turtle_egg,data=0,data=3,data=6,data=9,patch0-5=0:turtle_egg,transparency=TRANSPARENT +# Turtle egg - slightly cracked +block:id=turtle_egg,data=1,data=4,data=7,data=10,patch0-5=0:turtle_egg_slightly_cracked,transparency=TRANSPARENT +# Turtle egg - very cracked +block:id=turtle_egg,data=2,data=5,data=8,data=11,patch0-5=0:turtle_egg_very_cracked,transparency=TRANSPARENT # Dead tube coral block block:id=dead_tube_coral_block,allfaces=0:dead_tube_coral_block,stdrot=true @@ -2131,17 +2137,11 @@ block:id=fire_coral_fan,patch0-3=0:fire_coral_fan,stdrot=true,transparency=TRANS # Horn coral fan block:id=horn_coral_fan,patch0-3=0:horn_coral_fan,stdrot=true,transparency=TRANSPARENT -#[18:55:16] [Server thread/INFO]: [dynmap] 8564: blk=minecraft:sea_pickle, idx=0, state=pickles=1,waterlogged=true -#[18:55:16] [Server thread/INFO]: [dynmap] 8565: blk=minecraft:sea_pickle, idx=1, state=pickles=1,waterlogged=false -#[18:55:16] [Server thread/INFO]: [dynmap] 8566: blk=minecraft:sea_pickle, idx=2, state=pickles=2,waterlogged=true -#[18:55:16] [Server thread/INFO]: [dynmap] 8567: blk=minecraft:sea_pickle, idx=3, state=pickles=2,waterlogged=false -#[18:55:16] [Server thread/INFO]: [dynmap] 8568: blk=minecraft:sea_pickle, idx=4, state=pickles=3,waterlogged=true -#[18:55:16] [Server thread/INFO]: [dynmap] 8569: blk=minecraft:sea_pickle, idx=5, state=pickles=3,waterlogged=false -#[18:55:16] [Server thread/INFO]: [dynmap] 8570: blk=minecraft:sea_pickle, idx=6, state=pickles=4,waterlogged=true -#[18:55:16] [Server thread/INFO]: [dynmap] 8571: blk=minecraft:sea_pickle, idx=7, state=pickles=4,waterlogged=false +# Sea pickle +block:id=sea_pickle,patch0-5=0:sea_pickle,transparency=TRANSPARENT # Blue Ice -block:id=bloe_ice,allfaces=0:blue_ice,stdrot=true +block:id=blue_ice,allfaces=0:blue_ice,stdrot=true #[18:55:16] [Server thread/INFO]: [dynmap] 8573: blk=minecraft:conduit, idx=0, state= diff --git a/DynmapCoreAPI/src/main/java/org/dynmap/renderer/DynmapBlockState.java b/DynmapCoreAPI/src/main/java/org/dynmap/renderer/DynmapBlockState.java index 0e3f5000..a5f799df 100644 --- a/DynmapCoreAPI/src/main/java/org/dynmap/renderer/DynmapBlockState.java +++ b/DynmapCoreAPI/src/main/java/org/dynmap/renderer/DynmapBlockState.java @@ -124,7 +124,6 @@ public class DynmapBlockState { matchflags |= isWater(blockName) ? MATCH_WATER : 0; matchflags |= (blockName.equals(SNOW_BLOCK) || blockName.equals(SNOW_LAYER_BLOCK)) ? MATCH_SNOW : 0; matchflags |= blockName.equals(GRASS_BLOCK) ? MATCH_GRASS : 0; - matchflags |= stateName.contains("waterlogged=true") ? MATCH_WATERLOGGED : 0; } /** * Get state for same base block with given index @@ -281,6 +280,12 @@ public class DynmapBlockState { public final boolean isWaterlogged() { return (matchflags & MATCH_WATERLOGGED) != 0; } + /** + * Set state to be waterlogged (block filled with water) + */ + public final void setWaterlogged() { + matchflags |= MATCH_WATERLOGGED; + } /** * Test for matching blockname */ diff --git a/bukkit-helper-113/src/main/java/org/dynmap/bukkit/helper/v113/BukkitVersionHelperSpigot113.java b/bukkit-helper-113/src/main/java/org/dynmap/bukkit/helper/v113/BukkitVersionHelperSpigot113.java index f61f9e46..f651f47b 100644 --- a/bukkit-helper-113/src/main/java/org/dynmap/bukkit/helper/v113/BukkitVersionHelperSpigot113.java +++ b/bukkit-helper-113/src/main/java/org/dynmap/bukkit/helper/v113/BukkitVersionHelperSpigot113.java @@ -28,6 +28,7 @@ import org.dynmap.utils.MapChunkCache; import org.dynmap.utils.Polygon; import org.dynmap.bukkit.helper.v113.MapChunkCache113; import net.minecraft.server.v1_13_R1.Block; +import net.minecraft.server.v1_13_R1.BlockFluids; import net.minecraft.server.v1_13_R1.IBlockData; import net.minecraft.server.v1_13_R1.IBlockState; @@ -110,9 +111,12 @@ public class BukkitVersionHelperSpigot113 extends BukkitVersionHelperCB { sb = fname.substring(off1+1, off2); } DynmapBlockState bs = new DynmapBlockState(lastbs, idx, bname, sb); + if ((!bd.s().e()) && ((bd.getBlock() instanceof BlockFluids) == false)) { // Test if fluid type for block is not empty + bs.setWaterlogged(); + } dataToState.put(bd, bs); lastBlockState.put(bname, (lastbs == null) ? bs : lastbs); - Log.info(i + ": blk=" + bname + ", idx=" + idx + ", state=" + sb); + Log.info(i + ": blk=" + bname + ", idx=" + idx + ", state=" + sb + ", waterlogged=" + bs.isWaterlogged()); } } /**