Jump to content

Open a Gui specifically for an instance of an entity - i.e managing inventories.


Recommended Posts

Posted

Hi there;

 

I can't for the life of me figure out how to open gui's for non-tile entity entities.

I'm sure I'm being rather dumb in this, but I was wondering if someone could shed some light on how to do this?

I'm calling the gui like so:

player.openGui(Teo_Main.instance, Teo_GuiInventory.ID, world, (int)player.posX, (int)player.posY, (int)player.posZ);

 

Also being unable to "locate" the entity means I can't display the gui, as the inventory of the entity obviously changes between instances of the entity, hence I need to pass in the player and entity inventory.

 

I've looked in the player classes; the player uses displayGuiWhatever, I've also tried opening the gui with ye olde modloader method:

ModLoader.openGUI(player, new GuiMLBPegasus());

I've even tried FMLClientHandler's:

FMLClientHandler.instance().displayGuiScreen(player, gui);

 

I've also checked EntityMinecart, but that's just a glorified player.displayGuiScreen method.

 

To no avail. I'm sure it's something very stupidly easy. If it was a tile entity, it would be a lot simpler :D Could someone point me in the right direction?

Thanks in advance.

Posted

What are you exactly trying to accomplish that doesn't work for you?

Calling displayGuiScreen does nothing more than just display a gui screen. What this gui screen then displays is up to its own implementation.

 

Are you having problems displaying a gui screen? Cause calling displayGuiScreen should work fine.

Any logic past that has nothing to do with displaying the gui screen and should be handled in the actual implementation of the gui.

 

So for a custom inventory screen I'd imagine you'd just want to call displayGuiScreen, but your GuiMLBPegasus() constructor probably should contain an argument for the inventory object, so it can access it and display its contents.

Posted

What's in the gui screens has been fine since I first added them in 1.2.something. My issue is that the screens themselves aren't showing, for some reason. I couldn't call vanilla screens either, when attempting to do so just to check I wasn't going insane

 

EDIT: I just tried opening both GuiWinGame() and GuiInventory() (using FMLClientHandler.displayGuiScreen()) as an example of a screen which *should* open, and they didn't work either.

 

Potentially useful info: I'm using FML version 3.0.150.334. No errors were thrown when I try call a gui screen; rather, they just don't appear.

 

Edit num2:

Okay, so after hunting down the trail of displayGuiScreen to it's declaration in FMLClientHandler, it appears to be working if I call the method without FMLClientHandler - that is, (where mc == ModLoader.getMinecraftInstance();), with mc.displayGuiScreen(). I'm not sure why FMLClientHandler doesn't work for me, but for the moment, at least gui's are actually showing.

Posted

Strange. What build of Forge are you using?

I'm on FML 3.0.98.304 / Forge 4.0.0.217 and calling this works perfectly fine:

FMLClientHandler.instance().displayGuiScreen(entityPlayer, new FireCraftGuiClassChange());

Posted

I'm using Forge version 4.0.0.232, if I recall correctly. It's very weird, no? I even copy&pasted your code (replacing the gui class), and it didn't work - so it's definitely not my typing ><

 

Interestingly again, it was working, but now I get errors in vanilla minecraft classes when opening the guis. (not even a mention of any of my classes, or FML/Forge classes).

 

I think I'll use Forge Version 217, and see if that fixes things.

 

Edit: Just tried it with forge 217, it didn't make any difference to FMLClientHandler. It's rather frustrating that I'm getting given no error messages.

 

I'm gonna redownload everything, and see if that helps.

Posted

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Posted

 

The issue is that (at least it would appear that) you can't call a gui with parameters to acquire the instance of a specific entity - I'm perfectly aware that that's how it should be done, but how do you grab the instance of the entity the player is interacting with? If it was a tile entity, yes, you could simply do

TileEntity te = world.getBlockTileEntity(x, y, z);

and then check it's an instance of your own tile entity, and that's fine, but from what i've seen, there's no way to get a specific instance of a mob entity. I suppose you could use world.getEntitiesWithinAABB, and check for instances of the mob, but that would mess up if there was more than one instance of the mob.

 

Which is why I looked into EntityMinecart, but that uses EntityPlayer's displaychest method.

Posted

Whats stopping you from using the EntityID?

 

As the ID parameter in player.openGui()? If yes, it sounds like I wouldn't be able to have multiple gui's...Unless I was to make a meta-gui, I suppose.

 

Or am I being incredibly stupid?

Posted

