Search in sources :

Example 1 with SOpenHorseWindowPacket

use of net.minecraft.network.play.server.SOpenHorseWindowPacket in project Arclight by IzzelAliz.

the class ServerPlayerEntityMixin method openHorseInventory.

/**
 * @author IzzelAliz
 * @reason
 */
@Overwrite
public void openHorseInventory(final AbstractHorseEntity entityhorseabstract, final IInventory iinventory) {
    this.nextContainerCounter();
    Container container = new HorseInventoryContainer(this.currentWindowId, this.inventory, iinventory, entityhorseabstract);
    ((ContainerBridge) container).bridge$setTitle(entityhorseabstract.getDisplayName());
    container = CraftEventFactory.callInventoryOpenEvent((ServerPlayerEntity) (Object) this, container);
    if (container == null) {
        iinventory.closeInventory((ServerPlayerEntity) (Object) this);
        return;
    }
    if (this.openContainer != this.container) {
        this.closeScreen();
    }
    this.connection.sendPacket(new SOpenHorseWindowPacket(this.currentWindowId, iinventory.getSizeInventory(), entityhorseabstract.getEntityId()));
    (this.openContainer = container).addListener((ServerPlayerEntity) (Object) this);
    net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerContainerEvent.Open((ServerPlayerEntity) (Object) this, this.openContainer));
}
Also used : HorseInventoryContainer(net.minecraft.inventory.container.HorseInventoryContainer) Container(net.minecraft.inventory.container.Container) HorseInventoryContainer(net.minecraft.inventory.container.HorseInventoryContainer) SOpenHorseWindowPacket(net.minecraft.network.play.server.SOpenHorseWindowPacket) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) ContainerBridge(io.izzel.arclight.common.bridge.inventory.container.ContainerBridge) Overwrite(org.spongepowered.asm.mixin.Overwrite)

Aggregations

ContainerBridge (io.izzel.arclight.common.bridge.inventory.container.ContainerBridge)1 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)1 Container (net.minecraft.inventory.container.Container)1 HorseInventoryContainer (net.minecraft.inventory.container.HorseInventoryContainer)1 SOpenHorseWindowPacket (net.minecraft.network.play.server.SOpenHorseWindowPacket)1 Overwrite (org.spongepowered.asm.mixin.Overwrite)1