Search in sources :

Example 6 with Fluid

use of net.minecraft.server.v1_13_R2.Fluid 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)

Aggregations

IBlockData (net.minecraft.server.v1_13_R2.IBlockData)2 Material (net.minecraft.server.v1_13_R2.Material)2 Fluid (net.minecraft.server.v1_16_R3.Fluid)2 TagsFluid (net.minecraft.server.v1_16_R3.TagsFluid)2 HashMap (java.util.HashMap)1 IdentityHashMap (java.util.IdentityHashMap)1 Block (net.minecraft.server.v1_13_R2.Block)1 BlockCobbleWall (net.minecraft.server.v1_13_R2.BlockCobbleWall)1 BlockDoor (net.minecraft.server.v1_13_R2.BlockDoor)1 BlockFence (net.minecraft.server.v1_13_R2.BlockFence)1 BlockFenceGate (net.minecraft.server.v1_13_R2.BlockFenceGate)1 BlockFluids (net.minecraft.server.v1_13_R2.BlockFluids)1 BlockLogAbstract (net.minecraft.server.v1_13_R2.BlockLogAbstract)1 BlockMinecartTrackAbstract (net.minecraft.server.v1_13_R2.BlockMinecartTrackAbstract)1 BlockPosition (net.minecraft.server.v1_13_R2.BlockPosition)1 MutableBlockPosition (net.minecraft.server.v1_13_R2.BlockPosition.MutableBlockPosition)1 Fluid (net.minecraft.server.v1_13_R2.Fluid)1 TagsFluid (net.minecraft.server.v1_13_R2.TagsFluid)1 Block (net.minecraft.server.v1_14_R1.Block)1 BlockDoor (net.minecraft.server.v1_14_R1.BlockDoor)1