Search in sources :

Example 81 with IBlockData

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

the class BukkitVersionHelperSpigot114_1 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_14_R1.IBlockData)

Example 82 with IBlockData

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

the class Block_1_11_R1 method getMultiBlockMaskPacket.

@Override
@NotNull
public List<Object> getMultiBlockMaskPacket(@NotNull List<Block> blocks, @Nullable BlockState mask) {
    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 blockData = null;
    if (mask != null) {
        WorldServer world = ((CraftWorld) mask.getWorld()).getHandle();
        BlockPosition pos = new BlockPosition(mask.getX(), mask.getY(), mask.getZ());
        blockData = world.c(pos).getBlock().getBlockData();
    }
    for (List<Block> entry : sortedBlocks.values()) {
        packets.add(getMultiBlockMaskPacket(entry, blockData));
    }
    return packets;
}
Also used : HashMap(java.util.HashMap) BlockPosition(net.minecraft.server.v1_11_R1.BlockPosition) ArrayList(java.util.ArrayList) WorldServer(net.minecraft.server.v1_11_R1.WorldServer) CraftChunk(org.bukkit.craftbukkit.v1_11_R1.CraftChunk) Chunk(org.bukkit.Chunk) IBlockData(net.minecraft.server.v1_11_R1.IBlockData) Block(org.bukkit.block.Block) ArrayList(java.util.ArrayList) List(java.util.List) CraftWorld(org.bukkit.craftbukkit.v1_11_R1.CraftWorld) NotNull(org.jetbrains.annotations.NotNull)

Example 83 with IBlockData

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

the class Block_1_11_R1 method getMultiBlockMaskPacket.

@SuppressWarnings("deprecation")
@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 : net.minecraft.server.v1_11_R1.Block.getByCombinedId(mask.getId() | data << 12);
    for (List<Block> entry : sortedBlocks.values()) {
        packets.add(getMultiBlockMaskPacket(entry, theMask));
    }
    return packets;
}
Also used : IBlockData(net.minecraft.server.v1_11_R1.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_11_R1.CraftChunk) Chunk(org.bukkit.Chunk) NotNull(org.jetbrains.annotations.NotNull)

Example 84 with IBlockData

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

the class Block_1_10_R1 method getMultiBlockMaskPacket.

@Override
@NotNull
public List<Object> getMultiBlockMaskPacket(@NotNull List<Block> blocks, @Nullable BlockState mask) {
    if (blocks == null || blocks.isEmpty()) {
        throw new IllegalArgumentException("No blocks are being changed!");
    }
    Map<org.bukkit.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 blockData = null;
    if (mask != null) {
        WorldServer world = ((CraftWorld) mask.getWorld()).getHandle();
        BlockPosition pos = new BlockPosition(mask.getX(), mask.getY(), mask.getZ());
        blockData = world.c(pos).getBlock().getBlockData();
    }
    for (List<Block> entry : sortedBlocks.values()) {
        packets.add(getMultiBlockMaskPacket(entry, blockData));
    }
    return packets;
}
Also used : HashMap(java.util.HashMap) BlockPosition(net.minecraft.server.v1_10_R1.BlockPosition) ArrayList(java.util.ArrayList) WorldServer(net.minecraft.server.v1_10_R1.WorldServer) Chunk(org.bukkit.Chunk) CraftChunk(org.bukkit.craftbukkit.v1_10_R1.CraftChunk) IBlockData(net.minecraft.server.v1_10_R1.IBlockData) Block(org.bukkit.block.Block) ArrayList(java.util.ArrayList) List(java.util.List) CraftWorld(org.bukkit.craftbukkit.v1_10_R1.CraftWorld) NotNull(org.jetbrains.annotations.NotNull)

Example 85 with IBlockData

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

the class Block_1_14_R1 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_14_R1.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_14_R1.CraftChunk) Chunk(org.bukkit.Chunk) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

HashMap (java.util.HashMap)24 ArrayList (java.util.ArrayList)20 Block (org.bukkit.block.Block)19 List (java.util.List)16 IBlockData (net.minecraft.server.v1_16_R3.IBlockData)16 NotNull (org.jetbrains.annotations.NotNull)16 Chunk (org.bukkit.Chunk)14 IBlockData (net.minecraft.server.v1_12_R1.IBlockData)11 IBlockData (net.minecraft.server.v1_14_R1.IBlockData)10 BlockPosition (net.minecraft.server.v1_12_R1.BlockPosition)9 IBlockData (net.minecraft.server.v1_10_R1.IBlockData)8 IBlockData (net.minecraft.server.v1_15_R1.IBlockData)8 BlockPosition (net.minecraft.server.v1_16_R3.BlockPosition)8 BlockPosition (net.minecraft.server.v1_10_R1.BlockPosition)7 IBlockData (net.minecraft.server.v1_11_R1.IBlockData)7 BlockPosition (net.minecraft.server.v1_8_R3.BlockPosition)7 IBlockData (net.minecraft.server.v1_8_R3.IBlockData)7 IdentityHashMap (java.util.IdentityHashMap)6 BlockPosition (net.minecraft.server.v1_11_R1.BlockPosition)6 BlockPosition (net.minecraft.server.v1_14_R1.BlockPosition)6