From 4be9ccb1b27c7295f6f2155cc3722990fde0a4c3 Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Sat, 23 Jul 2011 00:49:09 -0500 Subject: [PATCH] Add single chest orientation calculation --- .../org/dynmap/hdmap/IsoHDPerspective.java | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/dynmap/hdmap/IsoHDPerspective.java b/src/main/java/org/dynmap/hdmap/IsoHDPerspective.java index 1f141966..c52d9cda 100644 --- a/src/main/java/org/dynmap/hdmap/IsoHDPerspective.java +++ b/src/main/java/org/dynmap/hdmap/IsoHDPerspective.java @@ -80,6 +80,14 @@ public class IsoHDPerspective implements HDPerspective { 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 }; + + /* Orientation lookup for single chest - index bits: occupied blocks NESW */ + private static final ChestData[] SINGLE_LOOKUP = { + ChestData.SINGLE_WEST, ChestData.SINGLE_EAST, ChestData.SINGLE_NORTH, ChestData.SINGLE_NORTH, + ChestData.SINGLE_WEST, ChestData.SINGLE_WEST, ChestData.SINGLE_NORTH, ChestData.SINGLE_NORTH, + ChestData.SINGLE_SOUTH, ChestData.SINGLE_SOUTH, ChestData.SINGLE_WEST, ChestData.SINGLE_EAST, + ChestData.SINGLE_SOUTH, ChestData.SINGLE_SOUTH, ChestData.SINGLE_WEST, ChestData.SINGLE_EAST + }; private class OurPerspectiveState implements HDPerspectiveState { int blocktypeid = 0; @@ -289,19 +297,19 @@ public class IsoHDPerspective implements HDPerspective { private int generateFenceBlockData(MapIterator mapiter) { int blockdata = 0; /* Check north */ - if(mapiter.getBlockTypeIDAt(BlockStep.X_MINUS) == 85) { /* Fence? */ + if(mapiter.getBlockTypeIDAt(BlockStep.X_MINUS) == FENCE_BLKTYPEID) { /* Fence? */ blockdata |= 1; } /* Look east */ - if(mapiter.getBlockTypeIDAt(BlockStep.Z_MINUS) == 85) { /* Fence? */ + if(mapiter.getBlockTypeIDAt(BlockStep.Z_MINUS) == FENCE_BLKTYPEID) { /* Fence? */ blockdata |= 2; } /* Look south */ - if(mapiter.getBlockTypeIDAt(BlockStep.X_PLUS) == 85) { /* Fence? */ + if(mapiter.getBlockTypeIDAt(BlockStep.X_PLUS) == FENCE_BLKTYPEID) { /* Fence? */ blockdata |= 4; } /* Look west */ - if(mapiter.getBlockTypeIDAt(BlockStep.Z_PLUS) == 85) { /* Fence? */ + if(mapiter.getBlockTypeIDAt(BlockStep.Z_PLUS) == FENCE_BLKTYPEID) { /* Fence? */ blockdata |= 8; } return blockdata; @@ -343,6 +351,15 @@ public class IsoHDPerspective implements HDPerspective { else if(ids[3] == CHEST_BLKTYPEID) { /* Another to north - assume west facing */ cd = ChestData.RIGHT_WEST; /* We're right side */ } + else { /* Else, single - build index into lookup table */ + int idx = 0; + for(int i = 0; i < ids.length; i++) { + if((ids[i] != 0) && (HDTextureMap.getTransparency(ids[i]) != BlockTransparency.TRANSPARENT)) { + idx |= (1<