Search in sources :

Example 1 with CraftContainer

use of org.bukkit.craftbukkit.v1_16_R1.inventory.CraftContainer in project MyPet by xXKeyleXx.

the class CustomInventory method open.

@Override
public void open(Player player) {
    EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
    Container container = new CraftContainer(getBukkitInventory(), entityPlayer, entityPlayer.nextContainerCounter());
    container = CraftEventFactory.callInventoryOpenEvent(entityPlayer, container);
    if (container != null) {
        Containers customSize = Containers.GENERIC_9X1;
        switch(this.getSize()) {
            case 18:
                customSize = Containers.GENERIC_9X2;
                break;
            case 27:
                customSize = Containers.GENERIC_9X3;
                break;
            case 36:
                customSize = Containers.GENERIC_9X4;
                break;
            case 45:
                customSize = Containers.GENERIC_9X5;
                break;
            case 54:
                customSize = Containers.GENERIC_9X6;
                break;
        }
        entityPlayer.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, customSize, new ChatComponentText(this.getName())));
        entityPlayer.activeContainer = container;
        entityPlayer.activeContainer.addSlotListener(entityPlayer);
    }
}
Also used : CraftContainer(org.bukkit.craftbukkit.v1_16_R1.inventory.CraftContainer) CraftPlayer(org.bukkit.craftbukkit.v1_16_R1.entity.CraftPlayer) CraftContainer(org.bukkit.craftbukkit.v1_16_R1.inventory.CraftContainer)

Example 2 with CraftContainer

use of org.bukkit.craftbukkit.v1_16_R1.inventory.CraftContainer in project MyPet by xXKeyleXx.

the class CustomInventory method open.

@Override
public void open(Player player) {
    EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
    Container container = new CraftContainer(getBukkitInventory(), entityPlayer, entityPlayer.nextContainerCounter());
    container = CraftEventFactory.callInventoryOpenEvent(entityPlayer, container);
    if (container != null) {
        Containers customSize = Containers.GENERIC_9X1;
        switch(this.getSize()) {
            case 18:
                customSize = Containers.GENERIC_9X2;
                break;
            case 27:
                customSize = Containers.GENERIC_9X3;
                break;
            case 36:
                customSize = Containers.GENERIC_9X4;
                break;
            case 45:
                customSize = Containers.GENERIC_9X5;
                break;
            case 54:
                customSize = Containers.GENERIC_9X6;
                break;
        }
        entityPlayer.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, customSize, new ChatComponentText(this.getName())));
        entityPlayer.activeContainer = container;
        entityPlayer.activeContainer.addSlotListener(entityPlayer);
    }
}
Also used : CraftContainer(org.bukkit.craftbukkit.v1_16_R3.inventory.CraftContainer) CraftPlayer(org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer) CraftContainer(org.bukkit.craftbukkit.v1_16_R3.inventory.CraftContainer)

Example 3 with CraftContainer

use of org.bukkit.craftbukkit.v1_16_R1.inventory.CraftContainer in project MyPet by xXKeyleXx.

the class CustomInventory method open.

@Override
public void open(Player player) {
    ServerPlayer entityPlayer = ((CraftPlayer) player).getHandle();
    AbstractContainerMenu container = new CraftContainer(getBukkitInventory(), entityPlayer, entityPlayer.nextContainerCounter());
    container = CraftEventFactory.callInventoryOpenEvent(entityPlayer, container);
    if (container != null) {
        MenuType<?> customSize = MenuType.GENERIC_9x1;
        switch(this.getContainerSize()) {
            case 18:
                customSize = MenuType.GENERIC_9x2;
                break;
            case 27:
                customSize = MenuType.GENERIC_9x3;
                break;
            case 36:
                customSize = MenuType.GENERIC_9x4;
                break;
            case 45:
                customSize = MenuType.GENERIC_9x5;
                break;
            case 54:
                customSize = MenuType.GENERIC_9x6;
                break;
        }
        entityPlayer.connection.send(new ClientboundOpenScreenPacket(container.containerId, customSize, new TextComponent(this.getName())));
        entityPlayer.containerMenu = container;
        entityPlayer.initMenu(container);
    }
}
Also used : TextComponent(net.minecraft.network.chat.TextComponent) AbstractContainerMenu(net.minecraft.world.inventory.AbstractContainerMenu) ServerPlayer(net.minecraft.server.level.ServerPlayer) ClientboundOpenScreenPacket(net.minecraft.network.protocol.game.ClientboundOpenScreenPacket) CraftPlayer(org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer) CraftContainer(org.bukkit.craftbukkit.v1_17_R1.inventory.CraftContainer)

Example 4 with CraftContainer

use of org.bukkit.craftbukkit.v1_16_R1.inventory.CraftContainer in project MyPet by xXKeyleXx.

the class CustomInventory method open.

@Override
public void open(Player player) {
    ServerPlayer entityPlayer = ((CraftPlayer) player).getHandle();
    AbstractContainerMenu container = new CraftContainer(getBukkitInventory(), entityPlayer, entityPlayer.nextContainerCounter());
    container = CraftEventFactory.callInventoryOpenEvent(entityPlayer, container);
    if (container != null) {
        MenuType<?> customSize = MenuType.GENERIC_9x1;
        switch(this.getContainerSize()) {
            case 18:
                customSize = MenuType.GENERIC_9x2;
                break;
            case 27:
                customSize = MenuType.GENERIC_9x3;
                break;
            case 36:
                customSize = MenuType.GENERIC_9x4;
                break;
            case 45:
                customSize = MenuType.GENERIC_9x5;
                break;
            case 54:
                customSize = MenuType.GENERIC_9x6;
                break;
        }
        entityPlayer.connection.send(new ClientboundOpenScreenPacket(container.containerId, customSize, new TextComponent(this.getName())));
        entityPlayer.containerMenu = container;
        entityPlayer.initMenu(container);
    }
}
Also used : TextComponent(net.minecraft.network.chat.TextComponent) AbstractContainerMenu(net.minecraft.world.inventory.AbstractContainerMenu) ServerPlayer(net.minecraft.server.level.ServerPlayer) ClientboundOpenScreenPacket(net.minecraft.network.protocol.game.ClientboundOpenScreenPacket) CraftPlayer(org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer) CraftContainer(org.bukkit.craftbukkit.v1_18_R1.inventory.CraftContainer)

Aggregations

TextComponent (net.minecraft.network.chat.TextComponent)2 ClientboundOpenScreenPacket (net.minecraft.network.protocol.game.ClientboundOpenScreenPacket)2 ServerPlayer (net.minecraft.server.level.ServerPlayer)2 AbstractContainerMenu (net.minecraft.world.inventory.AbstractContainerMenu)2 CraftPlayer (org.bukkit.craftbukkit.v1_16_R1.entity.CraftPlayer)1 CraftContainer (org.bukkit.craftbukkit.v1_16_R1.inventory.CraftContainer)1 CraftPlayer (org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer)1 CraftContainer (org.bukkit.craftbukkit.v1_16_R3.inventory.CraftContainer)1 CraftPlayer (org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer)1 CraftContainer (org.bukkit.craftbukkit.v1_17_R1.inventory.CraftContainer)1 CraftPlayer (org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer)1 CraftContainer (org.bukkit.craftbukkit.v1_18_R1.inventory.CraftContainer)1