Search in sources :

Example 31 with DynmapBlockState

use of org.dynmap.renderer.DynmapBlockState in project dynmap by webbukkit.

the class PaneRenderer method getRenderPatchList.

@Override
public RenderPatch[] getRenderPatchList(MapDataContext ctx) {
    /* Build connection map - check each axis */
    int blockdata = 0;
    DynmapBlockState t;
    DynmapBlockState type = ctx.getBlockType();
    /* Check north */
    t = ctx.getBlockTypeAt(-1, 0, 0);
    if ((t == type) || t.is(DynmapBlockState.GLASS_BLOCK) || (HDBlockStateTextureMap.getTransparency(t) == BlockTransparency.OPAQUE)) {
        blockdata |= SIDE_XN;
    }
    /* Look east */
    t = ctx.getBlockTypeAt(0, 0, -1);
    if ((t == type) || t.is(DynmapBlockState.GLASS_BLOCK) || (HDBlockStateTextureMap.getTransparency(t) == BlockTransparency.OPAQUE)) {
        blockdata |= SIDE_ZN;
    }
    /* Look south */
    t = ctx.getBlockTypeAt(1, 0, 0);
    if ((t == type) || t.is(DynmapBlockState.GLASS_BLOCK) || (HDBlockStateTextureMap.getTransparency(t) == BlockTransparency.OPAQUE)) {
        blockdata |= SIDE_XP;
    }
    /* Look west */
    t = ctx.getBlockTypeAt(0, 0, 1);
    if ((t == type) || t.is(DynmapBlockState.GLASS_BLOCK) || (HDBlockStateTextureMap.getTransparency(t) == BlockTransparency.OPAQUE)) {
        blockdata |= SIDE_ZP;
    }
    return meshes[blockdata];
}
Also used : DynmapBlockState(org.dynmap.renderer.DynmapBlockState)

Example 32 with DynmapBlockState

use of org.dynmap.renderer.DynmapBlockState in project dynmap by webbukkit.

the class CTMVertTextureRenderer method getRenderPatchList.

@Override
public RenderPatch[] getRenderPatchList(MapDataContext mapDataCtx) {
    DynmapBlockState bs = mapDataCtx.getBlockType();
    int meta = bs.stateIndex;
    boolean above = false;
    DynmapBlockState id_above = mapDataCtx.getBlockTypeAt(0, 1, 0);
    if (id_above.baseState == blk) {
        /* MIght match */
        int id_meta = id_above.stateIndex;
        if (meta == id_meta) {
            above = true;
        }
    }
    boolean below = false;
    DynmapBlockState id_below = mapDataCtx.getBlockTypeAt(0, -1, 0);
    if (id_below.baseState == blk) {
        /* MIght match */
        int id_meta = id_below.stateIndex;
        if (meta == id_meta) {
            below = true;
        }
    }
    RenderPatch[] mesh;
    if (above) {
        if (below) {
            mesh = this.mesh_both_neighbor;
        } else {
            mesh = this.mesh_above_neighbor;
        }
    } else {
        if (below) {
            mesh = this.mesh_below_neighbor;
        } else {
            mesh = this.mesh_no_neighbor;
        }
    }
    return mesh;
}
Also used : DynmapBlockState(org.dynmap.renderer.DynmapBlockState) RenderPatch(org.dynmap.renderer.RenderPatch)

Example 33 with DynmapBlockState

use of org.dynmap.renderer.DynmapBlockState in project dynmap by webbukkit.

the class ChestRenderer method getRenderPatchList.

@Override
public RenderPatch[] getRenderPatchList(MapDataContext ctx) {
    DynmapBlockState blktype = ctx.getBlockType().baseState;
    if (!double_chest) {
        // Force mismatch - always single
        blktype = DynmapBlockState.AIR;
    }
    int blkdata = blktype.stateIndex;
    /* Get block data */
    ChestData cd = ChestData.SINGLE_NORTH;
    /* Default to single facing north */
    switch(blkdata) {
        /* First, use orientation data */
        case 2:
            /* North */
            if (ctx.getBlockTypeAt(-1, 0, 0).baseState == blktype) {
                cd = ChestData.LEFT_NORTH;
            } else if (ctx.getBlockTypeAt(1, 0, 0).baseState == blktype) {
                cd = ChestData.RIGHT_NORTH;
            } else {
                cd = ChestData.SINGLE_NORTH;
            }
            break;
        case 4:
            /* West */
            if (ctx.getBlockTypeAt(0, 0, -1).baseState == blktype) {
                cd = ChestData.RIGHT_WEST;
            } else if (ctx.getBlockTypeAt(0, 0, 1).baseState == blktype) {
                cd = ChestData.LEFT_WEST;
            } else {
                cd = ChestData.SINGLE_WEST;
            }
            break;
        case 5:
            /* East */
            if (ctx.getBlockTypeAt(0, 0, -1).baseState == blktype) {
                cd = ChestData.LEFT_EAST;
            } else if (ctx.getBlockTypeAt(0, 0, 1).baseState == blktype) {
                cd = ChestData.RIGHT_EAST;
            } else {
                cd = ChestData.SINGLE_EAST;
            }
            break;
        case 3:
        /* South */
        default:
            if (ctx.getBlockTypeAt(-1, 0, 0).baseState == blktype) {
                cd = ChestData.RIGHT_SOUTH;
            } else if (ctx.getBlockTypeAt(1, 0, 0).baseState == blktype) {
                cd = ChestData.LEFT_SOUTH;
            } else {
                cd = ChestData.SINGLE_SOUTH;
            }
            break;
    }
    return models[cd.ordinal()];
}
Also used : DynmapBlockState(org.dynmap.renderer.DynmapBlockState)