You do realize

That x/y/z

Are nothing more then ints

...

that are sent to your client function...

They can be whatever the fuck you want.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Posted

You do realize

That x/y/z

Are nothing more then ints

...

that are sent to your client function...

They can be whatever the fuck you want.

 

[me=Teotoo]facepalms[/me]

Wow. How'd I miss that. Thanks!

  • 4 months later...
Posted

Ooooh ok, I didn't undertand the reply, i got it, you can give the entityId by passing it as one of the int parameters!

 

Sorry for disturbing and thanks for reply.

If yo want to say thanks, push the button!

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

    • Hi all,  I have the following issue: I'd like to parse some json using gson and rely on the (somewhat new) java record types. This is supported in gson 2.10+. Gson is already a dependency used by minecraft, however it's 2.8.x for 1.19.2 which I'm targeting at the moment. My idea was to include the newer version of the library in my mod and then shadow it so it gets used inside the scope of my mod instead of the older 2.8. This works fine for building the jar: If I decompile my mod.jar, I can see that it's correctly using the shadowed classes. However obviously when using the runClient intellj config, the shadowing doesn't get invoked. Is there any way of invoking shadow when using runClient, or am I on the wrong track and there's a better way of doing this entirely? Thanks in advance!
    • Yep I did upgrade just because it showed me a new version available.  I'll redownload the mod list and make sure anything works.  Thanks!
    • The latest log was taken down by pastebin for some reason. Did you try removing the mods you added? The mods you updated, was there a specific reason you updated, or just because? It's possible the updates introduced incompatibilitie, or even need a newer build of forge. If you didn't need the updates for a specific reason, you could also try downgrading those mods.
    • Please read the FAQ, and post logs as described there. https://forums.minecraftforge.net/topic/125488-rules-and-frequently-asked-questions-faq/
    • I am using forge 1.20.1 (version 47.3.0). My pc has an RTX 4080 super and an i9 14900 KF, I am on the latest Nvidia graphics driver, latest windows 10 software, I have java 23, forge 1.12.2 works and so does all vanilla versions but for some reason no version of forge 1.20.1 works and instead the game just crashes with the error code "-1." I have no mods in my mods fodler, I have deleted my options.txt and forge.cfg files in case my settings were causing a crash and have tried removing my forge version from the installations folder and reinstalling but no matter what I still crash with the same code and my log doesn't tell me anything: 18:34:53.924 game 2025-02-06 18:34:53,914 main WARN Advanced terminal features are not available in this environment 18:34:54.023 game [18:34:54] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher running: args [--username, mrmirchi, --version, 1.20.1-forge-47.3.0, --gameDir, C:\Users\aryam\AppData\Roaming\.minecraft, --assetsDir, C:\Users\aryam\AppData\Roaming\.minecraft\assets, --assetIndex, 5, --uuid, 2db00ea8d678420a8956109a85d90e9d, --accessToken, ????????, --clientId, ZWI3NThkNzMtNmNlZS00MGI5LTgyZTgtYmZkNzcwMTM5MGMx, --xuid, 2535436222989555, --userType, msa, --versionType, release, --quickPlayPath, C:\Users\aryam\AppData\Roaming\.minecraft\quickPlay\java\1738838092785.json, --launchTarget, forgeclient, --fml.forgeVersion, 47.3.0, --fml.mcVersion, 1.20.1, --fml.forgeGroup, net.minecraftforge, --fml.mcpVersion, 20230612.114412] 18:34:54.027 game [18:34:54] [main/INFO] [cp.mo.mo.Launcher/MODLAUNCHER]: ModLauncher 10.0.9+10.0.9+main.dcd20f30 starting: java version 17.0.8 by Microsoft; OS Windows 10 arch amd64 version 10.0 18:34:54.132 game [18:34:54] [main/INFO] [ne.mi.fm.lo.ImmediateWindowHandler/]: Loading ImmediateWindowProvider fmlearlywindow 18:34:54.191 game [18:34:54] [main/INFO] [EARLYDISPLAY/]: Trying GL version 4.6 18:34:54.303 game [18:34:54] [main/INFO] [EARLYDISPLAY/]: Requested GL version 4.6 got version 4.6 18:34:54.367 monitor Process Monitor Process crashed with exit code -1     screenshot of log: https://drive.google.com/file/d/1WdkH88H865XErvmIqAKjlg7yrmj8EYy7/view?usp=sharing
  • Topics

×
×
  • Create New...

Important Information

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