Search in sources :

Example 81 with Block

use of net.minecraft.server.v1_13_R2.Block 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 82 with Block

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

the class BukkitVersionHelperSpigot113_2 method getBlockNames.

/**
 * Get block short name list
 */
@Override
public String[] getBlockNames() {
    int cnt = Block.REGISTRY_ID.a();
    String[] names = new String[cnt];
    for (int i = 0; i < cnt; i++) {
        IBlockData bd = Block.getByCombinedId(i);
        names[i] = IRegistry.BLOCK.getKey(bd.getBlock()).toString();
        Log.info(i + ": blk=" + names[i] + ", bd=" + bd.toString());
    }
    return names;
}
Also used : IBlockData(net.minecraft.server.v1_13_R2.IBlockData)

Example 83 with Block

use of net.minecraft.server.v1_13_R2.Block in project Denizen by DenizenScript.

the class BlockHelperImpl method ringBell.

@Override
public void ringBell(Bell block) {
    org.bukkit.block.data.type.Bell bellData = (org.bukkit.block.data.type.Bell) block.getBlockData();
    Direction face = Direction.byName(bellData.getFacing().name());
    Direction dir = Direction.NORTH;
    switch(bellData.getAttachment()) {
        case DOUBLE_WALL:
        case SINGLE_WALL:
            switch(face) {
                case NORTH:
                case SOUTH:
                    dir = Direction.EAST;
                    break;
            }
            break;
        case FLOOR:
            dir = face;
            break;
    }
    CraftBlock craftBlock = (CraftBlock) block.getBlock();
    ((BellBlock) Blocks.BELL).attemptToRing(craftBlock.getCraftWorld().getHandle(), craftBlock.getPosition(), dir);
}
Also used : BellBlock(net.minecraft.world.level.block.BellBlock) org.bukkit.block(org.bukkit.block) org.bukkit.craftbukkit.v1_17_R1.block(org.bukkit.craftbukkit.v1_17_R1.block) Direction(net.minecraft.core.Direction)

Example 84 with Block

use of net.minecraft.server.v1_13_R2.Block in project Denizen by DenizenScript.

the class BlockHelperImpl method ringBell.

@Override
public void ringBell(Bell block) {
    org.bukkit.block.data.type.Bell bellData = (org.bukkit.block.data.type.Bell) block.getBlockData();
    Direction face = Direction.byName(bellData.getFacing().name());
    Direction dir = Direction.NORTH;
    switch(bellData.getAttachment()) {
        case DOUBLE_WALL:
        case SINGLE_WALL:
            switch(face) {
                case NORTH:
                case SOUTH:
                    dir = Direction.EAST;
                    break;
            }
            break;
        case FLOOR:
            dir = face;
            break;
    }
    CraftBlock craftBlock = (CraftBlock) block.getBlock();
    ((BellBlock) Blocks.BELL).attemptToRing(craftBlock.getCraftWorld().getHandle(), craftBlock.getPosition(), dir);
}
Also used : BellBlock(net.minecraft.world.level.block.BellBlock) org.bukkit.craftbukkit.v1_18_R2.block(org.bukkit.craftbukkit.v1_18_R2.block) org.bukkit.block(org.bukkit.block) Direction(net.minecraft.core.Direction)

Example 85 with Block

use of net.minecraft.server.v1_13_R2.Block in project MechanicsMain by WeaponMechanics.

the class Block_1_13_R2 method getMultiBlockMaskPacket.

@Override
@NotNull
public List<Object> getMultiBlockMaskPacket(@NotNull List<Block> blocks, @Nullable Material mask, byte data) {
    if (blocks == null || blocks.isEmpty()) {
        throw new IllegalArgumentException("No blocks are being changed!");
    }
    Map<Chunk, List<Block>> sortedBlocks = new HashMap<>();
    for (Block block : blocks) {
        List<Block> list = sortedBlocks.computeIfAbsent(block.getChunk(), chunk -> new ArrayList<>());
        list.add(block);
    }
    List<Object> packets = new ArrayList<>(sortedBlocks.size());
    IBlockData theMask = mask == null ? null : ((CraftBlockData) mask.createBlockData()).getState();
    for (List<Block> entry : sortedBlocks.values()) {
        packets.add(getMultiBlockMaskPacket(entry, theMask));
    }
    return packets;
}
Also used : IBlockData(net.minecraft.server.v1_13_R2.IBlockData) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Block(org.bukkit.block.Block) ArrayList(java.util.ArrayList) List(java.util.List) CraftChunk(org.bukkit.craftbukkit.v1_13_R2.CraftChunk) Chunk(org.bukkit.Chunk) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

Block (net.minecraft.server.v1_12_R1.Block)12 ArrayList (java.util.ArrayList)10 ByteString (com.google.protobuf.ByteString)8 Block (net.minecraft.server.v1_10_R1.Block)8 Block (net.minecraft.server.v1_11_R1.Block)8 BlockPosition (net.minecraft.server.v1_12_R1.BlockPosition)8 Block (net.minecraft.server.v1_8_R3.Block)8 FallingBlock (org.bukkit.entity.FallingBlock)8 HashMap (java.util.HashMap)7 BlockPosition (net.minecraft.server.v1_10_R1.BlockPosition)7 BlockPosition (net.minecraft.server.v1_11_R1.BlockPosition)7 AnnotateImageResponse (com.google.cloud.vision.v1.AnnotateImageResponse)6 Block (com.google.cloud.vision.v1.Block)6 Feature (com.google.cloud.vision.v1.Feature)6 ImageAnnotatorClient (com.google.cloud.vision.v1.ImageAnnotatorClient)6 Page (com.google.cloud.vision.v1.Page)6 Paragraph (com.google.cloud.vision.v1.Paragraph)6 Symbol (com.google.cloud.vision.v1.Symbol)6 Word (com.google.cloud.vision.v1.Word)6 IdentityHashMap (java.util.IdentityHashMap)5