Search in sources :

Example 1 with net.minecraft.server.v1_16_R2

use of net.minecraft.server.v1_16_R2 in project InteractionVisualizer by LOOHP.

the class V1_16_2 method getBoundingBoxes.

public List<BoundingBox> getBoundingBoxes(BlockPosition pos) {
    net.minecraft.server.v1_16_R2.BlockPosition blockpos = new net.minecraft.server.v1_16_R2.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) Item(org.bukkit.entity.Item) WorldServer(net.minecraft.server.v1_16_R2.WorldServer) EnumItemSlot(net.minecraft.server.v1_16_R2.EnumItemSlot) ArrayList(java.util.ArrayList) Block(org.bukkit.block.Block) CraftItemStack(org.bukkit.craftbukkit.v1_16_R2.inventory.CraftItemStack) TileEntityType(com.loohp.interactionvisualizer.objectholders.TileEntity.TileEntityType) World(org.bukkit.World) CraftMagicNumbers(org.bukkit.craftbukkit.v1_16_R2.util.CraftMagicNumbers) WrappedIterable(com.loohp.interactionvisualizer.objectholders.WrappedIterable) Material(org.bukkit.Material) EquipmentSlot(org.bukkit.inventory.EquipmentSlot) PacketPlayOutEntityEquipment(net.minecraft.server.v1_16_R2.PacketPlayOutEntityEquipment) ChunkPosition(com.loohp.interactionvisualizer.objectholders.ChunkPosition) Entity(org.bukkit.entity.Entity) ValuePairs(com.loohp.interactionvisualizer.objectholders.ValuePairs) BoundingBox(com.loohp.interactionvisualizer.objectholders.BoundingBox) CraftChunk(org.bukkit.craftbukkit.v1_16_R2.CraftChunk) TileEntity(com.loohp.interactionvisualizer.objectholders.TileEntity) Collectors(java.util.stream.Collectors) Pair(com.mojang.datafixers.util.Pair) ItemStack(org.bukkit.inventory.ItemStack) NMSTileEntitySet(com.loohp.interactionvisualizer.objectholders.NMSTileEntitySet) CraftWorld(org.bukkit.craftbukkit.v1_16_R2.CraftWorld) PacketContainer(com.comphenix.protocol.events.PacketContainer) List(java.util.List) EntityItem(net.minecraft.server.v1_16_R2.EntityItem) CraftItem(org.bukkit.craftbukkit.v1_16_R2.entity.CraftItem) VoxelShape(net.minecraft.server.v1_16_R2.VoxelShape) VoxelShape(net.minecraft.server.v1_16_R2.VoxelShape) BlockPosition(com.loohp.interactionvisualizer.objectholders.BlockPosition) BoundingBox(com.loohp.interactionvisualizer.objectholders.BoundingBox) WorldServer(net.minecraft.server.v1_16_R2.WorldServer) CraftWorld(org.bukkit.craftbukkit.v1_16_R2.CraftWorld)

Example 2 with net.minecraft.server.v1_16_R2

use of net.minecraft.server.v1_16_R2 in project InteractionVisualizer by LOOHP.

the class V1_16_2 method createEntityEquipmentPacket.

@Override
public PacketContainer[] createEntityEquipmentPacket(int entityId, List<ValuePairs<EquipmentSlot, ItemStack>> equipments) {
    List<Pair<EnumItemSlot, net.minecraft.server.v1_16_R2.ItemStack>> nmsList = new ArrayList<>();
    for (ValuePairs<EquipmentSlot, ItemStack> pair : equipments) {
        EnumItemSlot nmsSlot;
        switch(pair.getFirst()) {
            case CHEST:
                nmsSlot = EnumItemSlot.CHEST;
                break;
            case FEET:
                nmsSlot = EnumItemSlot.FEET;
                break;
            case HEAD:
                nmsSlot = EnumItemSlot.HEAD;
                break;
            case LEGS:
                nmsSlot = EnumItemSlot.LEGS;
                break;
            case OFF_HAND:
                nmsSlot = EnumItemSlot.OFFHAND;
                break;
            case HAND:
            default:
                nmsSlot = EnumItemSlot.MAINHAND;
                break;
        }
        net.minecraft.server.v1_16_R2.ItemStack nmsItem = CraftItemStack.asNMSCopy(pair.getSecond());
        nmsList.add(new Pair<>(nmsSlot, nmsItem));
    }
    PacketPlayOutEntityEquipment packet = new PacketPlayOutEntityEquipment(entityId, nmsList);
    return new PacketContainer[] { PacketContainer.fromPacket(packet) };
}
Also used : PacketContainer(com.comphenix.protocol.events.PacketContainer) ArrayList(java.util.ArrayList) EquipmentSlot(org.bukkit.inventory.EquipmentSlot) EnumItemSlot(net.minecraft.server.v1_16_R2.EnumItemSlot) CraftItemStack(org.bukkit.craftbukkit.v1_16_R2.inventory.CraftItemStack) ItemStack(org.bukkit.inventory.ItemStack) PacketPlayOutEntityEquipment(net.minecraft.server.v1_16_R2.PacketPlayOutEntityEquipment) Pair(com.mojang.datafixers.util.Pair)

Example 3 with net.minecraft.server.v1_16_R2

use of net.minecraft.server.v1_16_R2 in project RoseStacker by Rosewood-Development.

