Jump to content

[1.10.2] Attempted to load class net/minecraft/client/gui/GuiScreen


Recommended Posts

Posted

I get an error about:

 

Attempted to load class net/minecraft/client/gui/GuiScreen for invalid side SERVER

 

I'm confuse while its happening, it's crashing on launch, not even when I use the item, I don't understand clearly why this happens.

 

package com.mramericanmike.bqt.items;

import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.world.World;
import betterquesting.client.gui.GuiHome;
import betterquesting.core.BetterQuesting;

import com.mramericanmike.bqt.ModInfo;

public class BQTItem extends Item {

public BQTItem(String name){

	this.maxStackSize = 1;
	this.setUnlocalizedName(ModInfo.MODID + ":" + name);
	this.setRegistryName(name);
	this.setCreativeTab(BetterQuesting.tabQuesting);

}


public ActionResult<ItemStack> onItemRightClick(ItemStack itemStack, World world, EntityPlayer player, EnumHand hand)
    {
	if(world.isRemote)
    	{
    		Minecraft mc = Minecraft.getMinecraft();
		mc.displayGuiScreen(new GuiHome(mc.currentScreen));
    	}

        return new ActionResult(EnumActionResult.PASS, itemStack);
    }

}

 

If I comment the line mc.displayGuiScreen(new GuiHome(mc.currentScreen)); server launchs, but I'm confuse on why this in happening or how to fix it.

Posted

Sorry that I answer myself, but playing around and looking at some code out there, I found out that:

 

	@SideOnly(Side.CLIENT)
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStack, World world, EntityPlayer player, EnumHand hand)
    {
    		Minecraft mc = Minecraft.getMinecraft();
		mc.displayGuiScreen(new GuiHome(mc.currentScreen));
    			
        return new ActionResult(EnumActionResult.PASS, itemStack);
    }

 

@SideOnly(Side.CLIENT) fixes the problem but....... Am  supposed to use that? I have heard that shouldn't be used, so I believe I'm still doing something wrng somewhere.

Posted

Sorry that = answer myself, but playing around and looking at some code out there, I found out that:

 

	@SideOnly(Side.CLIENT)
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStack, World world, EntityPlayer player, EnumHand hand)
    {
    		Minecraft mc = Minecraft.getMinecraft();
		mc.displayGuiScreen(new GuiHome(mc.currentScreen));
    			
        return new ActionResult(EnumActionResult.PASS, itemStack);
    }

 

@SideOnly(Side.CLIENT) fixes the problem but....... Am  supposed to use that? I have heard that shouldn't be used, so I believe I'm still doing something wrng somewhere.

You are fine to do that. As in it will not crash the game, but be aware that the server will default back to the super.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

http://www.minecraftforge.net/forum/index.php?topic=22764.0

 

You should be using a GUIHandler instead.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.