Search in sources :

Example 11 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 12 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 13 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)

Example 14 with DynmapBlockState

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

the class StairBlockRenderer 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 15 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)

Aggregations

DynmapBlockState (org.dynmap.renderer.DynmapBlockState)62 HashMap (java.util.HashMap)12 ArrayList (java.util.ArrayList)10 IdentityHashMap (java.util.IdentityHashMap)10 Block (net.minecraft.block.Block)10 GsonBuilder (com.google.gson.GsonBuilder)9 BlockState (net.minecraft.block.BlockState)9 BitSet (java.util.BitSet)7 RequiredArgumentBuilder (com.mojang.brigadier.builder.RequiredArgumentBuilder)6 File (java.io.File)6 FluidBlock (net.minecraft.block.FluidBlock)6 Material (net.minecraft.block.Material)6 Identifier (net.minecraft.util.Identifier)6 Block (net.minecraft.world.level.block.Block)6 RenderPatch (org.dynmap.renderer.RenderPatch)6 JsonParseException (com.google.gson.JsonParseException)5 IOException (java.io.IOException)5 CancellationException (java.util.concurrent.CancellationException)5 ExecutionException (java.util.concurrent.ExecutionException)5 ZipFile (java.util.zip.ZipFile)5