Search in sources :

Example 6 with Fluid

use of net.minecraft.server.v1_16_R3.Fluid in project dynmap by webbukkit.

the class BukkitVersionHelperSpigot116_4 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();
    DynmapBlockState.Builder bld = new DynmapBlockState.Builder();
    // Loop through block data states
    for (int i = 0; i < cnt; i++) {
        IBlockData bd = Block.getByCombinedId(i);
        Block b = bd.getBlock();
        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();
        // getLightBlock
        int lightAtten = b.f(bd, BlockAccessAir.INSTANCE, BlockPosition.ZERO);
        // Log.info("statename=" + bname + "[" + sb + "], lightAtten=" + lightAtten);
        // Fill in base attributes
        bld.setBaseState(lastbs).setStateIndex(idx).setBlockName(bname).setStateName(sb).setMaterial(mat.toString()).setAttenuatesLight(lightAtten);
        if (mat.isSolid()) {
            bld.setSolid();
        }
        if (mat == Material.AIR) {
            bld.setAir();
        }
        if ((bd.getBlock() instanceof BlockRotatable) && (bd.getMaterial() == Material.WOOD)) {
            bld.setLog();
        }
        if (mat == Material.LEAVES) {
            bld.setLeaves();
        }
        if ((!bd.getFluid().isEmpty()) && ((bd.getBlock() instanceof BlockFluids) == false)) {
            // Test if fluid type for block is not empty
            bld.setWaterlogged();
        }
        // Build state
        DynmapBlockState dbs = bld.build();
        dataToState.put(bd, dbs);
        lastBlockState.put(bname, (lastbs == null) ? dbs : lastbs);
        Log.verboseinfo("blk=" + bname + ", idx=" + idx + ", state=" + sb + ", waterlogged=" + dbs.isWaterlogged());
    }
}
Also used : IdentityHashMap(java.util.IdentityHashMap) HashMap(java.util.HashMap) DynmapBlockState(org.dynmap.renderer.DynmapBlockState) Material(net.minecraft.server.v1_16_R3.Material) BukkitMaterial(org.dynmap.bukkit.helper.BukkitMaterial)

Aggregations

Fluid (net.minecraft.server.v1_16_R3.Fluid)2 Material (net.minecraft.server.v1_16_R3.Material)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 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 IBlockData (net.minecraft.server.v1_13_R2.IBlockData)1 Material (net.minecraft.server.v1_13_R2.Material)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 BlockFenceGate (net.minecraft.server.v1_14_R1.BlockFenceGate)1