Search in sources :

Example 86 with IBlockData

use of net.minecraft.server.v1_16_R1.IBlockData 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)

Example 87 with IBlockData

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

the class Block_1_13_R2 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 theMask = mask == null ? null : ((CraftBlockState) mask).getHandle();
    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)

Example 88 with IBlockData

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

the class Block_1_9_R2 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_9_R2.BlockPosition) ArrayList(java.util.ArrayList) WorldServer(net.minecraft.server.v1_9_R2.WorldServer) CraftChunk(org.bukkit.craftbukkit.v1_9_R2.CraftChunk) Chunk(org.bukkit.Chunk) IBlockData(net.minecraft.server.v1_9_R2.IBlockData) Block(org.bukkit.block.Block) ArrayList(java.util.ArrayList) List(java.util.List) CraftWorld(org.bukkit.craftbukkit.v1_9_R2.CraftWorld) NotNull(org.jetbrains.annotations.NotNull)

Example 89 with IBlockData

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

the class v1_9_R2 method getHitBox.

@Override
public HitBox getHitBox(org.bukkit.block.Block block) {
    if (block.isEmpty() || block.isLiquid())
        return null;
    WorldServer worldServer = ((CraftWorld) block.getWorld()).getHandle();
    BlockPosition blockPosition = new BlockPosition(block.getX(), block.getY(), block.getZ());
    IBlockData blockData = worldServer.getType(blockPosition);
    Block nmsBlock = blockData.getBlock();
    // Passable block check -> false means passable (thats why !)
    if (!(blockData.d(worldServer, blockPosition) != Block.k && nmsBlock.a(blockData, false)))
        return null;
    AxisAlignedBB aabb = blockData.c(worldServer, blockPosition);
    // 1.12 -> e
    // 1.11 -> d
    // 1.9 - 1.10 -> c
    int x = blockPosition.getX(), y = blockPosition.getY(), z = blockPosition.getZ();
    HitBox hitBox = new HitBox(x + aabb.a, y + aabb.b, z + aabb.c, x + aabb.d, y + aabb.e, z + aabb.f);
    hitBox.setBlockHitBox(block);
    return hitBox;
}
Also used : AxisAlignedBB(net.minecraft.server.v1_9_R2.AxisAlignedBB) IBlockData(net.minecraft.server.v1_9_R2.IBlockData) HitBox(me.deecaad.weaponmechanics.weapon.projectile.HitBox) BlockPosition(net.minecraft.server.v1_9_R2.BlockPosition) Block(net.minecraft.server.v1_9_R2.Block) WorldServer(net.minecraft.server.v1_9_R2.WorldServer) CraftWorld(org.bukkit.craftbukkit.v1_9_R2.CraftWorld)

Example 90 with IBlockData

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

the class v1_10_R1 method getHitBox.

@Override
public HitBox getHitBox(org.bukkit.block.Block block) {
    if (block.isEmpty() || block.isLiquid())
        return null;
    WorldServer worldServer = ((CraftWorld) block.getWorld()).getHandle();
    BlockPosition blockPosition = new BlockPosition(block.getX(), block.getY(), block.getZ());
    IBlockData blockData = worldServer.getType(blockPosition);
    Block nmsBlock = blockData.getBlock();
    // Passable block check -> false means passable (thats why !)
    if (!(blockData.d(worldServer, blockPosition) != Block.k && nmsBlock.a(blockData, false)))
        return null;
    AxisAlignedBB aabb = blockData.c(worldServer, blockPosition);
    // 1.12 -> e
    // 1.11 -> d
    // 1.9 - 1.10 -> c
    int x = blockPosition.getX(), y = blockPosition.getY(), z = blockPosition.getZ();
    HitBox hitBox = new HitBox(x + aabb.a, y + aabb.b, z + aabb.c, x + aabb.d, y + aabb.e, z + aabb.f);
    hitBox.setBlockHitBox(block);
    return hitBox;
}
Also used : AxisAlignedBB(net.minecraft.server.v1_10_R1.AxisAlignedBB) IBlockData(net.minecraft.server.v1_10_R1.IBlockData) HitBox(me.deecaad.weaponmechanics.weapon.projectile.HitBox) BlockPosition(net.minecraft.server.v1_10_R1.BlockPosition) Block(net.minecraft.server.v1_10_R1.Block) WorldServer(net.minecraft.server.v1_10_R1.WorldServer) CraftWorld(org.bukkit.craftbukkit.v1_10_R1.CraftWorld)

Aggregations

HashMap (java.util.HashMap)24 ArrayList (java.util.ArrayList)20 Block (org.bukkit.block.Block)18 List (java.util.List)16 IBlockData (net.minecraft.server.v1_16_R3.IBlockData)16 NotNull (org.jetbrains.annotations.NotNull)16 Chunk (org.bukkit.Chunk)15 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