Jump to content

[1.7.10] Gui without tileEntity?


Awesome_Spider

Recommended Posts

So I'm looking at a tutorial for gui's and it talks about TileEntities, Blocks, Containers, etc. But the thing is I don't want to create a gui based off a block. I want to create a gui that just simply opens when a button is pressed. I have the key bindings ready but I'm just confused at how to make a gui that doesn't use TileEntities and such. Could anyone point towards a good tutorial?

Link to comment
Share on other sites

Make your gui extend

GuiScreen

instead.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Yeah, I've been working a lot with custom block GUIs lately and I should probably write a tutorial.  Like the question in this thread, the first thing is to understand the gui needs to have a container/inventory and secondly whether it needs to have a tile entity associated with it.

 

Basically there are four possible scenarios:

1) Simple GUI without container or tile entity -- e.g. some sort of sign or simple information GUI that doesn't need player to put items in or out.

2) GUI with container but without tile entity -- if all the functionality of your GUI happens while the player is viewing the gui then you don't need a tile entity.  For example a crafting table.

3) GUI with container and tile entity -- if you need to have the block do functionality even while player is not in GUI, like how a furnace will cook/smelt over time, then you should use a tile entity.

4) GUI without container but with a tile entity -- like maybe a machine that you turn on in the GUI and then it continues to do something after you exit the GUI.

 

If you need an container then you need to associate it with something that implements IInventory.  That can either be a separate class, or can be the tile entity (if you have one).

 

Anyway, it sounds like you're just doing case #1.  For that you just need a GUI class and don't need a container or tile entity class.  Open the GUI just like you would in all cases -- in your block's onBlockActivated() method.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

Well, I'm actually doing more of situation #2, like a crafting table but without a block. It's a dismantler, an un-crafting table you might say.

 

That's funny because that's exactly what I spent the weekend making.  But yeah I didn't need a tile entity for it since like a crafting table the output was instantaneous.

 

Some of the tricky things to think about with an un-crafting table:

1) Some crafting recipes produce multiple of an item (like 3 paper) so when you're uncrafting you need to decide what to do.  Right now I have mine working so you have to put the same amount (or more) into the input for it to decraft.  But my kids want me to make some exceptions, for example a door  takes 6 wood to make 3 doors so they want 1 door to un-craft to 2 wood.  I haven't coded that yet because it gets tricky -- there are some multiples that wouldn't work to divide the input like railroad tracks. 

2) You need to consider the damage values in some cases -- like you want magenta dye to return the proper result different from the default dye.  But damage values are also used on tools and weapons and armor to reflect actual damage, so you need to think through how to code this carefully.

 

Once I get it working a bit better I might write a tutorial on an uncrafting table (I call it a "deconstructor").  But it sounds like you're taking the right approach.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

Cool, I haven't coded the gui yet because i'm trying to get the functionality first. Also, another thing to think about: You can make it so if other mods want to add an item to un-craft they can. They would have to be an extension to your mod though.

 

The way mine works so far is using hashmaps (I like HashMaps). Probably not the most efficient way, but I can get to making it more efficient when I release the mod. Anyway, the Dismantler, that's what I'm calling it, has a method that adds an Item and an ItemStack array to the hashmap. The item is the key, the itemstack array is the value. It also takes a modid parameter just in case there is a duplicate so it can throw an exception. That way, other mods can add their items. There is also a retrieve method which is where I add all the items that can be dismantled that are in my mod and vanilla using the adding method.

 

The reason why I use an itemstack array is because than I can specify how much of the item there is, so it can stack in the gui.

 

Confusing? Yes. Not the most efficient way? Maybe. Will it work? I have no idea. lol

Link to comment
Share on other sites

Oh and I haven't worked out damage values yet.

If the thing is a wooden pickaxe and its near close to being broken, try having a random chance and if it correct maybe have a random item, like a wooden plank or stick in this case is not given back or not give any of the items at all.

I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!

Link to comment
Share on other sites

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



×
×
  • Create New...

Important Information

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