Example usage for net.minecraftforge.fml.network NetworkDirection PLAY_TO_SERVER

List of usage examples for net.minecraftforge.fml.network NetworkDirection PLAY_TO_SERVER

Introduction

In this page you can find the example usage for net.minecraftforge.fml.network NetworkDirection PLAY_TO_SERVER.

Prototype

NetworkDirection PLAY_TO_SERVER

To view the source code for net.minecraftforge.fml.network NetworkDirection PLAY_TO_SERVER.

Click Source Link

Usage

From source file:com.teambrmodding.assistedprogression.network.packet.NotifyServerOfTrashBagChanges.java

License:Creative Commons License

/*******************************************************************************************************************
 * IMessageHandler                                                                                                 *
 *******************************************************************************************************************/

public static void process(NotifyServerOfTrashBagChanges message, Supplier<NetworkEvent.Context> ctx) {
    if (ctx.get().getDirection() == NetworkDirection.PLAY_TO_SERVER) {
        ServerPlayerEntity player = ctx.get().getSender();
        if (player.openContainer instanceof TrashBagContainer) {
            TrashBagContainer container = (TrashBagContainer) player.openContainer;
            container.trashBag.setTag(message.tag);
            container.detectAndSendChanges();
        }//from   www  . j ava 2s.c o  m
        ctx.get().setPacketHandled(true);
    }
}