mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-11-09 20:21:35 +01:00
Detect chest type (double, single) and base orientation
This commit is contained in:
parent
d746102963
commit
1c6ececd62
@ -74,6 +74,13 @@ public class IsoHDPerspective implements HDPerspective {
|
|||||||
private boolean need_biomedata = false;
|
private boolean need_biomedata = false;
|
||||||
private boolean need_rawbiomedata = false;
|
private boolean need_rawbiomedata = false;
|
||||||
|
|
||||||
|
private static final int CHEST_BLKTYPEID = 54;
|
||||||
|
private static final int FENCE_BLKTYPEID = 85;
|
||||||
|
|
||||||
|
private enum ChestData {
|
||||||
|
SINGLE_WEST, SINGLE_SOUTH, SINGLE_EAST, SINGLE_NORTH, LEFT_WEST, LEFT_SOUTH, LEFT_EAST, LEFT_NORTH, RIGHT_WEST, RIGHT_SOUTH, RIGHT_EAST, RIGHT_NORTH
|
||||||
|
};
|
||||||
|
|
||||||
private class OurPerspectiveState implements HDPerspectiveState {
|
private class OurPerspectiveState implements HDPerspectiveState {
|
||||||
int blocktypeid = 0;
|
int blocktypeid = 0;
|
||||||
int blockdata = 0;
|
int blockdata = 0;
|
||||||
@ -124,16 +131,26 @@ public class IsoHDPerspective implements HDPerspective {
|
|||||||
}
|
}
|
||||||
else if(HDTextureMap.getTransparency(lastblocktypeid) != BlockTransparency.SEMITRANSPARENT) {
|
else if(HDTextureMap.getTransparency(lastblocktypeid) != BlockTransparency.SEMITRANSPARENT) {
|
||||||
mapiter.unstepPosition(laststep); /* Back up to block we entered on */
|
mapiter.unstepPosition(laststep); /* Back up to block we entered on */
|
||||||
|
if(mapiter.getY() < 128) {
|
||||||
emitlevel = mapiter.getBlockEmittedLight();
|
emitlevel = mapiter.getBlockEmittedLight();
|
||||||
skylevel = mapiter.getBlockSkyLight();
|
skylevel = mapiter.getBlockSkyLight();
|
||||||
|
} else {
|
||||||
|
emitlevel = 0;
|
||||||
|
skylevel = 15;
|
||||||
|
}
|
||||||
mapiter.stepPosition(laststep);
|
mapiter.stepPosition(laststep);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mapiter.unstepPosition(laststep); /* Back up to block we entered on */
|
mapiter.unstepPosition(laststep); /* Back up to block we entered on */
|
||||||
|
if(mapiter.getY() < 128) {
|
||||||
mapiter.stepPosition(BlockStep.Y_PLUS); /* Look above */
|
mapiter.stepPosition(BlockStep.Y_PLUS); /* Look above */
|
||||||
emitlevel = mapiter.getBlockEmittedLight();
|
emitlevel = mapiter.getBlockEmittedLight();
|
||||||
skylevel = mapiter.getBlockSkyLight();
|
skylevel = mapiter.getBlockSkyLight();
|
||||||
mapiter.stepPosition(BlockStep.Y_MINUS);
|
mapiter.stepPosition(BlockStep.Y_MINUS);
|
||||||
|
} else {
|
||||||
|
emitlevel = 0;
|
||||||
|
skylevel = 15;
|
||||||
|
}
|
||||||
mapiter.stepPosition(laststep);
|
mapiter.stepPosition(laststep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -289,33 +306,45 @@ public class IsoHDPerspective implements HDPerspective {
|
|||||||
}
|
}
|
||||||
return blockdata;
|
return blockdata;
|
||||||
}
|
}
|
||||||
/* Figure out which orientation possibility applies to chest:
|
/**
|
||||||
* bit 1-0: 00=facing west, 01=facing-south, 10=facing-east, 11=facing-north
|
* Generate chest block to drive model selection:
|
||||||
* bit 3-2: 00=single, 01=left half, 10=right half
|
* 0 = single facing west
|
||||||
* truth table:
|
* 1 = single facing south
|
||||||
* N S E W : facing
|
* 2 = single facing east
|
||||||
* - - - - : W
|
* 3 = single facing north
|
||||||
* X - - - : S
|
* 4 = left side facing west
|
||||||
* - X - - : N
|
* 5 = left side facing south
|
||||||
* - - X - : W
|
* 6 = left side facing east
|
||||||
* - - - X : E
|
* 7 = left side facing north
|
||||||
* X - X - : S
|
* 8 = right side facing west
|
||||||
* X - - X : S
|
* 9 = right side facing south
|
||||||
* X - X X : S
|
* 10 = right side facing east
|
||||||
* - X - X : N
|
* 11 = right side facing north
|
||||||
* - X X - : N
|
* @param mapiter
|
||||||
* - X X X : N
|
* @return
|
||||||
* X X X - : W
|
|
||||||
* X X - - : W
|
|
||||||
* - - X X : W
|
|
||||||
* X - - X : S
|
|
||||||
* X X - X : E
|
|
||||||
* X X X X : ?
|
|
||||||
*/
|
*/
|
||||||
private int generateChestBlockData(MapIterator mapiter) {
|
private int generateChestBlockData(MapIterator mapiter) {
|
||||||
int blockdata = 0;
|
ChestData cd = ChestData.SINGLE_WEST; /* Default to single facing west */
|
||||||
|
/* Check adjacent block IDs */
|
||||||
|
int ids[] = { mapiter.getBlockTypeIDAt(BlockStep.Z_PLUS), /* To west */
|
||||||
|
mapiter.getBlockTypeIDAt(BlockStep.X_PLUS), /* To south */
|
||||||
|
mapiter.getBlockTypeIDAt(BlockStep.Z_MINUS), /* To east */
|
||||||
|
mapiter.getBlockTypeIDAt(BlockStep.X_MINUS) }; /* To north */
|
||||||
|
/* First, check if we're a double - see if any adjacent chests */
|
||||||
|
if(ids[0] == CHEST_BLKTYPEID) { /* Another to west - assume we face south */
|
||||||
|
cd = ChestData.RIGHT_SOUTH; /* We're right side */
|
||||||
|
}
|
||||||
|
else if(ids[1] == CHEST_BLKTYPEID) { /* Another to south - assume west facing */
|
||||||
|
cd = ChestData.LEFT_WEST; /* We're left side */
|
||||||
|
}
|
||||||
|
else if(ids[2] == CHEST_BLKTYPEID) { /* Another to east - assume south facing */
|
||||||
|
cd = ChestData.LEFT_SOUTH; /* We're left side */
|
||||||
|
}
|
||||||
|
else if(ids[3] == CHEST_BLKTYPEID) { /* Another to north - assume west facing */
|
||||||
|
cd = ChestData.RIGHT_WEST; /* We're right side */
|
||||||
|
}
|
||||||
|
|
||||||
return blockdata;
|
return cd.ordinal();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Process visit of ray to block
|
* Process visit of ray to block
|
||||||
@ -329,10 +358,10 @@ public class IsoHDPerspective implements HDPerspective {
|
|||||||
}
|
}
|
||||||
else if(nonairhit || (blocktypeid != 0)) {
|
else if(nonairhit || (blocktypeid != 0)) {
|
||||||
blockdata = mapiter.getBlockData();
|
blockdata = mapiter.getBlockData();
|
||||||
if(blocktypeid == 85) { /* Special case for fence - need to fake data so we can render properly */
|
if(blocktypeid == FENCE_BLKTYPEID) { /* Special case for fence - need to fake data so we can render properly */
|
||||||
blockdata = generateFenceBlockData(mapiter);
|
blockdata = generateFenceBlockData(mapiter);
|
||||||
}
|
}
|
||||||
else if(blocktypeid == 54) { /* Special case for chest - need to fake data so we can render */
|
else if(blocktypeid == CHEST_BLKTYPEID) { /* Special case for chest - need to fake data so we can render */
|
||||||
blockdata = generateChestBlockData(mapiter);
|
blockdata = generateChestBlockData(mapiter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,7 +189,7 @@ public class NewMapChunkCache implements MapChunkCache {
|
|||||||
if(y > this.y)
|
if(y > this.y)
|
||||||
laststep = BlockStep.Y_PLUS;
|
laststep = BlockStep.Y_PLUS;
|
||||||
else
|
else
|
||||||
laststep = BlockStep.Y_PLUS;
|
laststep = BlockStep.Y_MINUS;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
typeid = -1;
|
typeid = -1;
|
||||||
blkdata = -1;
|
blkdata = -1;
|
||||||
|
26
texture.txt
26
texture.txt
@ -231,8 +231,30 @@ block:id=51,allsides=129,top=162,transparency=TRANSPARENT
|
|||||||
block:id=52,allfaces=65,transparency=TRANSPARENT
|
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 - TODO: get entity data so we can see orientation
|
# Chest - single, facing west
|
||||||
block:id=54,top=25,south=27,north=27,east=26,west=26
|
block:id=54,data=0,topbottom=25,south=26,north=26,east=26,west=27
|
||||||
|
# Chest - single, facing south
|
||||||
|
block:id=54,data=1,topbottom=25,south=27,north=26,east=26,west=26
|
||||||
|
# Chest - single, facing east
|
||||||
|
block:id=54,data=2,topbottom=25,south=26,north=26,east=27,west=26
|
||||||
|
# Chest - single, facing north
|
||||||
|
block:id=54,data=3,topbottom=25,south=26,north=27,east=26,west=26
|
||||||
|
# Chest - left side of double, facing west
|
||||||
|
block:id=54,data=4,topbottom=25,south=26,north=26,east=58,west=41
|
||||||
|
# Chest - left side of double, facing south
|
||||||
|
block:id=54,data=5,topbottom=25,south=41,north=58,east=26,west=26
|
||||||
|
# Chest - left side of double, facing east
|
||||||
|
block:id=54,data=6,topbottom=25,south=26,north=26,east=41,west=58
|
||||||
|
# Chest - left side of double, facing north
|
||||||
|
block:id=54,data=7,topbottom=25,south=58,north=41,east=26,west=26
|
||||||
|
# Chest - right side of double, facing west
|
||||||
|
block:id=54,data=8,topbottom=25,south=26,north=26,east=57,west=42
|
||||||
|
# Chest - right side of double, facing south
|
||||||
|
block:id=54,data=9,topbottom=25,south=42,north=57,east=26,west=26
|
||||||
|
# Chest - right side of double, facing east
|
||||||
|
block:id=54,data=10,topbottom=25,south=26,north=26,east=42,west=57
|
||||||
|
# Chest - right side of double, facing north
|
||||||
|
block:id=54,data=11,topbottom=25,south=57,north=42,east=26,west=26
|
||||||
# Redstone wire (model handling shape - use red wool for color)
|
# Redstone wire (model handling shape - use red wool for color)
|
||||||
block:id=55,allfaces=129,transparency=TRANSPARENT
|
block:id=55,allfaces=129,transparency=TRANSPARENT
|
||||||
# Diamond ore
|
# Diamond ore
|
||||||
|
Loading…
Reference in New Issue
Block a user