Search in sources :

Example 76 with WorldServer

use of net.minecraft.server.v1_9_R2.WorldServer in project InteractionVisualizer by LOOHP.

the class V1_16 method getBoundingBoxes.

public List<BoundingBox> getBoundingBoxes(BlockPosition pos) {
    net.minecraft.server.v1_16_R1.BlockPosition blockpos = new net.minecraft.server.v1_16_R1.BlockPosition(pos.getX(), pos.getY(), pos.getZ());
    WorldServer world = ((CraftWorld) pos.getWorld()).getHandle();
    VoxelShape shape = world.getType(blockpos).getShape(world, blockpos);
    return shape.d().stream().map(each -> new BoundingBox(each.minX + pos.getX(), each.minY + pos.getY(), each.minZ + pos.getZ(), each.maxX + pos.getX(), each.maxY + pos.getY(), each.maxZ + pos.getZ())).collect(Collectors.toList());
}
Also used : BlockPosition(com.loohp.interactionvisualizer.objectholders.BlockPosition) EntityItem(net.minecraft.server.v1_16_R1.EntityItem) Item(org.bukkit.entity.Item) CraftChunk(org.bukkit.craftbukkit.v1_16_R1.CraftChunk) CraftWorld(org.bukkit.craftbukkit.v1_16_R1.CraftWorld) VoxelShape(net.minecraft.server.v1_16_R1.VoxelShape) CraftItem(org.bukkit.craftbukkit.v1_16_R1.entity.CraftItem) WorldServer(net.minecraft.server.v1_16_R1.WorldServer) ArrayList(java.util.ArrayList) Block(org.bukkit.block.Block) TileEntityType(com.loohp.interactionvisualizer.objectholders.TileEntity.TileEntityType) World(org.bukkit.World) WrappedIterable(com.loohp.interactionvisualizer.objectholders.WrappedIterable) Material(org.bukkit.Material) EquipmentSlot(org.bukkit.inventory.EquipmentSlot) ChunkPosition(com.loohp.interactionvisualizer.objectholders.ChunkPosition) Entity(org.bukkit.entity.Entity) ValuePairs(com.loohp.interactionvisualizer.objectholders.ValuePairs) BoundingBox(com.loohp.interactionvisualizer.objectholders.BoundingBox) TileEntity(com.loohp.interactionvisualizer.objectholders.TileEntity) Collectors(java.util.stream.Collectors) Pair(com.mojang.datafixers.util.Pair) CraftItemStack(org.bukkit.craftbukkit.v1_16_R1.inventory.CraftItemStack) ItemStack(org.bukkit.inventory.ItemStack) NMSTileEntitySet(com.loohp.interactionvisualizer.objectholders.NMSTileEntitySet) PacketContainer(com.comphenix.protocol.events.PacketContainer) List(java.util.List) EnumItemSlot(net.minecraft.server.v1_16_R1.EnumItemSlot) PacketPlayOutEntityEquipment(net.minecraft.server.v1_16_R1.PacketPlayOutEntityEquipment) CraftMagicNumbers(org.bukkit.craftbukkit.v1_16_R1.util.CraftMagicNumbers) VoxelShape(net.minecraft.server.v1_16_R1.VoxelShape) BlockPosition(com.loohp.interactionvisualizer.objectholders.BlockPosition) BoundingBox(com.loohp.interactionvisualizer.objectholders.BoundingBox) WorldServer(net.minecraft.server.v1_16_R1.WorldServer) CraftWorld(org.bukkit.craftbukkit.v1_16_R1.CraftWorld)

Example 77 with WorldServer

use of net.minecraft.server.v1_9_R2.WorldServer in project MechanicsMain by WeaponMechanics.

the class Block_1_11_R1 method getBlastResistance.

@Override
public float getBlastResistance(Block block) {
    WorldServer world = ((CraftWorld) block.getWorld()).getHandle();
    BlockPosition pos = new BlockPosition(block.getX(), block.getY(), block.getZ());
    net.minecraft.server.v1_11_R1.Block nmsBlock = world.c(pos).getBlock();
    return (float) ReflectionUtil.invokeField(durabilityField, nmsBlock) / 5.0f;
}
Also used : BlockPosition(net.minecraft.server.v1_11_R1.BlockPosition) WorldServer(net.minecraft.server.v1_11_R1.WorldServer) CraftWorld(org.bukkit.craftbukkit.v1_11_R1.CraftWorld)

Example 78 with WorldServer

use of net.minecraft.server.v1_9_R2.WorldServer 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 79 with WorldServer

use of net.minecraft.server.v1_9_R2.WorldServer 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 80 with WorldServer

use of net.minecraft.server.v1_9_R2.WorldServer in project MechanicsMain by WeaponMechanics.

the class Block_1_9_R2 method getBlastResistance.

@Override
public float getBlastResistance(Block block) {
    WorldServer world = ((CraftWorld) block.getWorld()).getHandle();
    BlockPosition pos = new BlockPosition(block.getX(), block.getY(), block.getZ());
    net.minecraft.server.v1_9_R2.Block nmsBlock = world.c(pos).getBlock();
    return (float) ReflectionUtil.invokeField(durabilityField, nmsBlock) / 5.0f;
}
Also used : BlockPosition(net.minecraft.server.v1_9_R2.BlockPosition) WorldServer(net.minecraft.server.v1_9_R2.WorldServer) CraftWorld(org.bukkit.craftbukkit.v1_9_R2.CraftWorld)

Aggregations

WorldServer (net.minecraft.server.v1_16_R3.WorldServer)25 CraftWorld (org.bukkit.craftbukkit.v1_16_R3.CraftWorld)19 ArrayList (java.util.ArrayList)18 UUID (java.util.UUID)18 List (java.util.List)16 WorldServer (net.minecraft.server.v1_12_R1.WorldServer)16 GameProfile (com.mojang.authlib.GameProfile)15 WorldServer (net.minecraft.server.v1_11_R1.WorldServer)15 Material (org.bukkit.Material)15 WorldServer (net.minecraft.server.v1_14_R1.WorldServer)14 WorldServer (net.minecraft.server.v1_15_R1.WorldServer)14 CraftWorld (org.bukkit.craftbukkit.v1_12_R1.CraftWorld)14 WorldServer (net.minecraft.server.v1_10_R1.WorldServer)13 Block (org.bukkit.block.Block)13 CraftWorld (org.bukkit.craftbukkit.v1_11_R1.CraftWorld)13 SkinnableEntity (net.citizensnpcs.npc.skin.SkinnableEntity)12 WorldServer (net.minecraft.server.v1_8_R3.WorldServer)12 LivingEntity (org.bukkit.entity.LivingEntity)12 CraftWorld (org.bukkit.craftbukkit.v1_10_R1.CraftWorld)11 WorldServer (net.minecraft.server.v1_13_R2.WorldServer)10