Skip to content

Commit

Permalink
Fix 1.13.x chest rendering models
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeprimm committed Sep 9, 2018
1 parent f058b8b commit 0a17eb0
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
* 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;
Expand All @@ -28,7 +28,7 @@ private enum ChestData {
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<String,String> custparm) {
if(!super.initializeRenderer(rpf, blkname, blockdatamask, custparm))
Expand Down
Original file line number Diff line number Diff line change
@@ -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()];
}
}
8 changes: 4 additions & 4 deletions DynmapCore/src/main/resources/models_1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0a17eb0

Please sign in to comment.