Jump to content

Do I need to learn about Tile Entities?


kauan99

Recommended Posts

Hello! (First of all, pardon my English)

 

Again, I'm sorry if this is a dumb question (I'm sure it is). I'm new to mod coding and programing (specially Java). And I'm definetly also sorry for this not being an objective question about a practical problem. I understand too little about the problem to even formulate a proper objective question on it.

 

I have this idea of creating and engine. It would run on coal and water (or maybe I'll come up with something else to power it), and it would output a different kind of energy than that of redstone circuits. I'd use it to power other things, like a grinder for example (a block-like thing with an inventory similar to the one of a furnace, but without the coal slot. I'd input something like, say, an emerald, and it would output emerald dust), and maybe even vehicles.

 

I'm not sure if it's even possible. Is more like a wild dream. Looking around the tutorials, the minecraft classes and google I began to think that for me to even begin to conceive how to implement that, I'd have to learn about NBT (whatever that is), Containers, GUI, Tile Entities, and probably much more.

 

Is that true? Or could I just make up a few blocks and add fields to them to handle their logic and I'd be done...?

 

There are no complete tutorials on those subjects and the incomplete ones are outdatted and obscure and they just made things worse (I wish I never learned about the existence of such beasts such as Tile Entities).

 

In short: is it possible to live without learning about NBT and Tile Entities, etc and still be able to code neat mods with stuff like the aforementioned engine and grinder? (Forget about the vehicles, that's probably going too far). And if I absolutely must learn those things to code decent mods, where do I find tutorials in a style more like "Tile Entities and NBT For Dummies"?

 

Thanks for any comments!!

WIP mods: easyautomation, easyenergy, easyelectronics, easymoney, easytrasportation, easysecurity, easymultiverse, easyfactions, easymagick, easyalchemy, easyseasons

Link to comment
Share on other sites

To begin with, from all the sorts of mods, You have chosen a tough one. A really tough one.

I find creating simple items much easier for beginners. I think that unless You are really, really curious, and really, really stubborn, you will be discouraged and You will quit.

 

I'd recommend doing something simpler for now - adding a new weapon or tool for instance.

 

Anyway

 

NBT doesn't bite. It simply stores additional information about something in save files. It is possible to live without NBT though - if you don't use it, SOME changes will be simply lost when You quit the game - which isn't necessary a big tragedy (for example - if furnace didn't use NBT and You would quit the game in the middle of smelting, this progress wouldn't be saved, as well as the furnace inventory.)

 

There are less tutorials than possibilities - there always will be so. But one of the methods of dealing with this inconvenience is observing Vanilla classes which You think have something in common with what You have in mind and mimicking them.

 

Tile Entities - You will need them. Along with Your block, you will have to create a class called TileEntityEngine ,

which will remember if coal and water is present in the engine and will do whatever engine does in it's onUpdate method. Your block will have to have createTileEntity method and it's hasTileEntity method will have to return true. 

 

And for the second type of redstone.. You will have to do a lot of copying and pasting.

 

There's API called Universal Electricity - if You really want non-redstone electricity, I would rather try to learn Universal Electricity API and write Universal Electricity mod. But then - I think it's two levels too hard for a complete beginner.

 

Become a non-complete beginner first, than try again.

Link to comment
Share on other sites

Hehe I must say I like your post mate :)

The TL;DR is: Yes!

 

The real and long answer(s):

 

The idea you have is interesting and cool and totally possible to do.

When it comes to tutorials they are aimed at the basic stuff, the advance stuff is lacking some information and to be honest part of programming is inventing the logic behind mechanics and reading documentation to understand other people's code.

 

I would suggest that you try to actively learn Java more than you learn to modd with forge first, as it's much faster and easier than the other way around :)

Some sources to look at for Learning Java can be found here:

 

 

Short videos of concepts gradually teaching Java basics: http://thenewboston.org/list.php?cat=31

CS106a - Free lectures from Standford with all materials you need including software and assignments!!! The CS106 is meant to bring absolute java beginners into programming and I highly recommend ithttp://see.stanford.edu/see/lecturelist.aspx?coll=824a47e1-135f-4508-a5aa-866adcae1111

 

 

You will need to learn about Container's and GUI's, TE's(Tile Entity's <-- you will love these!) and NBT yeah!

Also you will need to learn about Server<->Client communications, packet handling and much more :)

 

But don't get discouraged now, there is a lot of material and people out there to help you :)

