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

Hello! The GUI i made is pausing the game(causing bugs) And i cant figure out how to make it stop pausing.

 

 

GUI code:

 

 

 package mod.gmod622.gui;

import java.util.Random;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiIngameMenu;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentData;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;

public class GUIenchanter extends GuiScreen
{
private World worldMC;
private EntityPlayer entityP;
private Minecraft mineC;
public static double rand;
private static Random random = new Random();

public GUIenchanter(World world, EntityPlayer entityplayer, Minecraft minecraft)
{
worldMC = world;
entityP = entityplayer;
mineC = minecraft;
}

public void initGui()
{
buttonList.add(new GuiButton(0, width / 2 - 50, height / 2 - 50, 200, 20, "Random Enchanted Book (30 lvls)"));
}
protected void actionPerformed(GuiButton guiButton)
{
if(guiButton.id == 0)
{

if(entityP.experienceLevel >= 30) {
	EnchantedBook(entityP);
       entityP.experienceLevel -= 30;
        
}

}
}

public static void EnchantedBook(EntityPlayer par3EntityPlayer)
{
             Enchantment enchantment = Enchantment.enchantmentsBookList[random.nextInt(Enchantment.enchantmentsBookList.length)];
    ItemStack itemstack = new ItemStack(Item.enchantedBook.itemID, 1, 0);
    int l = MathHelper.getRandomIntegerInRange(random, enchantment.getMinLevel(), enchantment.getMaxLevel());
   Item.enchantedBook.getEnchantedItemStack_do(itemstack, new EnchantmentData(enchantment, l));
par3EntityPlayer.inventory.addItemStackToInventory(itemstack);
}

} 

 

Not new to java >> New to modding.

The gui class contains a method to set if you want your gui to pause the game or not, the method looks like this

  public boolean doesGuiPauseGame()
    {
        return true;
    }

 

Just copy and paste that method into your gui file and change the value from true to false, and you should be all good.

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.