Search in sources :

Example 1 with IGuiButtonSensitive

use of com.bluepowermod.client.gui.IGuiButtonSensitive 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

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