Example 34 with DynmapBlockState

use of org.dynmap.renderer.DynmapBlockState in project dynmap by webbukkit.

the class CopyStairBlockRenderer method getBaseRenderPatchList.

private RenderPatch[] getBaseRenderPatchList(MapDataContext ctx) {
    int data = ctx.getBlockType().stateIndex & 0x07;
    /* Get block data */
    /* Check block behind stair */
    DynmapBlockState corner = ctx.getBlockTypeAt(off_x[data], 0, off_z[data]);
    if (stair_ids.get(corner.globalStateIndex)) {
        /* If it is a stair */
        int cornerdat = corner.stateIndex & 0x07;
        if (cornerdat == match1[data]) {
            /* If right orientation */
            /* Make sure we don't have matching stair to side */
            DynmapBlockState side = ctx.getBlockTypeAt(-off_x[cornerdat], 0, -off_z[cornerdat]);
            if ((!stair_ids.get(side.globalStateIndex)) || ((side.stateIndex & 0x07) != data)) {
                return step_1_4_meshes[corner1[data]];
            }
        } else if (cornerdat == match2[data]) {
            /* If other orientation */
            /* Make sure we don't have matching stair to side */
            DynmapBlockState side = ctx.getBlockTypeAt(-off_x[cornerdat], 0, -off_z[cornerdat]);
            if ((!stair_ids.get(side.globalStateIndex)) || ((side.stateIndex & 0x07) != data)) {
                return step_1_4_meshes[corner2[data]];
            }
        }
    }
    /* Check block in front of stair */
    corner = ctx.getBlockTypeAt(-off_x[data], 0, -off_z[data]);
    if (stair_ids.get(corner.globalStateIndex)) {
        /* If it is a stair */
        int cornerdat = corner.stateIndex & 0x07;
        if (cornerdat == match1[data]) {
            /* If right orientation */
            /* Make sure we don't have matching stair to side */
            DynmapBlockState side = ctx.getBlockTypeAt(off_x[cornerdat], 0, off_z[cornerdat]);
            if ((!stair_ids.get(side.globalStateIndex)) || ((side.stateIndex & 0x07) != data)) {
                return step_3_4_meshes[icorner1[data]];
            }
        } else if (cornerdat == match2[data]) {
            /* If other orientation */
            /* Make sure we don't have matching stair to side */
            DynmapBlockState side = ctx.getBlockTypeAt(off_x[cornerdat], 0, off_z[cornerdat]);
            if ((!stair_ids.get(side.globalStateIndex)) || ((side.stateIndex & 0x07) != data)) {
                return step_3_4_meshes[icorner2[data]];
            }
        }
    }
    return stepmeshes[data];
}
Also used : DynmapBlockState(org.dynmap.renderer.DynmapBlockState)

Example 35 with DynmapBlockState

use of org.dynmap.renderer.DynmapBlockState in project dynmap by webbukkit.

the class RailCraftSlabBlockRenderer method setID.

private void setID(String bname) {
    DynmapBlockState bss = DynmapBlockState.getBaseStateByName(bname);
    if (bss.isNotAir()) {
        for (int i = 0; i < bss.getStateCount(); i++) {
            DynmapBlockState bs = bss.getState(i);
            stair_ids.set(bs.globalStateIndex);
        }
    }
}
Also used : DynmapBlockState(org.dynmap.renderer.DynmapBlockState)

Aggregations

DynmapBlockState (org.dynmap.renderer.DynmapBlockState)65 HashMap (java.util.HashMap)13 GsonBuilder (com.google.gson.GsonBuilder)11 ArrayList (java.util.ArrayList)11 IdentityHashMap (java.util.IdentityHashMap)11 Block (net.minecraft.block.Block)11 BlockState (net.minecraft.block.BlockState)10 Block (net.minecraft.world.level.block.Block)8 RequiredArgumentBuilder (com.mojang.brigadier.builder.RequiredArgumentBuilder)7 BitSet (java.util.BitSet)7 FluidBlock (net.minecraft.block.FluidBlock)7 Material (net.minecraft.block.Material)7 Identifier (net.minecraft.util.Identifier)7 JsonParseException (com.google.gson.JsonParseException)6 File (java.io.File)6 CancellationException (java.util.concurrent.CancellationException)6 ExecutionException (java.util.concurrent.ExecutionException)6 RenderPatch (org.dynmap.renderer.RenderPatch)6 CommandSyntaxException (com.mojang.brigadier.exceptions.CommandSyntaxException)5 IOException (java.io.IOException)5