the class NMSHandlerImpl method setItemStackNBT.

@Override
public ItemStack setItemStackNBT(ItemStack itemStack, String key, int value) {
    net.minecraft.server.v1_16_R2.ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
    NBTTagCompound tagCompound = nmsItem.getOrCreateTag();
    tagCompound.setInt(key, value);
    return CraftItemStack.asBukkitCopy(nmsItem);
}
Also used : NBTTagCompound(net.minecraft.server.v1_16_R2.NBTTagCompound)

Example 4 with net.minecraft.server.v1_16_R2

use of net.minecraft.server.v1_16_R2 in project Atlas by funkemunky.

the class BlockBox1_16_R2 method getCollisionBox.

@Override
public CollisionBox getCollisionBox(org.bukkit.block.Block block) {
    final net.minecraft.server.v1_16_R2.World world = ((org.bukkit.craftbukkit.v1_16_R2.CraftWorld) block.getWorld()).getHandle();
    final int x = block.getX(), y = block.getY(), z = block.getZ();
    net.minecraft.server.v1_16_R2.IBlockData iblockData = ((CraftBlock) block).getNMS();
    net.minecraft.server.v1_16_R2.Block vblock = iblockData.getBlock();
    BlockPosition blockPos = new BlockPosition(x, y, z);
    VoxelShape shape = vblock.a(iblockData, world, blockPos, VoxelShapeCollision.a());
    List<AxisAlignedBB> boxes = shape.d();
    if (boxes.size() == 0) {
        return BlockData.getData(block.getType()).getBox(block, ProtocolVersion.getGameVersion());
    } else if (boxes.size() == 1) {
        AxisAlignedBB box = boxes.get(0);
        return new SimpleCollisionBox(box.minX, box.minY, box.minZ, box.maxX, box.maxY, box.maxZ);
    } else {
        ComplexCollisionBox complexBox = new ComplexCollisionBox();
        for (AxisAlignedBB box : boxes) {
            complexBox.add(new SimpleCollisionBox(box.minX, box.minY, box.minZ, box.maxX, box.maxY, box.maxZ));
        }
        return complexBox;
    }
}
Also used : ComplexCollisionBox(cc.funkemunky.api.utils.world.types.ComplexCollisionBox) CraftBlock(org.bukkit.craftbukkit.v1_16_R2.block.CraftBlock) SimpleCollisionBox(cc.funkemunky.api.utils.world.types.SimpleCollisionBox) net.minecraft.server.v1_16_R2(net.minecraft.server.v1_16_R2) World(net.minecraft.server.v1_16_R2.World) CraftWorld(org.bukkit.craftbukkit.v1_16_R2.CraftWorld)

Example 5 with net.minecraft.server.v1_16_R2

use of net.minecraft.server.v1_16_R2 in project SilkSpawners by timbru31.

the class NMSHandler method getSilkSpawnersNBTEntityID.

@Override
@Nullable
public String getSilkSpawnersNBTEntityID(final ItemStack item) {
    net.minecraft.server.v1_16_R2.ItemStack itemStack = null;
    final CraftItemStack craftStack = CraftItemStack.asCraftCopy(item);
    itemStack = CraftItemStack.asNMSCopy(craftStack);
    final NBTTagCompound tag = itemStack.getTag();
    if (tag == null || !tag.hasKey("SilkSpawners")) {
        return null;
    }
    return tag.getCompound("SilkSpawners").getString("entity");
}
Also used : CraftItemStack(org.bukkit.craftbukkit.v1_16_R2.inventory.CraftItemStack) NBTTagCompound(net.minecraft.server.v1_16_R2.NBTTagCompound) Nullable(javax.annotation.Nullable)

Aggregations

CraftItemStack (org.bukkit.craftbukkit.v1_16_R2.inventory.CraftItemStack)11 NBTTagCompound (net.minecraft.server.v1_16_R2.NBTTagCompound)9 ItemStack (org.bukkit.inventory.ItemStack)7 CraftChunk (org.bukkit.craftbukkit.v1_16_R2.CraftChunk)4 Container (net.minecraft.server.v1_16_R2.Container)3 EntityPlayer (net.minecraft.server.v1_16_R2.EntityPlayer)3 Chunk (org.bukkit.Chunk)3 CraftPlayer (org.bukkit.craftbukkit.v1_16_R2.entity.CraftPlayer)3 CraftContainer (org.bukkit.craftbukkit.v1_16_R2.inventory.CraftContainer)3 PacketContainer (com.comphenix.protocol.events.PacketContainer)2 Pair (com.mojang.datafixers.util.Pair)2 ArrayList (java.util.ArrayList)2 Nullable (javax.annotation.Nullable)2 net.minecraft.server.v1_16_R2 (net.minecraft.server.v1_16_R2)2 BlockPosition (net.minecraft.server.v1_16_R2.BlockPosition)2 ChunkSection (net.minecraft.server.v1_16_R2.ChunkSection)2 ContainerAnvil (net.minecraft.server.v1_16_R2.ContainerAnvil)2 EnumItemSlot (net.minecraft.server.v1_16_R2.EnumItemSlot)2 PacketPlayOutEntityEquipment (net.minecraft.server.v1_16_R2.PacketPlayOutEntityEquipment)2 Material (org.bukkit.Material)2