Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.

  • Author

I don't have a GuiHandler. Also To what should i change the modloader thingy then? To what do i need to add what :x?

 

I just started a few days ago with coding i don't know everything yet.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.