I'm going to give you a nice start by telling you about the things you mentioned and suggest some things you can read, like a small reading list if you will :)

 

Containers are well they are things that contain stuff :P duh!

No but seriously they are responsible for containing and managing slots inn which Items can be placed.

So the container has the logic for letting you increase and decrease the items inside a stack inside the inventory/crafting bench/chest/etc. They are quite easy to learn to use :)

 

GUI's, well they are all the screens you see, like the inventory window and the Chest window etc.

If the GUI is going to handle items being moved around in an inventory, then it's a GuiContainer type of GUI, which adds some functionality to deal with items and containers :) If it's not a GuiContainer it's usually just a GuiScreen. Anyways GUI's are fun to work with once you get the hang of it, and  if you unlike me like drawing stuff then you will have quite a fun time experimenting with GUI's :D

 

NBT's or Named Binary Tag is a special format which was made to store information to disk in an easy way.

NBT is simply put a set of methods that allow you to save and load the state of your TileEntitys, Entitys and so on between game sessions. So that you're self-made furnace keeps it's inventory after you restart Minecraft :)

You can store different types of values via NBT and when you store an value you give it an identifier/name which you later use inn code to retrieve the data upon load :)

 

Tile Entity's

Did you know that at any given xyz location of the world there is not a block but an int BlockID?

The Block's them self's are not stored inn the world, only their ID's. The blocks have no memory of anything except the little they get from the metadata assosiated with the block at that xyz position. And metadata can only small amounts of information so how can a chestBlock store hundreds of items? The solution is TileEntity's! They are the ones where you will store ALL your information related to your special blocks, and the place where all the logic is done :)

 

If you are curios about TE's you could go into the code and check out BlockFurnace and TileEntityFurnace, atleast you can see that the logic of smelting and everything is handled by the TE.

TE's are not as scary as they sound, it's just all the logic and memory the block should have by it self moved into a different class :)

 

 

Some last words and links

If you haven't already I suggest you read http://www.minecraftforge.net/wiki/Basic_Modding before you start modding with forge, it will help you setup the essential files every mod needs :)

And you can keep following that to learn about implementing items and blocks.

From there on, you can play around with new tools and armor before you move on to GUI's and Containers, which also will be a nice introduction to TE's.

A project with GUI, Container and TE's I think there are several tutorials for out there is Custom Furnace, just google for around and it's inn the top hits :)

 

After that it depends on how well you are doing and what you want, either way looking at tutorials on youtube, forge wiki and minecraft forums is a good idea. Just make sure to only follow FORGE tutorials, since ModLoader doesn't work on SMP nor does it follow the same form as forge when it comes to code :)

 

Well that's it for me, at this time :) I really hope you do learn some java fundamentals before embarking on the modding journey, else it will be so much harder than it needs to <3

 

Edit: Fuck I managed to post before I was done writing. Updated and fixed now :)

Edit2: PS: Holy cow this got quite long, sorry for the wall of text.. but Hey you could have just read the TL;DR at the top ;)

If you guys dont get it.. then well ya.. try harder...

Link to comment
Share on other sites

Thank you very much! You both helped a lot! I have a much better understanding on all those things after reading your posts than I had after reading a whole bunch of tutorials (I'm even gonna ctrl+D this thread). I will start small, as Senitiel said, but I'll try to incorporate TileEntities, Containers and NBT from the begining. Building something simple, that has an inventory and needs to keep its state between sessions.

 

Those brief descriptions Mazetar gave me on Containers, NBT and GUI's were awesome. Now I know what to look for and where I'm going to.

 

I never imagined I could learn so much by asking such an abstract question. Again, thanks a lot, you guys!

WIP mods: easyautomation, easyenergy, easyelectronics, easymoney, easytrasportation, easysecurity, easymultiverse, easyfactions, easymagick, easyalchemy, easyseasons

Link to comment
Share on other sites

Well you didn't just ask an abstract question, you where forthcoming and honest telling us what you're goals are and what level you are at and you where polite. That makes the odds of getting a useful reply quite good ;)

 

Don't start with NBT's from the start. Start smaller, with just a block and an item and go from there.

After getting a furnace or something working you will get the need for NBT's to save it's state between game sessions, which will naturally lead to you having to implement it :)

Trying to implement all this from the start can be frustrating and overwhelming, and god knows programming can be that without us adding to it ;)

 

Good luck on your adventures into programming, and remember that you can always ask questions :)

If you guys dont get it.. then well ya.. try harder...

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.