Example usage for net.minecraftforge.fml.network NetworkHooks openGui

List of usage examples for net.minecraftforge.fml.network NetworkHooks openGui

Introduction

In this page you can find the example usage for net.minecraftforge.fml.network NetworkHooks openGui.

Prototype

public static void openGui(ServerPlayerEntity player, INamedContainerProvider containerSupplier) 

Source Link

Document

Request to open a GUI on the client, from the server Refer to net.minecraftforge.fml.ExtensionPoint#GUIFACTORY for how to provide a function to consume these GUI requests on the client.

Usage

From source file:com.teambrmodding.assistedprogression.common.item.TrashBagItem.java

License:Creative Commons License

/**
 * Called when this item is right clicked
 *///from www  .j  a  v a2  s  . c  om
@Override
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand) {
    if (!world.isRemote && hand == Hand.MAIN_HAND
            && player.getHeldItem(hand).getItem() instanceof TrashBagItem) {
        NetworkHooks.openGui((ServerPlayerEntity) player, (TrashBagItem) player.getHeldItem(hand).getItem());
        return new ActionResult<>(ActionResultType.SUCCESS, player.getHeldItem(hand));
    }
    return super.onItemRightClick(world, player, hand);
}