Search in sources :

Example 6 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 repeatTask.

@Override
public void repeatTask() {
    super.repeatTask();
    if (!this.isInvisible())
        this.setInvisible(true);
    if (getPet() != null)
        if (isBaby())
            setBaby((getPet().getPetType() instanceof ShulkerDefault));
    Player p = getPet().getOwner();
    if (this.displayEntity != null) {
        if (this.displayEntity.isValid()) {
            if (displayEntity.getPassenger() != null) {
                this.displayEntity.getPassenger().setCustomName(getCustomName().getText());
            } else {
                this.displayEntity.setCustomName(getCustomName().getText());
            }
            if (displayEntity.getPassenger() == null) {
                reloadLocation();
                net.minecraft.server.v1_13_R1.Entity displayEntity = ((CraftEntity) this.displayEntity).getHandle();
                if (((CraftPlayer) getOwner()).getHandle().isInvisible() != displayEntity.isInvisible()) {
                    displayEntity.setInvisible(!displayEntity.isInvisible());
                }
                return;
            }
            if (this.displayEntity.getPassenger() != null) {
                net.minecraft.server.v1_13_R1.Entity displayEntity = ((CraftEntity) this.displayEntity.getPassenger()).getHandle();
                if (((CraftPlayer) p).getHandle().isInvisible() != displayEntity.isInvisible()) {
                    displayEntity.setInvisible(!displayEntity.isInvisible());
                }
            }
        }
    }
}
Also used : CraftPlayer(org.bukkit.craftbukkit.v1_13_R1.entity.CraftPlayer) Player(org.bukkit.entity.Player) ShulkerDefault(simplepets.brainsynder.pet.types.ShulkerDefault) 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)

Example 7 with net.minecraft.server.v1_13_R1

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

the class V1_13 method getBoundingBoxes.

public List<BoundingBox> getBoundingBoxes(BlockPosition pos) {
    net.minecraft.server.v1_13_R1.BlockPosition blockpos = new net.minecraft.server.v1_13_R1.BlockPosition(pos.getX(), pos.getY(), pos.getZ());
    WorldServer world = ((CraftWorld) pos.getWorld()).getHandle();
    VoxelShape shape = world.getType(blockpos).g(world, blockpos);
    return shape.d().stream().map(each -> new BoundingBox(each.a + pos.getX(), each.b + pos.getY(), each.c + pos.getZ(), each.d + pos.getX(), each.e + pos.getY(), each.f + pos.getZ())).collect(Collectors.toList());
}
Also used : BlockPosition(com.loohp.interactionvisualizer.objectholders.BlockPosition) Item(org.bukkit.entity.Item) CraftChunk(org.bukkit.craftbukkit.v1_13_R1.CraftChunk) Block(org.bukkit.block.Block) CraftWorld(org.bukkit.craftbukkit.v1_13_R1.CraftWorld) TileEntityType(com.loohp.interactionvisualizer.objectholders.TileEntity.TileEntityType) World(org.bukkit.World) VoxelShape(net.minecraft.server.v1_13_R1.VoxelShape) WrappedIterable(com.loohp.interactionvisualizer.objectholders.WrappedIterable) WorldServer(net.minecraft.server.v1_13_R1.WorldServer) Material(org.bukkit.Material) EquipmentSlot(org.bukkit.inventory.EquipmentSlot) ChunkPosition(com.loohp.interactionvisualizer.objectholders.ChunkPosition) CraftMagicNumbers(org.bukkit.craftbukkit.v1_13_R1.util.CraftMagicNumbers) InteractionVisualizer(com.loohp.interactionvisualizer.InteractionVisualizer) Entity(org.bukkit.entity.Entity) ValuePairs(com.loohp.interactionvisualizer.objectholders.ValuePairs) BoundingBox(com.loohp.interactionvisualizer.objectholders.BoundingBox) ItemSlot(com.comphenix.protocol.wrappers.EnumWrappers.ItemSlot) TileEntity(com.loohp.interactionvisualizer.objectholders.TileEntity) PacketType(com.comphenix.protocol.PacketType) EntityItem(net.minecraft.server.v1_13_R1.EntityItem) Collectors(java.util.stream.Collectors) ItemStack(org.bukkit.inventory.ItemStack) NMSTileEntitySet(com.loohp.interactionvisualizer.objectholders.NMSTileEntitySet) PacketContainer(com.comphenix.protocol.events.PacketContainer) List(java.util.List) CraftItem(org.bukkit.craftbukkit.v1_13_R1.entity.CraftItem) VoxelShape(net.minecraft.server.v1_13_R1.VoxelShape) BlockPosition(com.loohp.interactionvisualizer.objectholders.BlockPosition) BoundingBox(com.loohp.interactionvisualizer.objectholders.BoundingBox) WorldServer(net.minecraft.server.v1_13_R1.WorldServer) CraftWorld(org.bukkit.craftbukkit.v1_13_R1.CraftWorld)

Example 8 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 processInvClickPacket.

