Search in sources :

Example 1 with BlockLogAbstract

use of net.minecraft.server.v1_13_R2.BlockLogAbstract in project dynmap by webbukkit.

the class BukkitVersionHelperSpigot113_2 method initializeBlockStates.

/**
 * Initialize block states (org.dynmap.blockstate.DynmapBlockState)
 */
@Override
public void initializeBlockStates() {
    dataToState = new IdentityHashMap<IBlockData, DynmapBlockState>();
    HashMap<String, DynmapBlockState> lastBlockState = new HashMap<String, DynmapBlockState>();
    int cnt = Block.REGISTRY_ID.a();
    // Loop through block data states
    for (int i = 0; i < cnt; i++) {
        IBlockData bd = Block.getByCombinedId(i);
        String bname = IRegistry.BLOCK.getKey(bd.getBlock()).toString();
        // See if we have seen this one
        DynmapBlockState lastbs = lastBlockState.get(bname);
        int idx = 0;
        if (lastbs != null) {
            // Yes
            // Get number of states so far, since this is next
            idx = lastbs.getStateCount();
        }
        // Build state name
        String sb = "";
        String fname = bd.toString();
        int off1 = fname.indexOf('[');
        if (off1 >= 0) {
            int off2 = fname.indexOf(']');
            sb = fname.substring(off1 + 1, off2);
        }
        Material mat = bd.getMaterial();
        DynmapBlockState bs = new DynmapBlockState(lastbs, idx, bname, sb, mat.toString());
        if ((!bd.s().e()) && ((bd.getBlock() instanceof BlockFluids) == false)) {
            // Test if fluid type for block is not empty
            bs.setWaterlogged();
        }
        if (mat == Material.AIR) {
            bs.setAir();
        }
        if (mat == Material.LEAVES) {
            bs.setLeaves();
        }
        if (bd.getBlock() instanceof BlockLogAbstract) {
            bs.setLog();
        }
        if (mat.isSolid()) {
            bs.setSolid();
        }
        dataToState.put(bd, bs);
        lastBlockState.put(bname, (lastbs == null) ? bs : lastbs);
        Log.verboseinfo(i + ": blk=" + bname + ", idx=" + idx + ", state=" + sb + ", waterlogged=" + bs.isWaterlogged());
    }
}
Also used : IBlockData(net.minecraft.server.v1_13_R2.IBlockData) HashMap(java.util.HashMap) IdentityHashMap(java.util.IdentityHashMap) BlockLogAbstract(net.minecraft.server.v1_13_R2.BlockLogAbstract) DynmapBlockState(org.dynmap.renderer.DynmapBlockState) Material(net.minecraft.server.v1_13_R2.Material) BlockFluids(net.minecraft.server.v1_13_R2.BlockFluids)

Example 2 with BlockLogAbstract

use of net.minecraft.server.v1_13_R2.BlockLogAbstract in project dynmap by webbukkit.

the class BukkitVersionHelperSpigot114_1 method initializeBlockStates.

/**
 * Initialize block states (org.dynmap.blockstate.DynmapBlockState)
 */
@Override
public void initializeBlockStates() {
    dataToState = new IdentityHashMap<IBlockData, DynmapBlockState>();
    HashMap<String, DynmapBlockState> lastBlockState = new HashMap<String, DynmapBlockState>();
    int cnt = Block.REGISTRY_ID.a();
    // Loop through block data states
    for (int i = 0; i < cnt; i++) {
        IBlockData bd = Block.getByCombinedId(i);
        String bname = IRegistry.BLOCK.getKey(bd.getBlock()).toString();
        // See if we have seen this one
        DynmapBlockState lastbs = lastBlockState.get(bname);
        int idx = 0;
        if (lastbs != null) {
            // Yes
            // Get number of states so far, since this is next
            idx = lastbs.getStateCount();
        }
        // Build state name
        String sb = "";
        String fname = bd.toString();
        int off1 = fname.indexOf('[');
        if (off1 >= 0) {
            int off2 = fname.indexOf(']');
            sb = fname.substring(off1 + 1, off2);
        }
        Material mat = bd.getMaterial();
        DynmapBlockState bs = new DynmapBlockState(lastbs, idx, bname, sb, mat.toString());
        if ((!bd.p().isEmpty()) && ((bd.getBlock() instanceof BlockFluids) == false)) {
            // Test if fluid type for block is not empty
            bs.setWaterlogged();
        }
        if (mat == Material.AIR) {
            bs.setAir();
        }
        if (mat == Material.LEAVES) {
            bs.setLeaves();
        }
        if (bd.getBlock() instanceof BlockLogAbstract) {
            bs.setLog();
        }
        if (mat.isSolid()) {
            bs.setSolid();
        }
        dataToState.put(bd, bs);
        lastBlockState.put(bname, (lastbs == null) ? bs : lastbs);
        Log.verboseinfo(i + ": blk=" + bname + ", idx=" + idx + ", state=" + sb + ", waterlogged=" + bs.isWaterlogged());
    }
}
Also used : IBlockData(net.minecraft.server.v1_14_R1.IBlockData) HashMap(java.util.HashMap) IdentityHashMap(java.util.IdentityHashMap) BlockLogAbstract(net.minecraft.server.v1_14_R1.BlockLogAbstract) DynmapBlockState(org.dynmap.renderer.DynmapBlockState) Material(net.minecraft.server.v1_14_R1.Material) BlockFluids(net.minecraft.server.v1_14_R1.BlockFluids)

Aggregations

HashMap (java.util.HashMap)2 IdentityHashMap (java.util.IdentityHashMap)2 DynmapBlockState (org.dynmap.renderer.DynmapBlockState)2 BlockFluids (net.minecraft.server.v1_13_R2.BlockFluids)1 BlockLogAbstract (net.minecraft.server.v1_13_R2.BlockLogAbstract)1 IBlockData (net.minecraft.server.v1_13_R2.IBlockData)1 Material (net.minecraft.server.v1_13_R2.Material)1 BlockFluids (net.minecraft.server.v1_14_R1.BlockFluids)1 BlockLogAbstract (net.minecraft.server.v1_14_R1.BlockLogAbstract)1 IBlockData (net.minecraft.server.v1_14_R1.IBlockData)1 Material (net.minecraft.server.v1_14_R1.Material)1