Jump to content

ClientPlayerEntity cannot be cast to ServerPlayerEntity


RoggyMan01

Recommended Posts

I'm new to forge developing and I'm trying to make a custom tile entity for a mod, but when I right click the block, the game crashes. The error seems tobe here:
 

@Override
    public ActionResultType use(BlockState state, World worldIn, BlockPos pos,
                                PlayerEntity player, Hand handIn, BlockRayTraceResult hit) {
        if(worldIn.isClientSide()){
            TileEntity tileEntity = worldIn.getBlockEntity(pos);

            if(!player.isCrouching()){
                if(tileEntity instanceof BasicGemFusionBenchTile){
                    INamedContainerProvider containerProvider = createContainerProvider(worldIn,pos);

                    NetworkHooks.openGui(((ServerPlayerEntity)player), containerProvider, tileEntity.getBlockPos());
                }else {
                    throw new IllegalStateException("Our Container provider is missing");
                }
            }
        }



        return ActionResultType.SUCCESS;
    }

Could someone help me out?

Link to comment
Share on other sites

6 minutes ago, RoggyMan01 said:
if(worldIn.isClientSide()){

and then

6 minutes ago, RoggyMan01 said:
NetworkHooks.openGui(((ServerPlayerEntity)player), containerProvider, tileEntity.getBlockPos());

the error should be clear, also note you can't open a gui (Container) on the client

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.