Fix cave renderer - handle different types of air in 1.13

This commit is contained in:
Mike Primm 2018-08-24 02:17:28 -05:00
parent 1babea2ace
commit d391d192d6
5 changed files with 59 additions and 29 deletions

View File

@ -42,7 +42,13 @@ public class CaveHDShader implements HDShader {
name = (String) configuration.get("name");
iflit = configuration.getBoolean("onlyiflit", false);
setHidden(DynmapBlockState.AIR); /* Air is hidden always */
for (int i = 0; i < DynmapBlockState.getGlobalIndexMax(); i++) {
DynmapBlockState bs = DynmapBlockState.getStateByGlobalIndex(i);
if (bs.isAir() || bs.isWater()) {
setHidden(bs);
}
}
List<Object> hidden = configuration.getList("hiddennames");
if(hidden != null) {
for(Object o : hidden) {
@ -60,6 +66,12 @@ public class CaveHDShader implements HDShader {
setHidden(DynmapBlockState.SNOW_BLOCK);
setHidden(DynmapBlockState.ICE_BLOCK);
setHidden(DynmapBlockState.SNOW_LAYER_BLOCK);
for (int i = 0; i < DynmapBlockState.getGlobalIndexMax(); i++) {
DynmapBlockState bs = DynmapBlockState.getStateByGlobalIndex(i);
if (bs.isLeaves() || bs.isSnow() || bs.isLog()) {
setHidden(bs);
}
}
}
}
@ -166,7 +178,7 @@ public class CaveHDShader implements HDShader {
if (isHidden(blocktype)) {
blocktype = DynmapBlockState.AIR;
}
else {
else if (blocktype.isNotAir()) {
air = false;
return false;
}

View File

@ -512,18 +512,17 @@ 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 */
if (skiptoair) { /* If skipping until we see air */
if (blocktype.isAir()) { /* If air, we're done */
skiptoair = false;
}
}
else if(nonairhit || blocktype.isNotAir()) {
done = true;
// If waterlogged, start by rendering as if full water block
if (blocktype.isWaterlogged()) {
boolean done = true;
DynmapBlockState saved_type = blocktype;
if (full_water == null) {
full_water = DynmapBlockState.getBaseStateByName(DynmapBlockState.WATER_BLOCK);
@ -536,12 +535,12 @@ public class IsoHDPerspective implements HDPerspective {
}
done = done && shaderdone[i];
}
// Restore block type
blocktype = saved_type;
/* If all are done, we're out */
if (done) {
return true;
}
// Restore block type
blocktype = saved_type;
nonairhit = true;
}
short[] model;
@ -559,12 +558,13 @@ public class IsoHDPerspective implements HDPerspective {
}
/* Look up to see if block is modelled */
if(patches != null) {
done = handlePatches(patches, shaderstate, shaderdone);
return handlePatches(patches, shaderstate, shaderdone);
}
else if ((model = scalemodels.getScaledModel(blocktype)) != null) {
done = handleSubModel(model, shaderstate, shaderdone);
return handleSubModel(model, shaderstate, shaderdone);
}
else {
boolean done = true;
subalpha = -1;
for(int i = 0; i < shaderstate.length; i++) {
if(!shaderdone[i]) {
@ -572,11 +572,12 @@ public class IsoHDPerspective implements HDPerspective {
}
done = done && shaderdone[i];
}
if (!done)
nonairhit = true;
if (done)
return true;
nonairhit = true;
}
}
return done;
return false;
}
/* Skip empty : return false if exited */

View File

@ -2143,12 +2143,6 @@ block:id=blue_ice,allfaces=0:blue_ice,stdrot=true
# Conduit
block:id=conduit,allfaces=0:conduit,transparency=TRANSPARENT
# Void air
block:id=void_air,transparency=TRANSPARENT
# Cave air
block:id=cave_air,transparency=TRANSPARENT
# Bubble column (taken care of due to being waterlogged)
block:id=bubble_column,transparency=SEMITRANSPARENT

View File

@ -34,6 +34,7 @@ public class DynmapBlockState {
private static int MATCH_LOG = 1 << 3;
private static int MATCH_GRASS = 1 << 4;
private static int MATCH_WATERLOGGED = 1 << 5;
private static int MATCH_LEAVES = 1 << 6;
// Map of base blocks by name
private static HashMap<String, DynmapBlockState> blocksByName = new HashMap<String, DynmapBlockState>();
@ -124,6 +125,7 @@ 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 |= log_blocks.contains(blockName) ? MATCH_LOG : 0;
}
/**
* Get state for same base block with given index
@ -191,6 +193,12 @@ public class DynmapBlockState {
public final boolean isAir() {
return (matchflags & MATCH_AIR) != 0;
}
/**
* Set to air
*/
public final void setAir() {
matchflags |= MATCH_AIR;
}
/**
* Return number of states under base state
* @return state count
@ -223,18 +231,10 @@ public class DynmapBlockState {
return (matchflags & MATCH_LOG) != 0;
}
/**
* Add log block name
* @param name - name of custom log block
* Set to log block
*/
public void addLogBlock(String name) {
log_blocks.add(name);
// Apply to existing blocks
DynmapBlockState bbs = DynmapBlockState.getBaseStateByName(name);
if (bbs.isNotAir()) {
for (int i = 0; i < bbs.getStateCount(); i++) {
bbs.states[i].matchflags |= MATCH_LOG;
}
}
public final void setLog() {
matchflags |= MATCH_LOG;
}
/**
* Test if block is water block
@ -286,6 +286,18 @@ public class DynmapBlockState {
public final void setWaterlogged() {
matchflags |= MATCH_WATERLOGGED;
}
/**
* Test if block is leaves
*/
public final boolean isLeaves() {
return (matchflags & MATCH_LEAVES) != 0;
}
/**
* Set state to be leaves
*/
public final void setLeaves() {
matchflags |= MATCH_LEAVES;
}
/**
* Test for matching blockname
*/

View File

@ -32,8 +32,10 @@ import org.dynmap.common.BiomeMap;
import net.minecraft.server.v1_13_R1.BiomeBase;
import net.minecraft.server.v1_13_R1.Block;
import net.minecraft.server.v1_13_R1.BlockFluids;
import net.minecraft.server.v1_13_R1.BlockLogAbstract;
import net.minecraft.server.v1_13_R1.IBlockData;
import net.minecraft.server.v1_13_R1.IBlockState;
import net.minecraft.server.v1_13_R1.Material;
/**
* Helper for isolation of bukkit version specific issues
@ -117,6 +119,15 @@ public class BukkitVersionHelperSpigot113 extends BukkitVersionHelperCB {
if ((!bd.s().e()) && ((bd.getBlock() instanceof BlockFluids) == false)) { // Test if fluid type for block is not empty
bs.setWaterlogged();
}
if (bd.getMaterial() == Material.AIR) {
bs.setAir();
}
if (bd.getMaterial() == Material.LEAVES) {
bs.setLeaves();
}
if (bd.getBlock() instanceof BlockLogAbstract) {
bs.setLog();
}
dataToState.put(bd, bs);
lastBlockState.put(bname, (lastbs == null) ? bs : lastbs);
Log.verboseinfo(i + ": blk=" + bname + ", idx=" + idx + ", state=" + sb + ", waterlogged=" + bs.isWaterlogged());