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

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

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.

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.