Jump to content

A mod tried to open a gui on the server without being a NetworkMod


kev30

Recommended Posts

So i'm trying to create a chest but i'm keep getting this error.

A mod tried to open a gui on the server without being a NetworkMod

 

 

Main file

	public void load(FMLInitializationEvent event) {
      ModLoader.registerContainerID(this, 30);	  
     Block crest = new crest(1999, Material.wood).setUnlocalizedName("Crest"); 
	GameRegistry.registerBlock(crest, "crest");
	LanguageRegistry.addName(crest, "Chest");		
	GameRegistry.addRecipe(new ItemStack(crest, 1), new Object [] {
		"012", "345", "678", 
		Character.valueOf('0'), new ItemStack(Block.stone, 1), 
		Character.valueOf('1'), new ItemStack(Block.stone, 1), 
		Character.valueOf('2'), new ItemStack(Block.stone, 1),
		Character.valueOf('3'), new ItemStack(Block.stone, 1), 
		Character.valueOf('4'), new ItemStack(Block.stone, 1), 
		Character.valueOf('5'), new ItemStack(Block.stone, 1), 
		Character.valueOf('6'), new ItemStack(Block.stone, 1), 
		Character.valueOf('7'), new ItemStack(Block.stone, 1), 
		Character.valueOf('8'), new ItemStack(Block.stone, 1)
	});	
}

 

GUI

@SideOnly(Side.CLIENT)
public class Guicrest extends GuiContainer{

public Guicrest(InventoryPlayer inventory, int x, int y, int z) {
	super(new ContainerCrest());
}

protected void drawContainerForegroundLayer(int par1, int par2) {
	this.fontRenderer.drawString("Crest", 0, 0, 4210752);
	this.fontRenderer.drawString("Inventory", 0, 0, 4210752);
}


//declare your variables
private static final ResourceLocation field_110410_t = new ResourceLocation("compitem:textures/gui/container/generic_54.png");


protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
	GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
	this.mc.renderEngine.func_110577_a(field_110410_t);

	this.xSize = 212;
	this.ySize = 222;
}
}

 

block file

	@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister par1IconRegister){
	 this.blockIcon = par1IconRegister.registerIcon("stone.texturePath");
}

@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int i, float a, float b, float c) {
	if(!world.isRemote){
		FMLNetworkHandler.openGui(player, new ContainerCrest(), 30, world, x, y, z);
	}else{
		ModLoader.openGUI((EntityPlayerSP) player, new Guicrest(player.inventory, x, y, z));
	}

	return true;
}

public TileEntity createNewTileEntity(World par1World) {
	return new TileEntitycrest();

}

 

I'm a beginner in coding and trying to learn how to create a mod. I have been coding now for a few days and this is just a error that i could not fix.

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.