diff --git a/DynmapCore/src/main/java/org/dynmap/hdmap/renderer/DoorRenderer.java b/DynmapCore/src/main/java/org/dynmap/hdmap/renderer/DoorRenderer.java index c771c079..234cb1bf 100644 --- a/DynmapCore/src/main/java/org/dynmap/hdmap/renderer/DoorRenderer.java +++ b/DynmapCore/src/main/java/org/dynmap/hdmap/renderer/DoorRenderer.java @@ -18,7 +18,7 @@ public class DoorRenderer extends CustomRenderer { public static final int TXT_BOTTOM = 1; // Indexed by combined meta - private RenderPatch[][] models = new RenderPatch[32][]; + protected RenderPatch[][] models = new RenderPatch[32][]; @Override public boolean initializeRenderer(RenderPatchFactory rpf, String blkname, BitSet blockdatamask, Map custparm) { diff --git a/DynmapCore/src/main/java/org/dynmap/hdmap/renderer/DoorStateRenderer.java b/DynmapCore/src/main/java/org/dynmap/hdmap/renderer/DoorStateRenderer.java new file mode 100644 index 00000000..8a5ae848 --- /dev/null +++ b/DynmapCore/src/main/java/org/dynmap/hdmap/renderer/DoorStateRenderer.java @@ -0,0 +1,34 @@ +package org.dynmap.hdmap.renderer; + +import org.dynmap.renderer.MapDataContext; +import org.dynmap.renderer.RenderPatch; + +/** + * Standard door renderer : two textures (top, bottom) + */ +public class DoorStateRenderer extends DoorRenderer { + @Override + public RenderPatch[] getRenderPatchList(MapDataContext ctx) { + int idx = ctx.getBlockType().stateIndex; // Get our state index + // Index: (idx%2)=powered/unpowered, (idx/2)%2=open/closed, (idx/4)%2=left/right, (idx/8)%2=upper/lower, (idx/16)%4=n/s/w/e + int midx = 0; + midx |= ((idx & 0x8) == 0) ? 8 : 0; // If upper half + midx |= ((idx & 0x2) == 0) ? 4 : 0; // If open + midx |= ((idx & 0x4) == 0) ? 0 : 16; // If left hinge + switch ((idx >> 4) & 0x3) { + case 0: // N + midx += 3; + break; + case 1: // S + midx += 1; + break; + case 2: // W + midx += 2; + break; + case 3: // E + midx += 0; + break; + } + return models[midx]; + } +} diff --git a/DynmapCore/src/main/resources/models_1.txt b/DynmapCore/src/main/resources/models_1.txt index 5c9e17ac..678ee16b 100644 --- a/DynmapCore/src/main/resources/models_1.txt +++ b/DynmapCore/src/main/resources/models_1.txt @@ -505,7 +505,7 @@ rotate:id=white_bed,data=0,rot=270 # Oak door # Iron Door -customblock:id=oak_door,id=iron_door,class=org.dynmap.hdmap.renderer.DoorRenderer +customblock:id=oak_door,id=iron_door,class=org.dynmap.hdmap.renderer.DoorStateRenderer # Wall lever, facing south patchblock:id=lever,data=1,patch0=WLeverBase1@270,patch1=WLeverBase2@270,patch2=WLeverBase3@270,patch3=WLeverBase4@270,patch4=WLeverBase5@270,patch5=WLeverSide1@270,patch6=WLeverSide2@270,patch7=WLeverSide3@270,patch8=WLeverSide4@270 @@ -1259,7 +1259,7 @@ customblock:id=acacia_fence,class=org.dynmap.hdmap.renderer.FenceWallBlockStateR # Wooden Door Block (Jungle) # Wooden Door Block (Acacia) # Wooden Door Block (Dark Oak) -customblock:id=spruce_door,id=birch_door,id=jungle_door,id=acacia_door,id=dark_oak_door,class=org.dynmap.hdmap.renderer.DoorRenderer +customblock:id=spruce_door,id=birch_door,id=jungle_door,id=acacia_door,id=dark_oak_door,class=org.dynmap.hdmap.renderer.DoorStateRenderer # End rod #block:id=end_rod,patch0=0:end_rod,transparency=TRANSPARENT