Jump to content

Recommended Posts

Posted

Hello,

 

I'm developing a mod with 2 objects (1 Item, 1 block) and 2 very similar GUI.

 

Now when i right-click on my block with my item in hand i open a GUI to save the position of the block into a tagCompound of my Item, and instead when i right-click with my item at any part i open another GUI totally similar to the previous GUI.

 

The GUIs have 1 Title, 1 textfield and 2 buttons (OK and Cancel), this is the code:

 

 

 

package portalgates;

 

import net.minecraft.src.EntityClientPlayerMP;

import net.minecraft.src.EntityPlayer;

import net.minecraft.src.GuiButton;

import net.minecraft.src.GuiScreen;

import net.minecraft.src.GuiTextField;

import net.minecraft.src.Packet250CustomPayload;

import org.lwjgl.input.Keyboard;

import net.minecraft.src.ItemStack;

import net.minecraft.src.MovingObjectPosition;

import net.minecraft.src.NBTTagCompound;

import net.minecraft.src.World;

 

public class PortalPlateGui extends GuiScreen

{

    private String TITLE = "Portal Gate's Name";

    EntityPlayer entityPlayer;

    private GuiTextField txt_PortalName;

    private GuiButton btn_ok;

    private GuiButton btn_cancel;

 

    public PortalPlateGui(EntityPlayer var1)

    {

        this.entityPlayer = var1;

    }

 

    /**

    * Called from the main game loop to update the screen.

    */

    public void updateScreen()

    {

        this.txt_PortalName.updateCursorCounter();

    }

   

    /**

    * Adds the buttons (and other controls) to the screen in question.

    */

    public void initGui()

    {

        Keyboard.enableRepeatEvents(false);

        this.controlList.clear();

        int var1 = this.width / 2 + 100 - 80;

        int var2 = this.height / 2 + 50 - 24;

        this.btn_ok = new GuiButton(0, var1, var2, 60, 20, "OK");

        this.btn_ok.enabled = false;

        var1 = this.width / 2 - 100 + 20;

        var2 = this.height / 2 + 50 - 24;

        this.btn_cancel = new GuiButton(1, var1, var2, 60, 20, "Cancel");

        this.controlList.add(this.btn_ok);

        this.controlList.add(this.btn_cancel);

        var1 = this.width / 2 - 100;

        var2 = this.height / 2 - 50 + 47;

        this.txt_PortalName = new GuiTextField(this.fontRenderer, var1, var2, 200, 20);

        this.txt_PortalName.setFocused(true);

        this.txt_PortalName.setMaxStringLength(32);

    }

 

    /**

    * Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e).

    */

    protected void actionPerformed(GuiButton var1)

    {

        if (var1.enabled)

        {

            switch (var1.id)

            {

                case 0:

                    String var2 = this.txt_PortalName.getText().trim();

                    this.sendNewNameToServer(var2);

 

                case 1:

                    this.mc.displayGuiScreen((GuiScreen)null);

                    this.mc.setIngameFocus();

 

                default:

            }

        }

    }

 

    /**

    * Fired when a key is typed. This is the equivalent of KeyListener.keyTyped(KeyEvent e).

    */

    protected void keyTyped(char var1, int var2)

    {

        this.txt_PortalName.textboxKeyTyped(var1, var2);

        ((GuiButton)this.controlList.get(0)).enabled = this.txt_PortalName.getText().trim().length() > 0;

 

        if (var1 == 10)

        {

            this.actionPerformed((GuiButton)this.controlList.get(0));

        }

 

        if (Integer.valueOf(var1).intValue() == 27)

        {

            this.actionPerformed((GuiButton)this.controlList.get(1));

        }

    }

 

    /**

    * Called when the mouse is clicked.

    */

    protected void mouseClicked(int var1, int var2, int var3)

    {

        super.mouseClicked(var1, var2, var3);

        this.txt_PortalName.mouseClicked(var1, var2, var3);

    }

 

    /**

    * Draws the screen and all the components in it.

    */

    public void drawScreen(int var1, int var2, float var3)

    {

//    System.out.println(var1);

//    System.out.println(var2);

//    System.out.println(var3);

   

        this.drawDefaultBackground();

        this.drawGuiBackground();

        int var4 = this.width / 2 - this.fontRenderer.getStringWidth(this.TITLE) / 2;

        int var5 = this.height / 2 - 50 + 20;

        this.fontRenderer.drawStringWithShadow(this.TITLE, var4, var5, 0xff4040);

        var4 = this.width / 2 - 100;

        var5 = this.height / 2 - 50 + 35;

        //this.fontRenderer.drawString("New name:", var4, var5, 4210752);

        this.txt_PortalName.drawTextBox();

        super.drawScreen(var1, var2, var3);

    }

 

