Skip to content

Commit 98a9fd6

Browse files
committed
Add 1.13 specific fence/wall renderer
1 parent 8c7d1f6 commit 98a9fd6

4 files changed

Lines changed: 173 additions & 10 deletions

File tree

DynmapCore/src/main/java/org/dynmap/hdmap/TexturePack.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1694,7 +1694,7 @@ public static void loadTextureMapping(DynmapCore core, ConfigurationNode config)
16941694
if (blk.isAir()) continue;
16951695
HDBlockStateTextureMap tm = HDBlockStateTextureMap.getByBlockState(blk);
16961696
if (tm == HDBlockStateTextureMap.BLANK) {
1697-
Log.severe("Block " + blk + " - no texture mapping");
1697+
Log.verboseinfo("Block " + blk + " - no texture mapping");
16981698
}
16991699
int cnt = HDBlockModels.getNeededTextureCount(blk);
17001700
if(cnt > tm.faces.length){
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
package org.dynmap.hdmap.renderer;
2+
3+
import java.util.ArrayList;
4+
import java.util.BitSet;
5+
import java.util.List;
6+
import java.util.Map;
7+
8+
import org.dynmap.hdmap.HDBlockStateTextureMap;
9+
import org.dynmap.hdmap.TexturePack.BlockTransparency;
10+
import org.dynmap.renderer.CustomRenderer;
11+
import org.dynmap.renderer.DynmapBlockState;
12+
import org.dynmap.renderer.MapDataContext;
13+
import org.dynmap.renderer.RenderPatch;
14+
import org.dynmap.renderer.RenderPatchFactory;
15+
16+
public class FenceWallBlockStateRenderer extends CustomRenderer {
17+
private static final int TEXTURE_SIDES = 0;
18+
private static final int TEXTURE_TOP = 1;
19+
private static final int TEXTURE_BOTTOM = 2;
20+
private boolean check_yplus;
21+
22+
private static final int SIDE_XP = 0x1; // East
23+
private static final int SIDE_XN = 0x2; // West
24+
private static final int SIDE_X = SIDE_XN | SIDE_XP;
25+
private static final int SIDE_ZP = 0x4; // South
26+
private static final int SIDE_ZN = 0x8; // North
27+
private static final int SIDE_Z = SIDE_ZN | SIDE_ZP;
28+
private static final int SIDE_YP = 0x10; // Up
29+
30+
// Meshes, indexed by connection combination (bit 0=X+, bit 1=X-, bit 2=Z+, bit 3=Z-, bit 4=Y+)
31+
private RenderPatch[][] meshes = new RenderPatch[32][];
32+
33+
@Override
34+
public boolean initializeRenderer(RenderPatchFactory rpf, String blkname, BitSet blockdatamask, Map<String,String> custparm) {
35+
if(!super.initializeRenderer(rpf, blkname, blockdatamask, custparm))
36+
return false;
37+
/* Build models, based on type of fence/wall we're set to be */
38+
String type = custparm.get("type");
39+
if((type != null) && (type.equals("wall"))) {
40+
buildWallMeshes(rpf);
41+
check_yplus = true;
42+
}
43+
else {
44+
buildFenceMeshes(rpf);
45+
}
46+
return true;
47+
}
48+
49+
@Override
50+
public int getMaximumTextureCount() {
51+
return 3;
52+
}
53+
54+
private static final int[] patchlist = { TEXTURE_BOTTOM, TEXTURE_TOP, TEXTURE_SIDES, TEXTURE_SIDES, TEXTURE_SIDES, TEXTURE_SIDES };
55+
56+
private void addBox(RenderPatchFactory rpf, List<RenderPatch> list, double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) {
57+
addBox(rpf, list, xmin, xmax, ymin, ymax, zmin, zmax, patchlist);
58+
}
59+
60+
private void buildFenceMeshes(RenderPatchFactory rpf) {
61+
ArrayList<RenderPatch> list = new ArrayList<RenderPatch>();
62+
for(int dat = 0; dat < 16; dat++) {
63+
/* Add center post */
64+
addBox(rpf, list, 0.375, 0.625, 0.0, 1.0, 0.375, 0.625);
65+
switch(dat & SIDE_X) {
66+
case SIDE_XP: // Just X+
67+
addBox(rpf, list, 0.625, 1.0, 0.375, 0.5625, 0.4375, 0.5625);
68+
addBox(rpf, list, 0.625, 1.0, 0.75, 0.9275, 0.4375, 0.5625);
69+
break;
70+
case SIDE_XN: // Just X-
71+
addBox(rpf, list, 0.0, 0.375, 0.375, 0.5625, 0.4375, 0.5625);
72+
addBox(rpf, list, 0.0, 0.375, 0.75, 0.9275, 0.4375, 0.5625);
73+
break;
74+
case SIDE_X: // X- and X+
75+
addBox(rpf, list, 0.0, 1.0, 0.375, 0.5625, 0.4375, 0.5625);
76+
addBox(rpf, list, 0.0, 1.0, 0.75, 0.9275, 0.4375, 0.5625);
77+
break;
78+
}
79+
switch(dat & SIDE_Z) {
80+
case SIDE_ZP: // Just Z+
81+
addBox(rpf, list, 0.4375, 0.5625, 0.375, 0.5625, 0.625, 1.0);
82+
addBox(rpf, list, 0.4375, 0.5625, 0.75, 0.9275, 0.625, 1.0);
83+
break;
84+
case SIDE_ZN: // Just Z-
85+
addBox(rpf, list, 0.4375, 0.5625, 0.375, 0.5625, 0.0, 0.375);
86+
addBox(rpf, list, 0.4375, 0.5625, 0.75, 0.9275, 0.0, 0.375);
87+
break;
88+
case SIDE_Z: // Z- and Z+
89+
addBox(rpf, list, 0.4375, 0.5625, 0.375, 0.5625, 0.0, 1.0);
90+
addBox(rpf, list, 0.4375, 0.5625, 0.75, 0.9275, 0.0, 1.0);
91+
break;
92+
}
93+
meshes[dat] = list.toArray(new RenderPatch[list.size()]);
94+
list.clear();
95+
}
96+
}
97+
98+
private void buildWallMeshes(RenderPatchFactory rpf) {
99+
ArrayList<RenderPatch> list = new ArrayList<RenderPatch>();
100+
for(int dat = 0; dat < 32; dat++) {
101+
boolean need_post = ((dat & 0xF) == 0) || ((dat & 0x10) == 0x10);
102+
switch(dat & SIDE_X) {
103+
case SIDE_XP: // Just X+
104+
addBox(rpf, list, 0.75, 1.0, 0.0, 0.8125, 0.3125, 0.6875);
105+
need_post = true;
106+
break;
107+
case SIDE_XN: // Just X-
108+
addBox(rpf, list, 0.0, 0.25, 0.0, 0.8125, 0.3125, 0.6875);
109+
need_post = true;
110+
break;
111+
case SIDE_X: // X- and X+
112+
addBox(rpf, list, 0.0, 1.0, 0.0, 0.8125, 0.3125, 0.6875);
113+
break;
114+
}
115+
switch(dat & SIDE_Z) {
116+
case SIDE_ZP: // Just Z+
117+
addBox(rpf, list, 0.3125, 0.6875, 0.0, 0.8125, 0.75, 1.0);
118+
need_post = true;
119+
break;
120+
case SIDE_ZN: // Just Z-
121+
addBox(rpf, list, 0.3125, 0.6875, 0.0, 0.8125, 0.0, 0.25);
122+
need_post = true;
123+
break;
124+
case SIDE_Z: // Z- and Z+
125+
addBox(rpf, list, 0.3125, 0.6875, 0.0, 0.8125, 0.0, 1.0);
126+
break;
127+
}
128+
if(need_post) {
129+
addBox(rpf, list, 0.25, 0.75, 0.0, 1.0, 0.25, 0.75);
130+
}
131+
meshes[dat] = list.toArray(new RenderPatch[list.size()]);
132+
list.clear();
133+
}
134+
}
135+
136+
private static int[][] sides = {
137+
{ 1, 0, 0, SIDE_XP },
138+
{ -1, 0, 0, SIDE_XN },
139+
{ 0, 0, 1, SIDE_ZP },
140+
{ 0, 0, -1, SIDE_ZN }
141+
};
142+
143+
@Override
144+
public RenderPatch[] getRenderPatchList(MapDataContext ctx) {
145+
int idx = ctx.getBlockType().stateIndex;
146+
int off = 0;
147+
if(check_yplus) { // Wall?
148+
if ((idx & 0x20) == 0) off += SIDE_XP; // East connected
149+
if ((idx & 0x10) == 0) off += SIDE_ZN; // North connected
150+
if ((idx & 0x08) == 0) off += SIDE_ZP; // South connected
151+
if ((idx & 0x04) == 0) off += SIDE_YP; // Up connected
152+
if ((idx & 0x01) == 0) off += SIDE_XN; // West connected
153+
}
154+
else { // Fence
155+
if ((idx & 0x10) == 0) off += SIDE_XP; // East connected
156+
if ((idx & 0x08) == 0) off += SIDE_ZN; // North connected
157+
if ((idx & 0x04) == 0) off += SIDE_ZP; // South connected
158+
if ((idx & 0x01) == 0) off += SIDE_XN; // West connected
159+
}
160+
return meshes[off];
161+
}
162+
}

DynmapCore/src/main/resources/models_1.txt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ ignore-updates:id=redstone_wall_torch,id=redstone_torch
242242
# Acacia fence
243243
# Dark oak fence
244244
# Nether brick fence
245-
customblock:id=oak_fence,id=spruce_fence,id=birch_fence,id=jungle_fence,id=acacia_fence,id=dark_oak_fence,id=nether_brick_fence,class=org.dynmap.hdmap.renderer.FenceWallBlockRenderer,type=fence,link0=107
245+
customblock:id=oak_fence,id=spruce_fence,id=birch_fence,id=jungle_fence,id=acacia_fence,id=dark_oak_fence,id=nether_brick_fence,class=org.dynmap.hdmap.renderer.FenceWallBlockStateRenderer,type=fence
246246

247247
# Stone pressure plate
248248
# Oak pressure plate
@@ -1028,7 +1028,8 @@ customblock:id=ender_chest,class=org.dynmap.hdmap.renderer.ChestRenderer,doublec
10281028
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
10291029

10301030
# Cobblestone wall
1031-
customblock:id=cobblestone_wall,class=org.dynmap.hdmap.renderer.FenceWallBlockRenderer,type=wall,link0=107
1031+
# Mossy cobblestone wall
1032+
customblock:id=cobblestone_wall,id=mossy_cobblestone_wall,class=org.dynmap.hdmap.renderer.FenceWallBlockStateRenderer,type=wall
10321033

10331034
# Flower pot
10341035
patchblock:id=flower_pot,data=0,patch0=FlowerPotTop,patch1=FlowerPotBottom,patch2=FlowerPotSide,patch3=FlowerPotSide@90,patch4=FlowerPotSide@180,patch5=FlowerPotSide@270,patch6=FlowerPotDirt
@@ -1255,19 +1256,19 @@ customblock:id=dark_oak_fence_gate,class=org.dynmap.hdmap.renderer.FenceGateBloc
12551256
customblock:id=acacia_fence_gate,class=org.dynmap.hdmap.renderer.FenceGateBlockRenderer
12561257

12571258
# Fence (Spruce)
1258-
customblock:id=spruce_fence,class=org.dynmap.hdmap.renderer.FenceWallBlockRenderer,type=fence,link0=183
1259+
customblock:id=spruce_fence,class=org.dynmap.hdmap.renderer.FenceWallBlockStateRenderer,type=fence,link0=183
12591260

12601261
# Fence (Birch)
1261-
customblock:id=birch_fence,class=org.dynmap.hdmap.renderer.FenceWallBlockRenderer,type=fence,link0=184
1262+
customblock:id=birch_fence,class=org.dynmap.hdmap.renderer.FenceWallBlockStateRenderer,type=fence,link0=184
12621263

12631264
# Fence (Jungle)
1264-
customblock:id=jungle_fence,class=org.dynmap.hdmap.renderer.FenceWallBlockRenderer,type=fence,link0=185
1265+
customblock:id=jungle_fence,class=org.dynmap.hdmap.renderer.FenceWallBlockStateRenderer,type=fence,link0=185
12651266

12661267
# Fence (Dark Oak)
1267-
customblock:id=dark_oak_fence,class=org.dynmap.hdmap.renderer.FenceWallBlockRenderer,type=fence,link0=186
1268+
customblock:id=dark_oak_fence,class=org.dynmap.hdmap.renderer.FenceWallBlockStateRenderer,type=fence,link0=186
12681269

12691270
# Fence (Acacia)
1270-
customblock:id=acacia_fence,class=org.dynmap.hdmap.renderer.FenceWallBlockRenderer,type=fence,link0=187
1271+
customblock:id=acacia_fence,class=org.dynmap.hdmap.renderer.FenceWallBlockStateRenderer,type=fence,link0=187
12711272

12721273
# Wooden Door Block (Spruce)
12731274
# Wooden Door Block (Birch)
@@ -1280,7 +1281,7 @@ customblock:id=spruce_door,id=birch_door,id=jungle_door,id=acacia_door,id=dark_o
12801281
#block:id=end_rod,patch0=0:end_rod,transparency=TRANSPARENT
12811282

12821283
# Chorus Plant
1283-
customblock:id=chorus_plant,class=org.dynmap.hdmap.renderer.FenceWallBlockRenderer,type=wall,link0=200
1284+
customblock:id=chorus_plant,class=org.dynmap.hdmap.renderer.FenceWallBlockStateRenderer,type=wall,link0=200
12841285

12851286
# Chorus Flower
12861287
block:id=chorus_flower,scale=8

bukkit/src/main/java/org/dynmap/bukkit/DynmapPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ public void loadExtraBiomes(String mcver) {
763763
}
764764
if (watermult != -1) {
765765
bmap.setWaterColorMultiplier(watermult);
766-
Log.info("Set watercolormult for " + bmap.toString() + " (" + i + ") to " + Integer.toHexString(watermult));
766+
Log.verboseinfo("Set watercolormult for " + bmap.toString() + " (" + i + ") to " + Integer.toHexString(watermult));
767767
}
768768
}
769769
}

0 commit comments

Comments
 (0)