Jump to content

Recommended Posts

Posted

I'm sure I'm doing something wrong but I can't find It. ps this is my first time using a gui

 

GuiScreen:

 

 

package com.example.gammacraft.gui;

import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;

public class CraftingTableGuiScreen extends GuiScreen {

public static int Guid;


public CraftingTableGuiScreen() {
	Guid=3;
}

public void drawBackground(int i){
	System.out.println("rendering gui:"+i);
}


}

 

 

 

GuiHandler:

 

 

package com.example.gammacraft.gui;

import com.example.gammacraft.containers.CraftingTableContainer;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import cpw.mods.fml.common.network.IGuiHandler;

public class GuiHandler implements IGuiHandler{

@Override
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {

	if(ID==CraftingTableGuiScreen.Guid){
		return new CraftingTableGuiScreen();
	}


	return null;

}

@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {

	if(ID==CraftingTableGuiScreen.Guid){
		return new CraftingTableContainer();
	}



	return null;
}

}

 

 

 

GuiHandler register:

NetworkRegistry.INSTANCE.registerGuiHandler(Instance, new GuiHandler());

 

openGui code in block class:

@Override
public boolean onBlockActivated(World world,int x,int y,int z,EntityPlayer player,int side,float hx,float hy,float hz{
player.openGui(gammacraft.Instance, 3, world, x, y, z);
return true;
}

 

I'm sure its just some stupid mistake that I can't find.

also this doesn't render anything, it just prints "render" in the console, but it doesn't do anything

The proud(ish) developer of Ancients

Posted

It's because you're not rendering anything. You're just printing it in the console.

 

It's working. You're just not doing anything.

-Mitchellbrine

 

Minecraft can do ANYTHING, it's coded in Java and you got the full power of Java behind you when you code. So nothing is impossible.

It may be freaking fucking hard though, but still possible ;)

 

If you create a topic on Modder Support, live by this motto:

I don't want your charity, I want your information
Posted

it just prints "render" in the console, but it doesn't do anything

-Mitchellbrine

 

Minecraft can do ANYTHING, it's coded in Java and you got the full power of Java behind you when you code. So nothing is impossible.

It may be freaking fucking hard though, but still possible ;)

 

If you create a topic on Modder Support, live by this motto:

I don't want your charity, I want your information
Posted

Mitchellbrine, that's what it's supposed to do, should've worded it better.

 

diedieten07, what do you mean the server can't access the class?

The proud(ish) developer of Ancients

Posted

The class is only accessed by the client.

 

Put your id in, say the GuiHandler class so it's accessible on both client and server.

-Mitchellbrine

 

Minecraft can do ANYTHING, it's coded in Java and you got the full power of Java behind you when you code. So nothing is impossible.

It may be freaking fucking hard though, but still possible ;)

 

If you create a topic on Modder Support, live by this motto:

I don't want your charity, I want your information
Posted

Ok I think I got it to work, it still doesn't print anything but it can pause the game when I right click. and unpause when I press esc. now I need to figure out how to render it.

The proud(ish) developer of Ancients

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.