Search in sources :

Example 1 with net.minecraft.server.v1_13_R1

use of net.minecraft.server.v1_13_R1 in project SimplePets by brainsynder-Dev.

the class EntityControllerPet method reloadLocation.

@Override
public void reloadLocation() {
    if (displayEntity.getPassenger() != null) {
        net.minecraft.server.v1_13_R1.Entity displayEntity = ((CraftEntity) this.displayEntity).getHandle();
        Location loc;
        if (this.displayRider != null) {
            if (this.displayRider.getType().equals(EntityType.SHULKER)) {
                loc = getBukkitEntity().getLocation().clone().subtract(0, 0.735, 0);
            } else {
                loc = getBukkitEntity().getLocation().clone();
            }
        } else {
            loc = getBukkitEntity().getLocation().clone();
        }
        displayEntity.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
        loc.getWorld().getNearbyEntities(loc, 100, 100, 100).forEach(entity -> {
            if (entity instanceof Player) {
                Player player = (Player) entity;
                PacketPlayOutEntityTeleport packet = new PacketPlayOutEntityTeleport(displayEntity);
                ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
            }
        });
        return;
    }
    net.minecraft.server.v1_13_R1.Entity displayEntity = ((CraftEntity) this.displayEntity).getHandle();
    Location loc;
    if (this.displayRider != null) {
        if (this.displayRider.getType().equals(EntityType.SHULKER)) {
            loc = getBukkitEntity().getLocation().clone().add(0, 0.75, 0);
        } else {
            loc = getBukkitEntity().getLocation().clone();
        }
    } else {
        loc = getBukkitEntity().getLocation().clone();
    }
    displayEntity.setPositionRotation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
    loc.getWorld().getNearbyEntities(loc, 100, 100, 100).forEach(entity -> {
        if (entity instanceof Player) {
            Player player = (Player) entity;
            PacketPlayOutEntityTeleport packet = new PacketPlayOutEntityTeleport(displayEntity);
            ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
        }
    });
}
Also used : CraftPlayer(org.bukkit.craftbukkit.v1_13_R1.entity.CraftPlayer) Player(org.bukkit.entity.Player) CraftEntity(org.bukkit.craftbukkit.v1_13_R1.entity.CraftEntity) CraftPlayer(org.bukkit.craftbukkit.v1_13_R1.entity.CraftPlayer) net.minecraft.server.v1_13_R1(net.minecraft.server.v1_13_R1) Location(org.bukkit.Location)

Example 2 with net.minecraft.server.v1_13_R1

use of net.minecraft.server.v1_13_R1 in project TheAPI by TheDevTec.

the class v1_13_R1 method openGUI.

@Override
public void openGUI(Player player, Object container, String legacy, int size, String title, ItemStack[] items) {
    EntityPlayer nmsPlayer = ((CraftPlayer) player).getHandle();
    int id = ((Container) container).windowId;
    net.minecraft.server.v1_13_R1.ItemStack[] nmsItems = new net.minecraft.server.v1_13_R1.ItemStack[items.length];
    for (int i = 0; i < items.length; ++i) {
        ItemStack is = items[i];
        if (is == null || is.getType() == Material.AIR)
            continue;
        net.minecraft.server.v1_13_R1.ItemStack item = null;
        ((Container) container).setItem(i, item = (net.minecraft.server.v1_13_R1.ItemStack) asNMSItem(is));
        nmsItems[i] = item;
    }
    BukkitLoader.getPacketHandler().send(player, packetOpenWindow(id, legacy, size, title));
    int i = 0;
    for (net.minecraft.server.v1_13_R1.ItemStack o : nmsItems) BukkitLoader.getPacketHandler().send(player, packetSetSlot(id, i++, o));
    nmsPlayer.activeContainer.transferTo((Container) container, (CraftPlayer) player);
    nmsPlayer.activeContainer = (Container) container;
    ((Container) container).addSlotListener(nmsPlayer);
    ((Container) container).checkReachable = false;
}
Also used : Container(net.minecraft.server.v1_13_R1.Container) CraftContainer(org.bukkit.craftbukkit.v1_13_R1.inventory.CraftContainer) EntityPlayer(net.minecraft.server.v1_13_R1.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_13_R1.entity.CraftPlayer) ItemStack(org.bukkit.inventory.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_13_R1.inventory.CraftItemStack)

Example 3 with net.minecraft.server.v1_13_R1

use of net.minecraft.server.v1_13_R1 in project TheAPI by TheDevTec.

the class v1_13_R1 method setGUITitle.

@Override
public void setGUITitle(Player player, Object container, String legacy, int size, String title) {
    EntityPlayer nmsPlayer = ((CraftPlayer) player).getHandle();
    int id = ((Container) container).windowId;
    NonNullList<net.minecraft.server.v1_13_R1.ItemStack> nmsItems = ((Container) container).items;
    BukkitLoader.getPacketHandler().send(player, packetOpenWindow(id, legacy, size, title));
    int i = 0;
    for (net.minecraft.server.v1_13_R1.ItemStack o : nmsItems) BukkitLoader.getPacketHandler().send(player, packetSetSlot(id, i++, o));
    nmsPlayer.activeContainer = (Container) container;
    ((Container) container).addSlotListener(nmsPlayer);
    ((Container) container).checkReachable = false;
}
Also used : Container(net.minecraft.server.v1_13_R1.Container) CraftContainer(org.bukkit.craftbukkit.v1_13_R1.inventory.CraftContainer) EntityPlayer(net.minecraft.server.v1_13_R1.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_13_R1.entity.CraftPlayer) ItemStack(org.bukkit.inventory.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_13_R1.inventory.CraftItemStack)

