mirror of
https://github.com/webbukkit/dynmap.git
synced 2025-01-11 18:37:40 +01:00
Add 1.13 specific fence/wall renderer
This commit is contained in:
parent
8c7d1f6181
commit
98a9fd6341
@ -1694,7 +1694,7 @@ public class TexturePack {
|
||||
if (blk.isAir()) continue;
|
||||
HDBlockStateTextureMap tm = HDBlockStateTextureMap.getByBlockState(blk);
|
||||
if (tm == HDBlockStateTextureMap.BLANK) {
|
||||
Log.severe("Block " + blk + " - no texture mapping");
|
||||
Log.verboseinfo("Block " + blk + " - no texture mapping");
|
||||
}
|
||||
int cnt = HDBlockModels.getNeededTextureCount(blk);
|
||||
if(cnt > tm.faces.length){
|
||||
|
@ -0,0 +1,162 @@
|
||||
package org.dynmap.hdmap.renderer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.BitSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.dynmap.hdmap.HDBlockStateTextureMap;
|
||||
import org.dynmap.hdmap.TexturePack.BlockTransparency;
|
||||
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;
|
||||
|
||||
public class FenceWallBlockStateRenderer extends CustomRenderer {
|
||||
private static final int TEXTURE_SIDES = 0;
|
||||
private static final int TEXTURE_TOP = 1;
|
||||
private static final int TEXTURE_BOTTOM = 2;
|
||||
private boolean check_yplus;
|
||||
|
||||
private static final int SIDE_XP = 0x1; // East
|
||||
private static final int SIDE_XN = 0x2; // West
|
||||
private static final int SIDE_X = SIDE_XN | SIDE_XP;
|
||||
private static final int SIDE_ZP = 0x4; // South
|
||||
private static final int SIDE_ZN = 0x8; // North
|
||||
private static final int SIDE_Z = SIDE_ZN | SIDE_ZP;
|
||||
private static final int SIDE_YP = 0x10; // Up
|
||||
|
||||
// Meshes, indexed by connection combination (bit 0=X+, bit 1=X-, bit 2=Z+, bit 3=Z-, bit 4=Y+)
|
||||
private RenderPatch[][] meshes = new RenderPatch[32][];
|
||||
|
||||
@Override
|
||||
public boolean initializeRenderer(RenderPatchFactory rpf, String blkname, BitSet blockdatamask, Map<String,String> custparm) {
|
||||
if(!super.initializeRenderer(rpf, blkname, blockdatamask, custparm))
|
||||
return false;
|
||||
/* Build models, based on type of fence/wall we're set to be */
|
||||
String type = custparm.get("type");
|
||||
if((type != null) && (type.equals("wall"))) {
|
||||
buildWallMeshes(rpf);
|
||||
check_yplus = true;
|
||||
}
|
||||
else {
|
||||
buildFenceMeshes(rpf);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumTextureCount() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
private static final int[] patchlist = { TEXTURE_BOTTOM, TEXTURE_TOP, TEXTURE_SIDES, TEXTURE_SIDES, TEXTURE_SIDES, TEXTURE_SIDES };
|
||||
|
||||
private void addBox(RenderPatchFactory rpf, List<RenderPatch> list, double xmin, double xmax, double ymin, double ymax, double zmin, double zmax) {
|
||||
addBox(rpf, list, xmin, xmax, ymin, ymax, zmin, zmax, patchlist);
|
||||
}
|
||||
|
||||
private void buildFenceMeshes(RenderPatchFactory rpf) {
|
||||
ArrayList<RenderPatch> list = new ArrayList<RenderPatch>();
|
||||
for(int dat = 0; dat < 16; dat++) {
|
||||
/* Add center post */
|
||||
addBox(rpf, list, 0.375, 0.625, 0.0, 1.0, 0.375, 0.625);
|
||||
switch(dat & SIDE_X) {
|
||||
case SIDE_XP: // Just X+
|
||||
addBox(rpf, list, 0.625, 1.0, 0.375, 0.5625, 0.4375, 0.5625);
|
||||
addBox(rpf, list, 0.625, 1.0, 0.75, 0.9275, 0.4375, 0.5625);
|
||||
break;
|
||||
case SIDE_XN: // Just X-
|
||||
addBox(rpf, list, 0.0, 0.375, 0.375, 0.5625, 0.4375, 0.5625);
|
||||
addBox(rpf, list, 0.0, 0.375, 0.75, 0.9275, 0.4375, 0.5625);
|
||||
break;
|
||||
case SIDE_X: // X- and X+
|
||||
addBox(rpf, list, 0.0, 1.0, 0.375, 0.5625, 0.4375, 0.5625);
|
||||
addBox(rpf, list, 0.0, 1.0, 0.75, 0.9275, 0.4375, 0.5625);
|
||||
break;
|
||||
}
|
||||
switch(dat & SIDE_Z) {
|
||||
case SIDE_ZP: // Just Z+
|
||||
addBox(rpf, list, 0.4375, 0.5625, 0.375, 0.5625, 0.625, 1.0);
|
||||
addBox(rpf, list, 0.4375, 0.5625, 0.75, 0.9275, 0.625, 1.0);
|
||||
break;
|
||||
case SIDE_ZN: // Just Z-
|
||||
addBox(rpf, list, 0.4375, 0.5625, 0.375, 0.5625, 0.0, 0.375);
|
||||
addBox(rpf, list, 0.4375, 0.5625, 0.75, 0.9275, 0.0, 0.375);
|
||||
break;
|
||||
case SIDE_Z: // Z- and Z+
|
||||
addBox(rpf, list, 0.4375, 0.5625, 0.375, 0.5625, 0.0, 1.0);
|
||||
addBox(rpf, list, 0.4375, 0.5625, 0.75, 0.9275, 0.0, 1.0);
|
||||
break;
|
||||
}
|
||||
meshes[dat] = list.toArray(new RenderPatch[list.size()]);
|
||||
list.clear();
|
||||
}
|
||||
}
|
||||
|
||||
private void buildWallMeshes(RenderPatchFactory rpf) {
|
||||
ArrayList<RenderPatch> list = new ArrayList<RenderPatch>();
|
||||
for(int dat = 0; dat < 32; dat++) {
|
||||
boolean need_post = ((dat & 0xF) == 0) || ((dat & 0x10) == 0x10);
|
||||
switch(dat & SIDE_X) {
|
||||
case SIDE_XP: // Just X+
|
||||
addBox(rpf, list, 0.75, 1.0, 0.0, 0.8125, 0.3125, 0.6875);
|
||||
need_post = true;
|
||||
break;
|
||||
case SIDE_XN: // Just X-
|
||||
addBox(rpf, list, 0.0, 0.25, 0.0, 0.8125, 0.3125, 0.6875);
|
||||
need_post = true;
|
||||
break;
|
||||
case SIDE_X: // X- and X+
|
||||
addBox(rpf, list, 0.0, 1.0, 0.0, 0.8125, 0.3125, 0.6875);
|
||||
break;
|
||||
}
|
||||
switch(dat & SIDE_Z) {
|
||||
case SIDE_ZP: // Just Z+
|
||||
addBox(rpf, list, 0.3125, 0.6875, 0.0, 0.8125, 0.75, 1.0);
|
||||
need_post = true;
|
||||
break;
|
||||
case SIDE_ZN: // Just Z-
|
||||
addBox(rpf, list, 0.3125, 0.6875, 0.0, 0.8125, 0.0, 0.25);
|
||||
need_post = true;
|
||||
break;
|
||||
case SIDE_Z: // Z- and Z+
|
||||
addBox(rpf, list, 0.3125, 0.6875, 0.0, 0.8125, 0.0, 1.0);
|
||||
break;
|
||||
}
|
||||
if(need_post) {
|
||||
addBox(rpf, list, 0.25, 0.75, 0.0, 1.0, 0.25, 0.75);
|
||||
}
|
||||
meshes[dat] = list.toArray(new RenderPatch[list.size()]);
|
||||
list.clear();
|
||||
}
|
||||
}
|
||||
|
||||
private static int[][] sides = {
|
||||
{ 1, 0, 0, SIDE_XP },
|
||||
{ -1, 0, 0, SIDE_XN },
|
||||
{ 0, 0, 1, SIDE_ZP },
|
||||
{ 0, 0, -1, SIDE_ZN }
|
||||
};
|
||||
|
||||
@Override
|
||||
public RenderPatch[] getRenderPatchList(MapDataContext ctx) {
|
||||
int idx = ctx.getBlockType().stateIndex;
|
||||
int off = 0;
|
||||
if(check_yplus) { // Wall?
|
||||
if ((idx & 0x20) == 0) off += SIDE_XP; // East connected
|
||||
if ((idx & 0x10) == 0) off += SIDE_ZN; // North connected
|
||||
if ((idx & 0x08) == 0) off += SIDE_ZP; // South connected
|
||||
if ((idx & 0x04) == 0) off += SIDE_YP; // Up connected
|
||||
if ((idx & 0x01) == 0) off += SIDE_XN; // West connected
|
||||
}
|
||||
else { // Fence
|
||||
if ((idx & 0x10) == 0) off += SIDE_XP; // East connected
|
||||
if ((idx & 0x08) == 0) off += SIDE_ZN; // North connected
|
||||
if ((idx & 0x04) == 0) off += SIDE_ZP; // South connected
|
||||
if ((idx & 0x01) == 0) off += SIDE_XN; // West connected
|
||||
}
|
||||
return meshes[off];
|
||||
}
|
||||
}
|
@ -242,7 +242,7 @@ ignore-updates:id=redstone_wall_torch,id=redstone_torch
|
||||
# Acacia fence
|
||||
# Dark oak fence
|
||||
# Nether brick fence
|
||||
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
|
||||
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
|
||||
|
||||
# Stone pressure plate
|
||||
# Oak pressure plate
|
||||
@ -1028,7 +1028,8 @@ customblock:id=ender_chest,class=org.dynmap.hdmap.renderer.ChestRenderer,doublec
|
||||
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
|
||||
|
||||
# Cobblestone wall
|
||||
customblock:id=cobblestone_wall,class=org.dynmap.hdmap.renderer.FenceWallBlockRenderer,type=wall,link0=107
|
||||
# Mossy cobblestone wall
|
||||
customblock:id=cobblestone_wall,id=mossy_cobblestone_wall,class=org.dynmap.hdmap.renderer.FenceWallBlockStateRenderer,type=wall
|
||||
|
||||
# Flower pot
|
||||
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
|
||||
customblock:id=acacia_fence_gate,class=org.dynmap.hdmap.renderer.FenceGateBlockRenderer
|
||||
|
||||
# Fence (Spruce)
|
||||
customblock:id=spruce_fence,class=org.dynmap.hdmap.renderer.FenceWallBlockRenderer,type=fence,link0=183
|
||||
customblock:id=spruce_fence,class=org.dynmap.hdmap.renderer.FenceWallBlockStateRenderer,type=fence,link0=183
|
||||
|
||||
# Fence (Birch)
|
||||
customblock:id=birch_fence,class=org.dynmap.hdmap.renderer.FenceWallBlockRenderer,type=fence,link0=184
|
||||
customblock:id=birch_fence,class=org.dynmap.hdmap.renderer.FenceWallBlockStateRenderer,type=fence,link0=184
|
||||
|
||||
# Fence (Jungle)
|
||||
customblock:id=jungle_fence,class=org.dynmap.hdmap.renderer.FenceWallBlockRenderer,type=fence,link0=185
|
||||
customblock:id=jungle_fence,class=org.dynmap.hdmap.renderer.FenceWallBlockStateRenderer,type=fence,link0=185
|
||||
|
||||
# Fence (Dark Oak)
|
||||
customblock:id=dark_oak_fence,class=org.dynmap.hdmap.renderer.FenceWallBlockRenderer,type=fence,link0=186
|
||||
customblock:id=dark_oak_fence,class=org.dynmap.hdmap.renderer.FenceWallBlockStateRenderer,type=fence,link0=186
|
||||
|
||||
# Fence (Acacia)
|
||||
customblock:id=acacia_fence,class=org.dynmap.hdmap.renderer.FenceWallBlockRenderer,type=fence,link0=187
|
||||
customblock:id=acacia_fence,class=org.dynmap.hdmap.renderer.FenceWallBlockStateRenderer,type=fence,link0=187
|
||||
|
||||
# Wooden Door Block (Spruce)
|
||||
# Wooden Door Block (Birch)
|
||||
@ -1280,7 +1281,7 @@ customblock:id=spruce_door,id=birch_door,id=jungle_door,id=acacia_door,id=dark_o
|
||||
#block:id=end_rod,patch0=0:end_rod,transparency=TRANSPARENT
|
||||
|
||||
# Chorus Plant
|
||||
customblock:id=chorus_plant,class=org.dynmap.hdmap.renderer.FenceWallBlockRenderer,type=wall,link0=200
|
||||
customblock:id=chorus_plant,class=org.dynmap.hdmap.renderer.FenceWallBlockStateRenderer,type=wall,link0=200
|
||||
|
||||
# Chorus Flower
|
||||
block:id=chorus_flower,scale=8
|
||||
|
@ -763,7 +763,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
}
|
||||
if (watermult != -1) {
|
||||
bmap.setWaterColorMultiplier(watermult);
|
||||
Log.info("Set watercolormult for " + bmap.toString() + " (" + i + ") to " + Integer.toHexString(watermult));
|
||||
Log.verboseinfo("Set watercolormult for " + bmap.toString() + " (" + i + ") to " + Integer.toHexString(watermult));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user