Search in sources :

Example 1 with Container

use of net.minecraft.inventory.container.Container in project BluePower by Qmunity.

the class MessageCraftingSync method handle.

public static void handle(MessageCraftingSync msg, Supplier<NetworkEvent.Context> contextSupplier) {
    NetworkEvent.Context context = contextSupplier.get();
    context.enqueueWork(() -> {
        ServerPlayerEntity player = context.getSender();
        if (player != null) {
            Container container = player.containerMenu;
            if (container != null) {
                container.slotsChanged(null);
            }
        }
    });
    contextSupplier.get().setPacketHandled(true);
}
Also used : Container(net.minecraft.inventory.container.Container) NetworkEvent(net.minecraftforge.fml.network.NetworkEvent) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity)

Example 2 with Container

use of net.minecraft.inventory.container.Container in project BluePower by Qmunity.

the class MessageGuiUpdate method handle.

public static void handle(MessageGuiUpdate msg, Supplier<NetworkEvent.Context> contextSupplier) {
    NetworkEvent.Context context = contextSupplier.get();
    context.enqueueWork(() -> {
        ServerPlayerEntity player = context.getSender();
        if (player == null) {
            return;
        }
        Container container = player.containerMenu;
        if (container instanceof IGuiButtonSensitive) {
            ((IGuiButtonSensitive) container).onButtonPress(player, msg.messageId, msg.value);
        }
    });
    contextSupplier.get().setPacketHandled(true);
}
Also used : Container(net.minecraft.inventory.container.Container) IGuiButtonSensitive(com.bluepowermod.client.gui.IGuiButtonSensitive) NetworkEvent(net.minecraftforge.fml.network.NetworkEvent) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity)

Aggregations

ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)2 Container (net.minecraft.inventory.container.Container)2 NetworkEvent (net.minecraftforge.fml.network.NetworkEvent)2 IGuiButtonSensitive (com.bluepowermod.client.gui.IGuiButtonSensitive)1