From 0a17eb060a0ac4e8f4e840b066e6e17ff4d44420 Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Sun, 9 Sep 2018 18:49:57 -0500 Subject: [PATCH] Fix 1.13.x chest rendering models --- .../dynmap/hdmap/renderer/ChestRenderer.java | 6 ++-- .../hdmap/renderer/ChestStateRenderer.java | 34 +++++++++++++++++++ DynmapCore/src/main/resources/models_1.txt | 8 ++--- 3 files changed, 41 insertions(+), 7 deletions(-) create mode 100644 DynmapCore/src/main/java/org/dynmap/hdmap/renderer/ChestStateRenderer.java diff --git a/DynmapCore/src/main/java/org/dynmap/hdmap/renderer/ChestRenderer.java b/DynmapCore/src/main/java/org/dynmap/hdmap/renderer/ChestRenderer.java index b1b0ddcf..57aaf909 100644 --- a/DynmapCore/src/main/java/org/dynmap/hdmap/renderer/ChestRenderer.java +++ b/DynmapCore/src/main/java/org/dynmap/hdmap/renderer/ChestRenderer.java @@ -14,11 +14,11 @@ import org.dynmap.renderer.RenderPatchFactory; * Simple renderer for handling single and double chests */ public class ChestRenderer extends CustomRenderer { - private enum ChestData { + protected 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 }; // Models, indexed by ChestData.ordinal() - private RenderPatch[][] models = new RenderPatch[ChestData.values().length][]; + protected RenderPatch[][] models = new RenderPatch[ChestData.values().length][]; private static final double OFF1 = 1.0 / 16.0; private static final double OFF14 = 14.0 / 16.0; @@ -28,7 +28,7 @@ public class ChestRenderer extends CustomRenderer { private static final int[] LEFT_PATCHES = { 14, 6, 10, 11, 12, 8 }; private static final int[] RIGHT_PATCHES = { 15, 7, 10, 11, 13, 9 }; - private boolean double_chest = false; + protected boolean double_chest = false; @Override public boolean initializeRenderer(RenderPatchFactory rpf, String blkname, BitSet blockdatamask, Map custparm) { if(!super.initializeRenderer(rpf, blkname, blockdatamask, custparm)) diff --git a/DynmapCore/src/main/java/org/dynmap/hdmap/renderer/ChestStateRenderer.java b/DynmapCore/src/main/java/org/dynmap/hdmap/renderer/ChestStateRenderer.java new file mode 100644 index 00000000..639bc7dc --- /dev/null +++ b/DynmapCore/src/main/java/org/dynmap/hdmap/renderer/ChestStateRenderer.java @@ -0,0 +1,34 @@ +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.DynmapBlockState; +import org.dynmap.renderer.MapDataContext; +import org.dynmap.renderer.RenderPatch; +import org.dynmap.renderer.RenderPatchFactory; + +/** + * Simple renderer for handling single and double chests (1.13+) + */ +public class ChestStateRenderer extends ChestRenderer { + protected 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 ChestData[] byIndex = { + ChestData.SINGLE_NORTH, ChestData.RIGHT_NORTH, ChestData.LEFT_NORTH, + ChestData.SINGLE_SOUTH, ChestData.RIGHT_SOUTH, ChestData.LEFT_SOUTH, + ChestData.SINGLE_WEST, ChestData.RIGHT_WEST, ChestData.LEFT_WEST, + ChestData.SINGLE_EAST, ChestData.RIGHT_EAST , ChestData.LEFT_EAST }; + @Override + public RenderPatch[] getRenderPatchList(MapDataContext ctx) { + int idx = ctx.getBlockType().stateIndex / 2; // Ignore waterlogged for model + if (!double_chest) { // If single only, skip to 3x index of state + idx = idx * 3; + } + return models[byIndex[idx].ordinal()]; + } +} diff --git a/DynmapCore/src/main/resources/models_1.txt b/DynmapCore/src/main/resources/models_1.txt index 1dd2c1c3..f1401787 100644 --- a/DynmapCore/src/main/resources/models_1.txt +++ b/DynmapCore/src/main/resources/models_1.txt @@ -947,9 +947,9 @@ layer:3,4 ******** -******- --****-- -# Chest - single, facing west -# Trap Chest - single, facing west -customblock:id=chest,id=trapped_chest,class=org.dynmap.hdmap.renderer.ChestRenderer +# Chest - single or double +# Trap Chest - single or double +customblock:id=chest,id=trapped_chest,class=org.dynmap.hdmap.renderer.ChestStateRenderer # Cake Block block:id=cake,scale=16 @@ -989,7 +989,7 @@ patchblock:id=tripwire_hook,data=3,data=7,data=11,data=15 patchrotate:id=tripwire_hook,data=0,rot=270 # Ender Chest - facing south -customblock:id=ender_chest,class=org.dynmap.hdmap.renderer.ChestRenderer,doublechest=false +customblock:id=ender_chest,class=org.dynmap.hdmap.renderer.ChestStateRenderer,doublechest=false # Beacon patchblock:id=beacon,patch0=BeaconGlassSide,patch1=BeaconGlassSide@90,patch2=BeaconGlassSide@180,patch3=BeaconGlassSide@270,patch4=BeaconGlassTop,patch5=BeaconGlassBottom,patch6=BeaconObsidianSide,patch7=BeaconObsidianSide@90,patch8=BeaconObsidianSide@180,patch9=BeaconObsidianSide@270,patch10=BeaconObsidianTop,patch11=BeaconLightSide,patch12=BeaconLightSide@90,patch13=BeaconLightSide@180,,patch14=BeaconLightSide@270,patch15=BeaconLightTop