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

Hey so I'm having a little trouble with GUI buttons. I new to GUI and I can't seem to get this to work. I have the button set so that if the player has a poison effect and the button is pressed then it will remove the poison effect. I pressed the button and my players hearts turn from that green color back to a red but the poison effect doesn't actually get removed. This also happens if I try to apply invisibility, it shows the effect in the players inventory but the player isn't actually invisible. Any help would be greatly appreciated.

 

Here is the code in my GUI class that involves removing the potion effect:

 
        public void initGui()
{
this.buttonList.clear();

int posX = ((this.width - xSOT) / 2);
int posY = ((this.height - ySOT) / 2);

this.buttonList.add(new GuiButton(0, posX + 40, posY + 40, 100, 20, "Remove Posion" ));
}


public void actionPerformed(GuiButton button)
{

switch(button.id)
{
case 0: this.mc.thePlayer.removePotionEffect(Potion.poison.id);
}
}
[/Code]

I dont know if this would be different for buttons but I have an item that when right clicked removes all potion effects. Here is the code.

 

for(int i = 0; i <20; i++)
{
player.removePotionEffect(i);
}

 

This takes away the actual effect and the display on the side of the inventory GUI.

You can get rid of the for statement and just put in the number of the potion effect you want to remove. (Don't know what poison is off the top of my head)

 

  • Author

Yeah that won't for buttons like coolAlias said. I could just use your method but I'm gonna stick with packet's and GUI's so I can extend my knowledge of the two. Thanks for adding though.

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.