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,
        Consumer<PacketBuffer> extraDataWriter) 

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.block.BaseBlock.java

License:Creative Commons License

/**
 * Called when block is clicked, we will be using this to show the gui
 *///from  www. j av a2s . c  o  m
public boolean onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn,
        BlockRayTraceResult hit) {
    if (worldIn.isRemote) {
        return true;
    } else {
        TileEntity tileentity = worldIn.getTileEntity(pos);
        if (tileentity instanceof INamedContainerProvider) {
            INamedContainerProvider grinder = (INamedContainerProvider) tileentity;
            NetworkHooks.openGui((ServerPlayerEntity) player, grinder, pos);
        }
        return true;
    }
}