    protected void drawGuiBackground()

    {

        int var1 = this.mc.renderEngine.getTexture("/gui/guiportal.png");

        this.mc.renderEngine.bindTexture(var1);

        int var2 = (this.width - 100) / 2;

        int var3 = (this.height - 50) / 2;

        this.drawTexturedModalRect(var2 - 100 + 30, var3 - 50 + 30 + 5, 0, 0, 240, 100);

    }

 

    protected void sendNewNameToServer(String var1)

    {

        String var3 = (new String(var1)).trim();       

    }

}

 

 

 

In a new world i use all my objects without problems but when i esc and re-load my world MC goes to crash, randomly but most of the times, when i try to open a GUI with my Item in hand:

 

 

 

2012-12-23 01:05:09 [iNFO] [ForgeModLoader] Forge Mod Loader version 4.5.2.459 for Minecraft 1.4.5 loading

2012-12-23 01:05:10 [iNFO] [sTDOUT] 27 achievements

2012-12-23 01:05:11 [iNFO] [sTDOUT] 208 recipes

2012-12-23 01:05:11 [iNFO] [sTDOUT] Setting user: Player391, -

2012-12-23 01:05:11 [iNFO] [sTDERR] Client asked for parameter: server

2012-12-23 01:05:11 [iNFO] [sTDOUT] LWJGL Version: 2.4.2

2012-12-23 01:05:12 [iNFO] [ForgeModLoader] Attempting early MinecraftForge initialization

2012-12-23 01:05:12 [iNFO] [sTDOUT] MinecraftForge v6.4.1.411 Initialized

2012-12-23 01:05:12 [iNFO] [ForgeModLoader] MinecraftForge v6.4.1.411 Initialized

2012-12-23 01:05:12 [iNFO] [sTDOUT] Replaced 84 ore recipies

2012-12-23 01:05:12 [iNFO] [ForgeModLoader] Completed early MinecraftForge initialization

2012-12-23 01:05:12 [iNFO] [ForgeModLoader] Searching C:\Users\7ed\Desktop\MPC\jars\mods for mods

2012-12-23 01:05:13 [iNFO] [ForgeModLoader] Forge Mod Loader has identified 7 mods to load

2012-12-23 01:05:13 [iNFO] [ForgeModLoader] Configured a dormant chunk cache size of 0

2012-12-23 01:05:13 [iNFO] [sTDOUT] Custom Stack Limit: FILE PATH = C:\Users\7ed\Desktop\MPC\jars\config\stacking.properties

2012-12-23 01:05:13 [iNFO] [sTDOUT] Custom Stack Limit: READING CONFIG FILE

2012-12-23 01:05:14 [iNFO] [sTDOUT] Starting up SoundSystem...

2012-12-23 01:05:14 [iNFO] [sTDOUT] Initializing LWJGL OpenAL

2012-12-23 01:05:14 [iNFO] [sTDOUT]    (The LWJGL binding of OpenAL.  For more information, see http://www.lwjgl.org)

2012-12-23 01:05:14 [iNFO] [sTDOUT] OpenAL initialized.

2012-12-23 01:05:15 [iNFO] [ForgeModLoader] Forge Mod Loader has successfully loaded 7 mods

2012-12-23 01:05:18 [iNFO] [ForgeModLoader] Loading dimension 0 (New World) (net.minecraft.src.IntegratedServer@80cbba)

2012-12-23 01:05:18 [iNFO] [ForgeModLoader] Loading dimension 1 (New World) (net.minecraft.src.IntegratedServer@80cbba)

2012-12-23 01:05:18 [iNFO] [ForgeModLoader] Loading dimension -1 (New World) (net.minecraft.src.IntegratedServer@80cbba)

2012-12-23 01:05:24 [iNFO] [ForgeModLoader] Unloading dimension 0

2012-12-23 01:05:24 [iNFO] [ForgeModLoader] Unloading dimension -1

2012-12-23 01:05:24 [iNFO] [ForgeModLoader] Unloading dimension 1

2012-12-23 01:05:24 [iNFO] [sTDERR] net.minecraft.src.ReportedException: Rendering screen

2012-12-23 01:05:24 [iNFO] [sTDERR] at net.minecraft.src.EntityRenderer.updateCameraAndRender(EntityRenderer.java:986)

2012-12-23 01:05:24 [iNFO] [sTDERR] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:888)

2012-12-23 01:05:24 [iNFO] [sTDERR] at net.minecraft.client.Minecraft.run(Minecraft.java:783)

