Jump to content

How to find out things by yourself.


alvitawa

Recommended Posts

So for instance, I now want to create an always-on-top gui(like the health hearts or hunger bar). And as always, I can't figure out how to do anything unless there is a tutorial for it. Let's say you want to make what I said, how would you find out how to do it?

Link to comment
Share on other sites

Look at Minecraft code that does something close to what you want to achieve.

You will often be able to subclass an existing class this way.

 

Otherwise look at the source code of Mods that do something similar.

 

That's how I proceed :)

 

Thank you, that's something at least, but what if it's something no one has never done?

Link to comment
Share on other sites

Look at Minecraft code that does something close to what you want to achieve.

You will often be able to subclass an existing class this way.

 

Otherwise look at the source code of Mods that do something similar.

 

That's how I proceed :)

 

Thank you, that's something at least, but what if it's something no one has never done?

Then you study the minecraft code and learn java.

If I helped please press the Thank You button.

Link to comment
Share on other sites

Look at Minecraft code that does something close to what you want to achieve.

You will often be able to subclass an existing class this way.

 

Otherwise look at the source code of Mods that do something similar.

 

That's how I proceed :)

 

Thank you, that's something at least, but what if it's something no one has never done?

 

It is clear that you have never really programmed anything else except minecraft before, or minecraft seriously for that matter. But I applaud you that you're willing to take the effort, many "modders" are sadly stuck in the tutorial stage.

 

Finding how to do something, or we can coin the term problem solving, is one of the major parts of writing code. Or rather it is the most important thing, even more so than written transparent code, writing code according to the standard, understanding different principles and being able to apply them.

Let us, for convenience sake take a simple example: a minecraft tree.

 

Making a minecraft tree is simple, we can easily find tutorials on it and minecraft has trees.

But let us start a thinking process:

 

What do we want to create? A minecraft tree, that's simple. OK. But what do we need to create that minecraft tree? Well, since it is minecraft we'll need blocks for that tree. Well, do we want to create new ones or do we want to reuse blocks? Well, lets create them. How many do we need? Looking at the other tree examples we'll need two. Let's create them. Generally one would follow the minecraft way here so knowing or having tutorial is handy. Well once those two blocks are created we can proceed. Well, what now? We have our two blocks what do we do with them? It's simple really, we place them in the world. But how do we do that? Well, generally we'll want a tree class, a class that's specific for our tree, so we'll define how it'll look and what it'll do in that class. Once we are in our class we can proceed with placing them. We want to place a tree anywhere we can so we'll want a method and the code to place it inside. And then it is a simple matter of calling the parWorld.setBlock command with the correct id and location( base location xyz + or - value). Something which has been created for us, if it hasn't we'll have to create a method or class that can do that etc. However, we still need to be able to be called by the minecraft code, so have a look at the examples, ah, they inherit a class. Because they inherit it is best to inherit that as well. And so on and on and on.

 

In reality one would look first at the examples and try to copy them as close as possible so as to not run into problems you shouldn't run into.

If there are no examples, e.g. you are writing your own application, it is best to look at it structurally, what do I want, what do I need for that and how will I do it.

And it helps writing it out on paper if you're not fluent with it. The same for code, both even have several types of diagrams to help people structurize and ease programming and example for logical thinking is a flow chart, and example for coding is a Nassi–Shneiderman diagram.

 

Once you are more advanced (I say more but really every single experience or thing you learn changes how you program) you will notice those things more easily.

It's like learning to be a butcher. Let's say you have a cow in front of you, well if you've never done it before or are still learning you'll need to think. Where to cut best not to spoil the meat for instance. A professional butcher doesn't need to thing, he knows that if he cuts there it'll be good.

The same applies to programming. Take our previous example for instance, we put a setblock line everytime we wanted to place a block. A programmer who's more at ease with the code will use for loop since clearly if you want to place 10 identical blocks in one line then there has to be a better way to do so.

 

In general it comes down to you trying things out, make a tree from a tutorial then create a tree on your own, then add an extra block to that tree, then make it sparkle etc.

