diff --git a/DynmapCore/src/main/java/org/dynmap/hdmap/renderer/VineStateRenderer.java b/DynmapCore/src/main/java/org/dynmap/hdmap/renderer/VineStateRenderer.java new file mode 100644 index 00000000..a0ef20da --- /dev/null +++ b/DynmapCore/src/main/java/org/dynmap/hdmap/renderer/VineStateRenderer.java @@ -0,0 +1,55 @@ +package org.dynmap.hdmap.renderer; + +import java.util.ArrayList; +import java.util.BitSet; +import java.util.Map; + +import org.dynmap.renderer.CustomRenderer; +import org.dynmap.renderer.MapDataContext; +import org.dynmap.renderer.RenderPatch; +import org.dynmap.renderer.RenderPatchFactory; +import org.dynmap.renderer.RenderPatchFactory.SideVisible; + +/* + * Vine renderer for v1.13+ + */ +public class VineStateRenderer extends CustomRenderer { + + // Meshes, indexed by state index (bit4=east, bit3=north, bit2=south, bit1=up, bit0=west) + protected RenderPatch[][] meshes = new RenderPatch[32][]; + + @Override + public boolean initializeRenderer(RenderPatchFactory rpf, String blkname, BitSet blockdatamask, Map custparm) { + if(!super.initializeRenderer(rpf, blkname, blockdatamask, custparm)) + return false; + buildPatches(rpf); + return true; + } + + private void buildPatches(RenderPatchFactory rpf) { + RenderPatch Top = rpf.getPatch(0.0, 0.95, 0.0, 1.0, 0.95, 0.0, 0.0, 0.95, 1.0, 0.0, 1.0, 0.0, 1.0, SideVisible.BOTH, 0); + RenderPatch West = rpf.getPatch(0.05, 0.0, 0.0, 0.05, 0.0, 1.0, 0.05, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, SideVisible.BOTH, 0); + RenderPatch East = rpf.getPatch(0.95, 0.0, 0.0, 0.95, 0.0, 1.0, 0.95, 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, SideVisible.BOTH, 0); + RenderPatch North = rpf.getPatch(0.0, 0.0, 0.05, 1.0, 0.0, 0.05, 0.0, 1.0, 0.05, 0.0, 1.0, 0.0, 1.0, SideVisible.BOTH, 0); + RenderPatch South = rpf.getPatch(0.0, 0.0, 0.95, 1.0, 0.0, 0.95, 0.0, 1.0, 0.95, 0.0, 1.0, 0.0, 1.0, SideVisible.BOTH, 0); + ArrayList list = new ArrayList(); + for (int i = 0; i < 32; i++) { + list.clear(); + if ((i & 0x10) == 0) list.add(East); + if ((i & 0x08) == 0) list.add(North); + if ((i & 0x04) == 0) list.add(South); + if ((i & 0x02) == 0) list.add(Top); + if ((i & 0x01) == 0) list.add(West); + meshes[i] = list.toArray(new RenderPatch[list.size()]); + } + } + @Override + public int getMaximumTextureCount() { + return 2; + } + + @Override + public RenderPatch[] getRenderPatchList(MapDataContext ctx) { + return meshes[ctx.getBlockType().stateIndex]; + } +} diff --git a/DynmapCore/src/main/resources/models_1.txt b/DynmapCore/src/main/resources/models_1.txt index aa724a64..a76b1c17 100644 --- a/DynmapCore/src/main/resources/models_1.txt +++ b/DynmapCore/src/main/resources/models_1.txt @@ -776,36 +776,9 @@ patchblock:id=sunflower,id=lilac,id=rose_bush,id=peony,id=tall_grass,id=large_fe # Sapling (oak, spruce, birch, jungle, acacia, dark oak) patchblock:id=oak_sapling,id=spruce_sapling,id=birch_sapling,id=jungle_sapling,id=acacia_sapling,id=dark_oak_sapling,patch0=VertX1Z0ToX0Z1,patch1=VertX1Z0ToX0Z1@90 -# Vines - N side of block -patchblock:id=vine,data=2,patch0=VertX0In -# Vines - E side of block -patchblock:id=vine,data=4,patch0=VertX0In@90 -# Vines - S side of block -patchblock:id=vine,data=8,patch0=VertX0In@180 -# Vines - W side of block -patchblock:id=vine,data=1,patch0=VertX0In@270 -# Vines - N+E sides of block -patchblock:id=vine,data=6,patch0=VertX0In,patch1=VertX0In@90 -# Vines - E+S side of block -patchblock:id=vine,data=12,patch0=VertX0In@90,patch1=VertX0In@180 -# Vines - S+W side of block -patchblock:id=vine,data=9,patch0=VertX0In@180,patch1=VertX0In@270 -# Vines - W+N side of block -patchblock:id=vine,data=3,patch0=VertX0In@270,patch1=VertX0In -# Vines - N+S sides of block -patchblock:id=vine,data=10,patch0=VertX0In,patch1=VertX0In@180 -# Vines - E+W side of block -patchblock:id=vine,data=5,patch0=VertX0In@90,patch1=VertX0In@270 -# Vines - N+E+W sides of block -patchblock:id=vine,data=7,patch0=VertX0In@90,patch1=VertX0In@270,patch2=VertX0In -# Vines - N+E+S side of block -patchblock:id=vine,data=14,patch0=VertX0In@180,patch1=VertX0In,patch2=VertX0In@90 -# Vines - E+S+W side of block -patchblock:id=vine,data=13,patch0=VertX0In@270,patch1=VertX0In@90,patch2=VertX0In@180 -# Vines - N+S+W side of block -patchblock:id=vine,data=11,patch0=VertX0In,patch1=VertX0In@180,patch2=VertX0In@270 -# Vines - N+S+E+W sides of block -patchblock:id=vine,data=15,patch0=VertX0In@270,patch1=VertX0In@90,patch2=VertX0In@180,patch3=VertX0In +# Vines +customblock:id=vine,class=org.dynmap.hdmap.renderer.VineStateRenderer + # Oak fence gate customblock:id=oak_fence_gate,class=org.dynmap.hdmap.renderer.FenceGateBlockStateRenderer # Pumpkin stem