Jump to content

[1.10] GuiScreen Bugs


Darki

Recommended Posts

So hi everyone,

At the moment I try to make a realistic mod therefore I make a character builder, but I have 2 Bugs. First of all the Class:

GuiScreen:

public class CharacterBuilder extends GuiScreen{

private GuiButtonExt bOk = new GuiButtonExt(0, width / 2 - 50, height / 2 + 5, 100, 20, "Start");

@Override
public void initGui() {
	buttonList.add(bOk);
}

@Override
protected void actionPerformed(GuiButton button) throws IOException {
	if(button == bOk){
		mc.displayGuiScreen((GuiScreen)null);
	}
	super.actionPerformed(button);
}

@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
	drawDefaultBackground();
	super.drawScreen(mouseX, mouseY, partialTicks);
}

}

Now the First Bug:

I made a Ok Button this Button should close the GuiScreen but it wont be closed when you click the button.

Second Bug:

I tried to open the Screen when you join a world but the Screen wont be opened. Here the JoinEvent:

	@SubscribeEvent
public void onJoin(EntityJoinWorldEvent e){
	if(e.getEntity() instanceof EntityPlayer){
		EntityPlayer player = (EntityPlayer) e.getEntity();
		Minecraft.getMinecraft().displayGuiScreen(new CharacterBuilder());
	}
}

The Event will called andMinecraft.getMinecraft().displayGuiScreen(new CharacterBuilder()); will be called too.

Link to comment
Share on other sites

So hi everyone,

At the moment I try to make a realistic mod therefore I make a character builder, but I have 2 Bugs. First of all the Class:

GuiScreen:

public class CharacterBuilder extends GuiScreen{

private GuiButtonExt bOk = new GuiButtonExt(0, width / 2 - 50, height / 2 + 5, 100, 20, "Start");

@Override
public void initGui() {
	buttonList.add(bOk);
}

@Override
protected void actionPerformed(GuiButton button) throws IOException {
	if(button == bOk){
		mc.displayGuiScreen((GuiScreen)null);
	}
	super.actionPerformed(button);
}

@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
	drawDefaultBackground();
	super.drawScreen(mouseX, mouseY, partialTicks);
}

}

Now the First Bug:

I made a Ok Button this Button should close the GuiScreen but it wont be closed when you click the button.

Second Bug:

I tried to open the Screen when you join a world but the Screen wont be opened. Here the JoinEvent:

	@SubscribeEvent
public void onJoin(EntityJoinWorldEvent e){
	if(e.getEntity() instanceof EntityPlayer){
		EntityPlayer player = (EntityPlayer) e.getEntity();
		Minecraft.getMinecraft().displayGuiScreen(new CharacterBuilder());
	}
}

The Event will called andMinecraft.getMinecraft().displayGuiScreen(new CharacterBuilder()); will be called too.

 

1. Don't compare the raw objects in actionPerformed, compare their IDs (button.id).

 

2. I believe that entities are spawned solely on the server, which is why your GUI won't show up (GUIs are client-side). You might be able to send a packet to the client, or use a different event that you can use to emulate a player joining the world. Here is a list of pretty much all (there may be a few missing) the forge events. One of them might be fired on both server and client (or just client) that you can use: https://dl.dropboxusercontent.com/s/h777x7ugherqs0w/forgeevents.html

Link to comment
Share on other sites

2. I believe that entities are spawned solely on the server, which is why your GUI won't show up (GUIs are client-side). You might be able to send a packet to the client, or use a different event that you can use to emulate a player joining the world. Here is a list of pretty much all (there may be a few missing) the forge events. One of them might be fired on both server and client (or just client) that you can use: https://dl.dropboxusercontent.com/s/h777x7ugherqs0w/forgeevents.html

 

Incorrect.  Entities do indeed spawn client side (that's how you can see them).

However, that is not how you should be displaying a GUI, for one because it uses Client Side Only code inside a Common Code method.  For two, you need a GUI handler.

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.

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.