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

I got suggested that I should use a PacketHandler to open my GUI. Now I have no idea on how to open the gui in the PacketHandler, so I would require some help. I searched for some tutorials and explanations, but I can't realize what should I do.

 

The GUI has 1 button and 1 text input field. When you input a number in the field and click on the button, it will take the number and set the strength of the explosion.

 

Here's the action method for the button:

 

protected void actionPerformed(GuiButton button) {

	World world = null;
	WorldServer[] list = MinecraftServer.getServer().worldServers;

	/*switch (button.id) {
	case 1:
		i += 1;
		break;
	case 2:
		i -= 1;
	}
	*/
	// Packet code here
        // PaintEventDispatcher.sendPacketToServer(packet); //send packet

	for (WorldServer ins : list) {
		if (ins.provider.dimensionId == entity.worldObj.provider.dimensionId)
			world = ins;
	}
	if (world == null)
		world = list[0];

	if (button.id == 0) {

		if (true) {
			if (power.getText().isEmpty())
				power.setText("");
			else if (power.getText().matches("[a-zA-Z]+")) 
				power.setText("");
			else if (power.getText().matches("[0-9]+")) {
				this.mc.displayGuiScreen((GuiScreen) null);
				world.createExplosion((Entity) null, i, j - 10, k, Integer.parseInt(power.getText().trim()), true); 
			}
			else 
				power.setText("");
		}

	}

}

 

_         

___ ___| |__  _ __ 

/ __/ __| '_ \| '_ \

\__ \__ \ | | | | | |

|___/___/_| |_|_| |_|

First, you would create a packet handler etc. and register it. Then, you would create a packet that takes an integer (ID of the gui you want to open) as its data. When the packet is received, open up the GUI via the gui ID you sent.

We all stuff up sometimes... But I seem to be at the bottom of that pot.

Are you trying to open the gui on an entity, an item or a tileentity?

you would only have to use a packet for the strength of the explosion you've declared client sided in the gui's text input.

  • Author

I'm opening GUI on the block. Can any of you guys lead me to some source or examples?

_         

___ ___| |__  _ __ 

/ __/ __| '_ \| '_ \

\__ \__ \ | | | | | |

|___/___/_| |_|_| |_|

  • Author

With the PacketHandler

_         

___ ___| |__  _ __ 

/ __/ __| '_ \| '_ \

\__ \__ \ | | | | | |

|___/___/_| |_|_| |_|

Why do you need a PacketHandler if you can just use the onBlockActivated(args) method in the block class so if you click on the block in te world (not in the inventory) it opens the gui. If you wan't it to be in your inventory and right click it, you need a custom ItemBlock and use the onItemUse(args) method and open the gui in that method. If this doesn't match your needs, can you please specify where the block is, so we now what you wan't to do with the block.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

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.