2012-12-23 01:05:24 [iNFO] [sTDERR] at java.lang.Thread.run(Unknown Source)

2012-12-23 01:05:24 [iNFO] [sTDERR] Caused by: java.lang.NullPointerException

2012-12-23 01:05:24 [iNFO] [sTDERR] at net.minecraft.src.GuiScreen.drawWorldBackground(GuiScreen.java:254)

2012-12-23 01:05:24 [iNFO] [sTDERR] at net.minecraft.src.GuiScreen.drawDefaultBackground(GuiScreen.java:249)

2012-12-23 01:05:24 [iNFO] [sTDERR] at portalgates.PortalGateGui.drawScreen(PortalGateGui.java:153)

2012-12-23 01:05:24 [iNFO] [sTDERR] at net.minecraft.src.EntityRenderer.updateCameraAndRender(EntityRenderer.java:977)

2012-12-23 01:05:24 [iNFO] [sTDERR] ... 3 more

2012-12-23 01:05:34 [iNFO] [sTDOUT] Stopping!

2012-12-23 01:05:34 [iNFO] [sTDOUT] SoundSystem shutting down...

2012-12-23 01:05:34 [iNFO] [sTDOUT]    Author: Paul Lamb, www.paulscode.com

2012-12-23 01:05:36 [iNFO] [sTDERR] Someone is closing me!

 

 

 

Sorry for my English but Please Help!

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Reach Out To Rapid Digital: What sapp Info: +1 41 4 80 7 14 85 Email INFO: rap iddi gita lrecov ery @ exe cs. com Hello, my name is Jayson, and I’m 35 years old from the United Kingdom. My family and I recently endured an incredibly challenging experience that I wouldn’t wish on anyone. We became victims of a cryptocurrency investment fraud scheme that saw us lose a staggering $807,000 in USDT and Bitcoins. The fraudsters had created a convincing facade, and we were lured into investing, only to discover later that the platform was a complete scam. We were left devastated, not just financially, but emotionally, as we had trusted these people and believed in the legitimacy of the investment. After the initial shock wore off, we desperately searched for ways to recover the lost funds. It seemed like an impossible task, and we felt as though there was no hope. That’s when, by sheer luck, we stumbled across a post about Rapid Digital Recovery, a cryptocurrency and funds recovery organization with a proven track record in cybersecurity and fraud recovery. We decided to reach out to them, and from the first interaction, we were impressed with their professionalism and transparency. They explained the recovery process in detail and reassured us that they had the skills and expertise to track down the perpetrators and recover our funds. This gave us a renewed sense of hope, something we hadn’t felt in months. What truly stood out during our experience with Rapid Digital Recovery was their dedication to the recovery process. The team went above and beyond, using sophisticated tracking tools and cyber forensics to gather critical information. Within a matter of weeks, they had successfully located the funds and traced the scam back to the fraudsters responsible. They worked with the authorities to ensure the criminals were held accountable for their actions. To our relief, the team at Rapid Digital Recovery was able to recover every single penny we had lost. The funds were returned in full, and the sense of closure we felt was invaluable. We couldn’t have imagined such a positive outcome in the early stages of our recovery journey, and we are deeply grateful for the work they did. If you ever find yourself in a similar situation, I highly recommend contacting Rapid Digital Recovery. Their expertise, transparency, and dedication to their clients make them the go-to choice for anyone seeking to recover lost cryptocurrency or funds. They truly gave us back our financial future.  
    • This is my first time modding anything, so maybe just skill issue. I'm using Forge 54.0.12 and Temurin 21.0.5+11-LTS I wanted to create a custom keybind and to check whether it works I'd like to send a chat message. I tried using Minecraft.getInstance().player.sendSystemMessage(Component.literal("test")); but IntelliJ couldnt resolve sendSystemMessage(...). Since I saw people using it in earlier versions, I tried the same thing with 1.20.6(- 50.1.0), where it works fine, now I can't figure out if this is intentional and whether there are other options for sending chat messages. On that note, is there more documentation than https://docs.minecraftforge.net/en/1.21.x/? It seems very incomplete compared to something like the Oracle Java docs
    • Hi, i'm having this error and I wanna fix it. we try: -Reload drivers -Eliminate .minecraft -Eliminate Java -Restart launcher -Verify if minecraft is using gpu -Mods  in .minecraft is empty -Install the latest and recomended version of forge idk what i have to do, help me pls. the lastest log is: https://mclo.gs/WAMao8x  
    • Read the FAQ, Rule #2. (https://forums.minecraftforge.net/topic/125488-rules-and-frequently-asked-questions-faq/)  
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.