@Override
public boolean processInvClickPacket(Player player, HolderGUI gui, Object provPacket) {
    PacketPlayInWindowClick packet = (PacketPlayInWindowClick) provPacket;
    int slot = packet.c();
    if (slot == -999)
        return false;
    int id = packet.b();
    int mouseClick = packet.d();
    net.minecraft.server.v1_13_R1.InventoryClickType nmsType = packet.g();
    InventoryClickType type = InventoryClickType.valueOf(nmsType.name());
    Object container = gui.getContainer(player);
    ItemStack item = asBukkitItem(packet.f());
    if ((type == InventoryClickType.QUICK_MOVE || type == InventoryClickType.CLONE || type == InventoryClickType.THROW || (item.getType() == Material.AIR || item.getType() == Material.CAVE_AIR)) && (item.getType() == Material.AIR || item.getType() == Material.CAVE_AIR))
        item = asBukkitItem(getSlotItem(container, slot));
    boolean cancel = false;
    if (InventoryClickType.SWAP == type) {
        item = player.getInventory().getItem(mouseClick);
        mouseClick = 0;
        cancel = true;
    }
    if (item == null)
        item = new ItemStack(Material.AIR);
    ItemStack before = player.getItemOnCursor();
    ClickType clickType = BukkitLoader.buildClick(item, type, slot, mouseClick);
    if (!cancel)
        cancel = BukkitLoader.useItem(player, item, gui, slot, clickType);
    if (!gui.isInsertable())
        cancel = true;
    int gameSlot = slot > gui.size() - 1 ? InventoryUtils.convertToPlayerInvSlot(slot - gui.size()) : slot;
    if (!cancel)
        cancel = gui.onIteractItem(player, item, clickType, gameSlot, slot < gui.size());
    else
        gui.onIteractItem(player, item, clickType, gameSlot, slot < gui.size());
    int position = 0;
    if (!cancel && type == InventoryClickType.QUICK_MOVE) {
        ItemStack[] contents = slot < gui.size() ? player.getInventory().getStorageContents() : gui.getInventory().getStorageContents();
        List<Integer> modified = slot < gui.size() ? InventoryUtils.shift(slot, player, gui, clickType, gui instanceof AnvilGUI ? DestinationType.PLAYER_INV_ANVIL : DestinationType.PLAYER_INV_CUSTOM_INV, null, contents, item) : InventoryUtils.shift(slot, player, gui, clickType, DestinationType.CUSTOM_INV, gui.getNotInterableSlots(player), contents, item);
        if (!modified.isEmpty()) {
            if (slot < gui.size()) {
                boolean canRemove = !modified.contains(-1);
                player.getInventory().setStorageContents(contents);
                if (canRemove) {
                    gui.remove(gameSlot);
                } else {
                    gui.getInventory().setItem(gameSlot, item);
                }
            } else {
                boolean canRemove = !modified.contains(-1);
                gui.getInventory().setStorageContents(contents);
                if (canRemove) {
                    player.getInventory().setItem(gameSlot, null);
                } else {
                    player.getInventory().setItem(gameSlot, item);
                }
            }
        }
        return true;
    }
    if (cancel) {
        // MOUSE
        BukkitLoader.getPacketHandler().send(player, packetSetSlot(-1, -1, asNMSItem(before)));
        switch(type) {
            case CLONE:
                return true;
            case SWAP:
            case QUICK_MOVE:
            case PICKUP_ALL:
                // TOP
                for (ItemStack cItem : gui.getInventory().getContents()) {
                    BukkitLoader.getPacketHandler().send(player, packetSetSlot(id, position++, asNMSItem(cItem)));
                }
                // BUTTON
                player.updateInventory();
                return true;
            default:
                BukkitLoader.getPacketHandler().send(player, packetSetSlot(id, slot, getSlotItem(container, slot)));
                if (gui instanceof AnvilGUI) {
                    // TOP
                    for (ItemStack cItem : gui.getInventory().getContents()) {
                        if (position != slot)
                            BukkitLoader.getPacketHandler().send(player, packetSetSlot(id, position++, asNMSItem(cItem)));
                    }
                    // BUTTON
                    player.updateInventory();
                }
                return true;
        }
    } else {
        if (gui instanceof AnvilGUI && slot == 2)
            postToMainThread(() -> ((ContainerAnvil) container).shiftClick((EntityPlayer) getPlayer(player), slot));
    }
    return false;
}
Also used : AnvilGUI(me.devtec.theapi.bukkit.gui.AnvilGUI) InventoryClickType(me.devtec.theapi.bukkit.BukkitLoader.InventoryClickType) InventoryClickType(me.devtec.theapi.bukkit.BukkitLoader.InventoryClickType) ClickType(me.devtec.theapi.bukkit.gui.GUI.ClickType) ContainerAnvil(net.minecraft.server.v1_13_R1.ContainerAnvil) PacketPlayInWindowClick(net.minecraft.server.v1_13_R1.PacketPlayInWindowClick) ItemStack(org.bukkit.inventory.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_13_R1.inventory.CraftItemStack)

Example 9 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 getBlock.

@Override
public Object getBlock(Object chunk, int x, int y, int z) {
    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)
        return Blocks.AIR.getBlockData();
    return sc.getBlocks().a(x & 15, y & 15, z & 15);
}
Also used : Chunk(org.bukkit.Chunk) CraftChunk(org.bukkit.craftbukkit.v1_13_R1.CraftChunk) ChunkSection(net.minecraft.server.v1_13_R1.ChunkSection)

Example 10 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 openAnvilGUI.

@Override
public void openAnvilGUI(Player player, Object con, String title, ItemStack[] items) {
    ContainerAnvil container = (ContainerAnvil) con;
    EntityPlayer nmsPlayer = ((CraftPlayer) player).getHandle();
    int id = 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.setItem(i, item = (net.minecraft.server.v1_13_R1.ItemStack) asNMSItem(is));
        nmsItems[i] = item;
    }
    BukkitLoader.getPacketHandler().send(player, packetOpenWindow(id, "minecraft:anvil", 0, 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.checkReachable = false;
}
Also used : Container(net.minecraft.server.v1_13_R1.Container) CraftContainer(org.bukkit.craftbukkit.v1_13_R1.inventory.CraftContainer) ContainerAnvil(net.minecraft.server.v1_13_R1.ContainerAnvil) 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)

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