Example 4 with net.minecraft.server.v1_13_R1

use of net.minecraft.server.v1_13_R1 in project TheAPI by TheDevTec.

the class v1_13_R1 method setBlock.

@Override
public void setBlock(Object chunk, int x, int y, int z, Object IblockData, int data) {
    net.minecraft.server.v1_13_R1.Chunk c = (net.minecraft.server.v1_13_R1.Chunk) chunk;
    ChunkSection sc = c.getSections()[y >> 4];
    if (sc == null) {
        c.getSections()[y >> 4] = sc = new ChunkSection(y >> 4 << 4, true);
    }
    BlockPosition pos = new BlockPosition(x, y, z);
    // REMOVE TILE ENTITY
    c.tileEntities.remove(pos);
    try {
        DataBits bits = (DataBits) dataBits.get(sc.getBlocks());
        @SuppressWarnings("unchecked") DataPalette<IBlockData> pallete = (DataPalette<IBlockData>) dataPallete.get(sc.getBlocks());
        bits.a(b(x & 15, y & 15, z & 15), pallete.a((IBlockData) IblockData));
    } catch (Exception er) {
    }
    // ADD TILE ENTITY
    if (IblockData instanceof ITileEntity) {
        TileEntity ent = ((ITileEntity) IblockData).a(c);
        c.tileEntities.put(pos, ent);
        Object packet = ent.getUpdatePacket();
        Bukkit.getOnlinePlayers().forEach(player -> BukkitLoader.getPacketHandler().send(player, packet));
    }
}
Also used : ITileEntity(net.minecraft.server.v1_13_R1.ITileEntity) DataBits(net.minecraft.server.v1_13_R1.DataBits) BlockPosition(net.minecraft.server.v1_13_R1.BlockPosition) Chunk(org.bukkit.Chunk) CraftChunk(org.bukkit.craftbukkit.v1_13_R1.CraftChunk) DataPalette(net.minecraft.server.v1_13_R1.DataPalette) TileEntity(net.minecraft.server.v1_13_R1.TileEntity) ITileEntity(net.minecraft.server.v1_13_R1.ITileEntity) IBlockData(net.minecraft.server.v1_13_R1.IBlockData) ChunkSection(net.minecraft.server.v1_13_R1.ChunkSection)

Example 5 with net.minecraft.server.v1_13_R1

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

the class BlockBox1_13_R1 method getCollisionBox.

@Override
public CollisionBox getCollisionBox(Block block) {
    final net.minecraft.server.v1_13_R1.World world = ((org.bukkit.craftbukkit.v1_13_R1.CraftWorld) block.getWorld()).getHandle();
    final int x = block.getX(), y = block.getY(), z = block.getZ();
    net.minecraft.server.v1_13_R1.IBlockData iblockData = ((CraftBlock) block).getNMS();
    net.minecraft.server.v1_13_R1.Block vblock = iblockData.getBlock();
    BlockPosition blockPos = new BlockPosition(x, y, z);
    VoxelShape shape = vblock.a(iblockData, (IBlockAccess) world, blockPos);
    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.a, box.b, box.c, box.d, box.e, box.f);
    } else {
        ComplexCollisionBox complexBox = new ComplexCollisionBox();
        for (AxisAlignedBB box : boxes) {
            complexBox.add(new SimpleCollisionBox(box.a, box.b, box.c, box.d, box.e, box.f));
        }
        return complexBox;
    }
}
Also used : ComplexCollisionBox(cc.funkemunky.api.utils.world.types.ComplexCollisionBox) CraftBlock(org.bukkit.craftbukkit.v1_13_R1.block.CraftBlock) SimpleCollisionBox(cc.funkemunky.api.utils.world.types.SimpleCollisionBox) net.minecraft.server.v1_13_R1(net.minecraft.server.v1_13_R1)

Aggregations

CraftPlayer (org.bukkit.craftbukkit.v1_13_R1.entity.CraftPlayer)5 ItemStack (org.bukkit.inventory.ItemStack)5 CraftItemStack (org.bukkit.craftbukkit.v1_13_R1.inventory.CraftItemStack)4 net.minecraft.server.v1_13_R1 (net.minecraft.server.v1_13_R1)3 Container (net.minecraft.server.v1_13_R1.Container)3 EntityPlayer (net.minecraft.server.v1_13_R1.EntityPlayer)3 CraftChunk (org.bukkit.craftbukkit.v1_13_R1.CraftChunk)3 ChunkSection (net.minecraft.server.v1_13_R1.ChunkSection)2 ContainerAnvil (net.minecraft.server.v1_13_R1.ContainerAnvil)2 Chunk (org.bukkit.Chunk)2 CraftEntity (org.bukkit.craftbukkit.v1_13_R1.entity.CraftEntity)2 CraftContainer (org.bukkit.craftbukkit.v1_13_R1.inventory.CraftContainer)2 ComplexCollisionBox (cc.funkemunky.api.utils.world.types.ComplexCollisionBox)1 SimpleCollisionBox (cc.funkemunky.api.utils.world.types.SimpleCollisionBox)1 PacketType (com.comphenix.protocol.PacketType)1 PacketContainer (com.comphenix.protocol.events.PacketContainer)1 ItemSlot (com.comphenix.protocol.wrappers.EnumWrappers.ItemSlot)1 InteractionVisualizer (com.loohp.interactionvisualizer.InteractionVisualizer)1 BlockPosition (com.loohp.interactionvisualizer.objectholders.BlockPosition)1 BoundingBox (com.loohp.interactionvisualizer.objectholders.BoundingBox)1