And I would also suggest looking up java tutorials, it'll introduce new techniques to you and you'll be far more flexible. This will show in your logical thinking and in your code. And even, in life outside coding(does that even exist?) you'll find applications because if the next time you have an art history exam with a difficult question you'll say: What do I want? What do I need for that? And how will I do it? You'll set your pen on the paper and start writing List<? extends AnswerInMyBrain> Answer = new Answer(); And it'll throw an error...

Link to comment
Share on other sites

I do know java, I have read through most of the official tutorials. When I see something in minecraft like abstract class or inherit Blablabla I know what it means, I have also programmed quite a lot in ahk and done some random java stuff. But modding is something new to me, I mean programming "inside" of another program, wich I am not alowed to edit etc...

 

Look at Minecraft code that does something close to what you want to achieve.

You will often be able to subclass an existing class this way.

 

Otherwise look at the source code of Mods that do something similar.

 

That's how I proceed :)

 

Thank you, that's something at least, but what if it's something no one has never done?

 

It is clear that you have never really programmed anything else except minecraft before, or minecraft seriously for that matter. But I applaud you that you're willing to take the effort, many "modders" are sadly stuck in the tutorial stage.

 

Finding how to do something, or we can coin the term problem solving, is one of the major parts of writing code. Or rather it is the most important thing ...

 

... new techniques to you and you'll be far more flexible. This will show in your logical thinking and in your code. And even, in life outside coding(does that even exist?) you'll find applications because if the next time you have an art history exam with a difficult question you'll say: What do I want? What do I need for that? And how will I do it? You'll set your pen on the paper and start writing List<? extends AnswerInMyBrain> Answer = new Answer(); And it'll throw an error...

 

Thank you for your reply :) I hope I come further with this procedure.

Link to comment
Share on other sites

Modding in Minecraft presents some special challenges. For one thing, the vanilla code has been scrubbed of all of its authors' naming and internal comments that would tell us what's what (it's my understanding that all class and method names we see are "deobfuscation" provided by Forge, and all comments are by Forge). Whatever the process, we're left with a relatively low-information code base to work with (as compared to what one would see if hired to work from inside Mojang). One needs an above average IQ to decode method arguments like p_12345_5, but I find that solving those problems is a bunch of fun puzzles. It's like doing Sudoku.

 

Then, as you say, we're not allowed to change the vanilla code base. This shortcoming is partially offset by adopting a modder's hacking style. We're not writing professional code, so we're not bound by anybody's standards and practices for producing an easily maintainable etc program. What that means to me is that I can take the gloves off and abuse Java's reflection in totally unprofessional (and sometimes inefficient) ways. If I were coding professionally, I'd improve the vanilla code rather than hacking around it.

 

Finally, there's Forge itself. I am impressed by how well it is structured/organized, but it's still a lot to take in. Its reflection is not the easiest code to follow, especially because eclipse can't follow class and method references that won't be known until runtime. Furthermore, if you can even find your way to the part of Forge that you need for what you want to do, the internal comments don't always connect all of the "how to use" dots. Even more confusing is the haystack of obsolete examples available online. Forge changes with Minecraft, so the proper way to use it in 2012 may be the wrong way in 2014 (Sadly, this is also true of some tutorials floating around the Internet).

 

Having been Forge-modding Minecraft since mid-May, I now overcome obfuscation and the inflexible core myself. It's the mysteries of Forge practices and terminology that sometimes bring me here to search the support forum and sometimes ask a question (and if I get down to the horse-armor mod at the bottom of my to-do list before seeing new horse-armor hooks in Forge, then I'll be asking another one in a few weeks).

 

Good luck!

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Link to comment
Share on other sites

All coding (beyond just following tutorials) is problem solving.  You basically know you have a bunch of pieces and you know you want to do something but then need to choose which pieces and how they go together to achieve what you want.  I think most people can learn to do this, but I suppose some people may get stuck because it requires both creative and strict technical thought processes to come together.

 

