mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-09-12 06:08:07 +02:00
Split renderdata (generated data) from normal block data - to help
with custom block work
This commit is contained in:
parent
f4de63e85e
commit
fc1fec4af8
@ -31,11 +31,11 @@ public class HDBlockModels {
|
|||||||
public static class HDScaledBlockModels {
|
public static class HDScaledBlockModels {
|
||||||
private short[][][] modelvectors;
|
private short[][][] modelvectors;
|
||||||
|
|
||||||
public final short[] getScaledModel(int blocktype, int blockdata) {
|
public final short[] getScaledModel(int blocktype, int blockdata, int blockrenderdata) {
|
||||||
if(modelvectors[blocktype] == null) {
|
if(modelvectors[blocktype] == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return modelvectors[blocktype][blockdata];
|
return modelvectors[blocktype][(blockrenderdata>=0)?blockrenderdata:blockdata];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,10 @@ public interface HDPerspectiveState {
|
|||||||
* Get current block data
|
* Get current block data
|
||||||
*/
|
*/
|
||||||
int getBlockData();
|
int getBlockData();
|
||||||
|
/**
|
||||||
|
* Get current block render data
|
||||||
|
*/
|
||||||
|
int getBlockRenderData();
|
||||||
/**
|
/**
|
||||||
* Get direction of last block step
|
* Get direction of last block step
|
||||||
*/
|
*/
|
||||||
|
@ -95,6 +95,7 @@ public class IsoHDPerspective implements HDPerspective {
|
|||||||
private class OurPerspectiveState implements HDPerspectiveState {
|
private class OurPerspectiveState implements HDPerspectiveState {
|
||||||
int blocktypeid = 0;
|
int blocktypeid = 0;
|
||||||
int blockdata = 0;
|
int blockdata = 0;
|
||||||
|
int blockrenderdata = -1;
|
||||||
int lastblocktypeid = 0;
|
int lastblocktypeid = 0;
|
||||||
Vector3D top, bottom;
|
Vector3D top, bottom;
|
||||||
int px, py;
|
int px, py;
|
||||||
@ -193,6 +194,10 @@ public class IsoHDPerspective implements HDPerspective {
|
|||||||
* Get current block data
|
* Get current block data
|
||||||
*/
|
*/
|
||||||
public final int getBlockData() { return blockdata; }
|
public final int getBlockData() { return blockdata; }
|
||||||
|
/**
|
||||||
|
* Get current block render data
|
||||||
|
*/
|
||||||
|
public final int getBlockRenderData() { return blockrenderdata; }
|
||||||
/**
|
/**
|
||||||
* Get direction of last block step
|
* Get direction of last block step
|
||||||
*/
|
*/
|
||||||
@ -473,22 +478,23 @@ public class IsoHDPerspective implements HDPerspective {
|
|||||||
skiptoair = false;
|
skiptoair = false;
|
||||||
}
|
}
|
||||||
else if(nonairhit || (blocktypeid != 0)) {
|
else if(nonairhit || (blocktypeid != 0)) {
|
||||||
|
blockdata = mapiter.getBlockData();
|
||||||
switch(blocktypeid) {
|
switch(blocktypeid) {
|
||||||
case FENCE_BLKTYPEID: /* Special case for fence - need to fake data so we can render properly */
|
case FENCE_BLKTYPEID: /* Special case for fence - need to fake data so we can render properly */
|
||||||
blockdata = generateFenceBlockData(mapiter);
|
blockrenderdata = generateFenceBlockData(mapiter);
|
||||||
break;
|
break;
|
||||||
case CHEST_BLKTYPEID: /* Special case for chest - need to fake data so we can render */
|
case CHEST_BLKTYPEID: /* Special case for chest - need to fake data so we can render */
|
||||||
blockdata = generateChestBlockData(mapiter);
|
blockrenderdata = generateChestBlockData(mapiter);
|
||||||
break;
|
break;
|
||||||
case REDSTONE_BLKTYPEID: /* Special case for redstone - fake data for wire pattern */
|
case REDSTONE_BLKTYPEID: /* Special case for redstone - fake data for wire pattern */
|
||||||
blockdata = generateRedstoneWireBlockData(mapiter);
|
blockrenderdata = generateRedstoneWireBlockData(mapiter);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
blockdata = mapiter.getBlockData();
|
blockrenderdata = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* Look up to see if block is modelled */
|
/* Look up to see if block is modelled */
|
||||||
short[] model = scalemodels.getScaledModel(blocktypeid, blockdata);
|
short[] model = scalemodels.getScaledModel(blocktypeid, blockdata, blockrenderdata);
|
||||||
if(model != null) {
|
if(model != null) {
|
||||||
return handleSubModel(model, shaderstate, shaderdone);
|
return handleSubModel(model, shaderstate, shaderdone);
|
||||||
}
|
}
|
||||||
|
@ -120,12 +120,15 @@ public class TexturePack {
|
|||||||
private List<Integer> blockids;
|
private List<Integer> blockids;
|
||||||
private int databits;
|
private int databits;
|
||||||
private BlockTransparency bt;
|
private BlockTransparency bt;
|
||||||
|
private boolean userender;
|
||||||
private static HDTextureMap[] texmaps;
|
private static HDTextureMap[] texmaps;
|
||||||
private static BlockTransparency transp[];
|
private static BlockTransparency transp[];
|
||||||
|
private static boolean userenderdata[];
|
||||||
|
|
||||||
private static void initializeTable() {
|
private static void initializeTable() {
|
||||||
texmaps = new HDTextureMap[16*BLOCKTABLELEN];
|
texmaps = new HDTextureMap[16*BLOCKTABLELEN];
|
||||||
transp = new BlockTransparency[BLOCKTABLELEN];
|
transp = new BlockTransparency[BLOCKTABLELEN];
|
||||||
|
userenderdata = new boolean[BLOCKTABLELEN];
|
||||||
HDTextureMap blank = new HDTextureMap();
|
HDTextureMap blank = new HDTextureMap();
|
||||||
for(int i = 0; i < texmaps.length; i++)
|
for(int i = 0; i < texmaps.length; i++)
|
||||||
texmaps[i] = blank;
|
texmaps[i] = blank;
|
||||||
@ -136,6 +139,7 @@ public class TexturePack {
|
|||||||
private HDTextureMap() {
|
private HDTextureMap() {
|
||||||
blockids = Collections.singletonList(Integer.valueOf(0));
|
blockids = Collections.singletonList(Integer.valueOf(0));
|
||||||
databits = 0xFFFF;
|
databits = 0xFFFF;
|
||||||
|
userender = false;
|
||||||
faces = new int[] { BLOCKINDEX_BLANK, BLOCKINDEX_BLANK, BLOCKINDEX_BLANK, BLOCKINDEX_BLANK, BLOCKINDEX_BLANK, BLOCKINDEX_BLANK };
|
faces = new int[] { BLOCKINDEX_BLANK, BLOCKINDEX_BLANK, BLOCKINDEX_BLANK, BLOCKINDEX_BLANK, BLOCKINDEX_BLANK, BLOCKINDEX_BLANK };
|
||||||
|
|
||||||
for(int i = 0; i < texmaps.length; i++) {
|
for(int i = 0; i < texmaps.length; i++) {
|
||||||
@ -143,11 +147,12 @@ public class TexturePack {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public HDTextureMap(List<Integer> blockids, int databits, int[] faces, BlockTransparency trans) {
|
public HDTextureMap(List<Integer> blockids, int databits, int[] faces, BlockTransparency trans, boolean userender) {
|
||||||
this.faces = faces;
|
this.faces = faces;
|
||||||
this.blockids = blockids;
|
this.blockids = blockids;
|
||||||
this.databits = databits;
|
this.databits = databits;
|
||||||
this.bt = trans;
|
this.bt = trans;
|
||||||
|
this.userender = userender;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addToTable() {
|
public void addToTable() {
|
||||||
@ -159,11 +164,15 @@ public class TexturePack {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
transp[blkid] = bt; /* Transparency is only blocktype based right now */
|
transp[blkid] = bt; /* Transparency is only blocktype based right now */
|
||||||
|
userenderdata[blkid] = userender; /* Ditto for using render data */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HDTextureMap getMap(int blkid, int blkdata) {
|
public static HDTextureMap getMap(int blkid, int blkdata, int blkrenderdata) {
|
||||||
return texmaps[(blkid<<4) + blkdata];
|
if(userenderdata[blkid])
|
||||||
|
return texmaps[(blkid<<4) + blkrenderdata];
|
||||||
|
else
|
||||||
|
return texmaps[(blkid<<4) + blkdata];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BlockTransparency getTransparency(int blkid) {
|
public static BlockTransparency getTransparency(int blkid) {
|
||||||
@ -704,6 +713,7 @@ public class TexturePack {
|
|||||||
line = line.substring(6);
|
line = line.substring(6);
|
||||||
BlockTransparency trans = BlockTransparency.OPAQUE;
|
BlockTransparency trans = BlockTransparency.OPAQUE;
|
||||||
String[] args = line.split(",");
|
String[] args = line.split(",");
|
||||||
|
boolean userenderdata = false;
|
||||||
for(String a : args) {
|
for(String a : args) {
|
||||||
String[] av = a.split("=");
|
String[] av = a.split("=");
|
||||||
if(av.length < 2) continue;
|
if(av.length < 2) continue;
|
||||||
@ -759,12 +769,15 @@ public class TexturePack {
|
|||||||
Log.severe("Texture mapping has invalid transparency setting - " + av[1] + " - line " + rdr.getLineNumber() + " of " + txtname);
|
Log.severe("Texture mapping has invalid transparency setting - " + av[1] + " - line " + rdr.getLineNumber() + " of " + txtname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(av[0].equals("userenderdata")) {
|
||||||
|
userenderdata = av[1].equals("true");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* If no data bits, assume all */
|
/* If no data bits, assume all */
|
||||||
if(databits < 0) databits = 0xFFFF;
|
if(databits < 0) databits = 0xFFFF;
|
||||||
/* If we have everything, build block */
|
/* If we have everything, build block */
|
||||||
if(blkids.size() > 0) {
|
if(blkids.size() > 0) {
|
||||||
HDTextureMap map = new HDTextureMap(blkids, databits, faces, trans);
|
HDTextureMap map = new HDTextureMap(blkids, databits, faces, trans, userenderdata);
|
||||||
map.addToTable();
|
map.addToTable();
|
||||||
cnt++;
|
cnt++;
|
||||||
}
|
}
|
||||||
@ -795,7 +808,7 @@ public class TexturePack {
|
|||||||
*/
|
*/
|
||||||
public final void readColor(final HDPerspectiveState ps, final MapIterator mapiter, final Color rslt, final int blkid, final int lastblocktype, final boolean biome_shaded) {
|
public final void readColor(final HDPerspectiveState ps, final MapIterator mapiter, final Color rslt, final int blkid, final int lastblocktype, final boolean biome_shaded) {
|
||||||
int blkdata = ps.getBlockData();
|
int blkdata = ps.getBlockData();
|
||||||
HDTextureMap map = HDTextureMap.getMap(blkid, blkdata);
|
HDTextureMap map = HDTextureMap.getMap(blkid, blkdata, ps.getBlockRenderData());
|
||||||
BlockStep laststep = ps.getLastBlockStep();
|
BlockStep laststep = ps.getLastBlockStep();
|
||||||
int textid = map.faces[laststep.ordinal()]; /* Get index of texture source */
|
int textid = map.faces[laststep.ordinal()]; /* Get index of texture source */
|
||||||
if(textid < 0) {
|
if(textid < 0) {
|
||||||
|
@ -280,35 +280,35 @@ block:id=52,allfaces=65,transparency=TRANSPARENT
|
|||||||
# Wooden stairs
|
# Wooden stairs
|
||||||
block:id=53,allsides=4,topbottom=4004,transparency=SEMITRANSPARENT
|
block:id=53,allsides=4,topbottom=4004,transparency=SEMITRANSPARENT
|
||||||
# Chest - single, facing west
|
# Chest - single, facing west
|
||||||
block:id=54,data=0,topbottom=25,south=26,north=26,east=26,west=27
|
block:id=54,data=0,topbottom=25,south=26,north=26,east=26,west=27,userenderdata=true
|
||||||
# Chest - single, facing south
|
# Chest - single, facing south
|
||||||
block:id=54,data=1,topbottom=25,south=27,north=26,east=26,west=26
|
block:id=54,data=1,topbottom=25,south=27,north=26,east=26,west=26,userenderdata=true
|
||||||
# Chest - single, facing east
|
# Chest - single, facing east
|
||||||
block:id=54,data=2,topbottom=25,south=26,north=26,east=27,west=26
|
block:id=54,data=2,topbottom=25,south=26,north=26,east=27,west=26,userenderdata=true
|
||||||
# Chest - single, facing north
|
# Chest - single, facing north
|
||||||
block:id=54,data=3,topbottom=25,south=26,north=27,east=26,west=26
|
block:id=54,data=3,topbottom=25,south=26,north=27,east=26,west=26,userenderdata=true
|
||||||
# Chest - left side of double, facing west
|
# Chest - left side of double, facing west
|
||||||
block:id=54,data=4,topbottom=25,south=26,north=26,east=58,west=41
|
block:id=54,data=4,topbottom=25,south=26,north=26,east=58,west=41,userenderdata=true
|
||||||
# Chest - left side of double, facing south
|
# Chest - left side of double, facing south
|
||||||
block:id=54,data=5,topbottom=25,south=41,north=58,east=26,west=26
|
block:id=54,data=5,topbottom=25,south=41,north=58,east=26,west=26,userenderdata=true
|
||||||
# Chest - left side of double, facing east
|
# Chest - left side of double, facing east
|
||||||
block:id=54,data=6,topbottom=25,south=26,north=26,east=41,west=58
|
block:id=54,data=6,topbottom=25,south=26,north=26,east=41,west=58,userenderdata=true
|
||||||
# Chest - left side of double, facing north
|
# Chest - left side of double, facing north
|
||||||
block:id=54,data=7,topbottom=25,south=58,north=41,east=26,west=26
|
block:id=54,data=7,topbottom=25,south=58,north=41,east=26,west=26,userenderdata=true
|
||||||
# Chest - right side of double, facing west
|
# Chest - right side of double, facing west
|
||||||
block:id=54,data=8,topbottom=25,south=26,north=26,east=57,west=42
|
block:id=54,data=8,topbottom=25,south=26,north=26,east=57,west=42,userenderdata=true
|
||||||
# Chest - right side of double, facing south
|
# Chest - right side of double, facing south
|
||||||
block:id=54,data=9,topbottom=25,south=42,north=57,east=26,west=26
|
block:id=54,data=9,topbottom=25,south=42,north=57,east=26,west=26,userenderdata=true
|
||||||
# Chest - right side of double, facing east
|
# Chest - right side of double, facing east
|
||||||
block:id=54,data=10,topbottom=25,south=26,north=26,east=42,west=57
|
block:id=54,data=10,topbottom=25,south=26,north=26,east=42,west=57,userenderdata=true
|
||||||
# Chest - right side of double, facing north
|
# Chest - right side of double, facing north
|
||||||
block:id=54,data=11,topbottom=25,south=57,north=42,east=26,west=26
|
block:id=54,data=11,topbottom=25,south=57,north=42,east=26,west=26,userenderdata=true
|
||||||
# Redstone wire (all but NS and EW)
|
# Redstone wire (all but NS and EW)
|
||||||
block:id=55,data=0,data=3,data=4,data=5,data=6,data=7,data=8,data=9,data=10,allfaces=180,transparency=TRANSPARENT
|
block:id=55,data=0,data=3,data=4,data=5,data=6,data=7,data=8,data=9,data=10,allfaces=180,transparency=TRANSPARENT,userenderdata=true
|
||||||
# Redstone wire (EW)
|
# Redstone wire (EW)
|
||||||
block:id=55,data=2,allfaces=181,transparency=TRANSPARENT
|
block:id=55,data=2,allfaces=181,transparency=TRANSPARENT,userenderdata=true
|
||||||
# Redstone wire (NS)
|
# Redstone wire (NS)
|
||||||
block:id=55,data=1,allfaces=4181,transparency=TRANSPARENT
|
block:id=55,data=1,allfaces=4181,transparency=TRANSPARENT,userenderdata=true
|
||||||
# Diamond ore
|
# Diamond ore
|
||||||
block:id=56,allfaces=50
|
block:id=56,allfaces=50
|
||||||
# Diamond block
|
# Diamond block
|
||||||
|
Loading…
Reference in New Issue
Block a user