For example, imagine you had (in real life, not in Minecraft) a pile of wood and some construction tools.  I think many people could come up with creative ideas on what type of treehouse they could make with the wood, but you wouldn't make a good treehouse unless you had some strict technical skills (like understanding best way to create a strong floor, or how to make a structure that could accommodate the tree moving in the wind without breaking the structure.

 

So back to Minecraft modding, on the one hand you need to be able to vision how the classes and events can be used together and then you have to have the specific Java technical knowledge.

 

I think most people are creative, but the technical knowledge is also key.  This forum is full of questions of people who really have desire to mod, know they have a cool idea for a mod, but really get lost quickly in the coding.

 

But there is one more thing -- you have to be able to know what all the pieces and tools you have to build with.  My big suggestion here is to learn to use Eclipse (or IntelliJ or whatever IDE you use) to *explore* the Minecraft and Forge code.  If you're working with entities, make sure you follow the entire class hierarchy.  For example, you can do this by rightclicking on  whatever the class you're looking at extends and choose type hierarchy or you can also follow the declarations.  Similarly, you should explore what is calling each method by right-clicking and choosing call hierarchy.

 

If you follow posts in these forums, you might find people that seem like they know the answers to everything but really in most cases they just know how to quickly discover the answer.  They do this just the way I said -- by exploring the code.

 

So my big tip is to use your IDE to explore the code.  The more you understand the way Minecraft and Forge typically work, you can will find that you'll more quickly be able to come up with a technical approach to implement the mod you've dreamed up.

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

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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hi all, I'm running a 1.20.1 Minecraft Forge server with a hosting website and something seems to have gone wrong. It started as an occasional crash that has now become extremely frequent and I don't know what exactly is causing it. I already tried disabling watchdog but the server crashes anyway. Oddly it only occasionally generates a crash report after a crash occurs. Based on viewing the server console's research usage it seems that the CPU spikes astronomically high (100% usage), especially when chunks are being loaded or when a new person joins the server. I downloaded Spark to create a profile (https://spark.lucko.me/bBlWe7ou29) but I lack experience with this mod and don't understand what I'm looking at/how this should help me diagnose the issue. I am using a lot of mods so I'm guessing there is some sort of issue there or a corrupted chunk (although MCRF found no chunk errors). We actually don't experience any lag until the crash occurs, so it's some sort of sudden spike in resource usage. Based on the crash report I've already tried removing Canary and Modernfix but there was no change. Thanks for any help you can provide. Specs:  4 cores x 4200MHz AMD Ryzen 9 5950X 4GB RAM Crash report:  
    • will test that once i get home, thanks
    • I am getting this exception (I am new and just trying to create an item) Caused by: java.io.FileNotFoundException: abrasmagics:models/item/ingot_test.json at net.minecraft.client.resources.SimpleReloadableResourceManager.getResource(SimpleReloadableResourceManager.java:69) ~[SimpleReloadableResourceManager.class:?] at net.minecraft.client.renderer.block.model.ModelBakery.loadModel(ModelBakery.java:334) ~[ModelBakery.class:?] at net.minecraftforge.client.model.ModelLoader.access$1400(ModelLoader.java:115) ~[ModelLoader.class:?] at net.minecraftforge.client.model.ModelLoader$VanillaLoader.loadModel(ModelLoader.java:861) ~[ModelLoader$VanillaLoader.class:?] at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:157) ~[ModelLoaderRegistry.class:?]   However the directory is set up correctly and the file does exist   idk how to upload images so here is a treeview of the directories:   src ├───main │ ├───java │ │ └───net │ │ └───abrasmods │ │ └───abrasmagics │ │ ├───init │ │ ├───items │ │ └───utils │ │ ├───handlers │ │ ├───misc │ │ └───proxy │ └───resources │ └───assets │ └───abrasmagics │ ├───models │ │ ├───block │ │ └───item │ └───textures └───test ├───java └───resources   the file ingot_test.json is under models/item. The directory seems fine and the file does exist so anyone plz help.   i am using intellij and is coding for 1.12.2
  • Topics

×
×
  • Create New...

Important Information

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