Minecraft Blogs / Article

Minecraft Modding - The Ultimate Guide for Beginners - Advanced

  • 18,687 views, 0 today
  • 13
  • 5
  • 14
Surseance
Level 67 : High Grandmaster Modder
289

Copy-and-paste Modding: What It Is and Why It Is Bad

Lately, I have seen a lot of what I like to call copy-and-paste-modders. What is that? Well that is a fancy term that means a modder who copies and pastes code from other mods (after decompiling someone else's code) and applying it into their mod. Or, this can also mean someone that looked up a tutorial on how to add a new block to the game and copied and pasted the code directly from the tutorial page. This is BAD! This is not the way you learn how to mod, much less learn java! Coding takes time, patience (lots of it), and practice!
I am not saying that decompiling someone else's code is bad --frankly, it's a very good way to learn what good modding looks like, but copying the whole thing without understanding WHY the code works is a different story. I this article, I will be explaining thoroughly how to improve your modding and programming skills. Enjoy.

The 10 Most Important Tips for Coding


Here are ten tips that I've learned to use over the course of my programming hobby, please pay attention to them carefully, and I suggest saving these somewhere to remind you every time you sit down to code something.

1. NEVER copy-and-paste code!
2. NEVER quit or give up just because you can't figure something out! Just work with it and be patient.
3. ALWAYS strive to make your code better and more efficient! Clunky code is BAD and can lead to failures or difficult update processes!
4. ALWAYS write your code neatly with comments in tricky areas! If you want someone else to read your code later, then I suggest that you type your code as if you were OCD. Also, commenting your code helps you to understand what your code does, and it also shows that you have a firm understanding of the game's methods.
5. ALWAYS enjoy what you're coding! If you don't enjoy it, then find another hobby. If you get frustrated easily and eventually end up quitting, then you don't really enjoy modding in the first place.
6. ALWAYS ask questions if you don't understand something! There are many smart individuals who don't mind answering your questions or concerns about modding. Just make sure you post those questions in the right place and ask politely for someone to answer them.
7. NEVER use code that you don't understand! If you don't know what it does, then ask or investigate it yourself by looking through other pieces of code.
8. ALWAYS think of new and clever ways to code things! There is almost always more than one way to code something that has the effect you want.
9. ALWAYS design your code in such a way that you can easily add new items (or objects as programmers call them)! If you don't, it will encourage you to copy-and-paste code.
10. ALWAYS be ready to use the Trial & Error Method! If you are not willing to use this method, then you do not have the patience it takes to program.

The Trial & Error Method


If you are surprised that this is actually a tip for coding, then get ready for this amazing trick. You will have to have a lot of patience for this to work. This method means that when you are coding something and it doesn't turn out correctly in the game, you work with it by modifying bit by bit until it works correctly. Yes, this is a tedious process, but it works every time. Why? Because the more willing you are to figure something out, then the more likely you are to successfully add something new and cool to the game. Just make sure to stay open-minded for new possibilities of work-around solutions. Your brain may be smarter than you think it is.

Once You Code It, Feel Free to Use It


Let's say you have spent a long time working on a method and it works exactly how you want it to in the game. Well, now that is your method to use freely in any mod you want! And, it will probably be applicable in more ways that you think!

Why Java Coders Should Use Eclipse


Eclipse is a wonderful, free resource provided by Oracle (the current owners of Java). Eclipse has so many powerful tools that modders can utilize for their benefit that it is almost laughable why you wouldn't want to use it. There are many nice features like refactoring, code-alligning, GitHub compatibility, search functions, error notifiers, etc. If you aren't using Eclipse for some odd reason, now would be the time to switch --it'll save so many headaches in the long-run.

Here are some neat little things you can do with Eclipse:


1. You can change the background of Eclipse's white canvas by downloading the Eclipse Color Theme plugin. If you install this program correctly (look on YouTube for help), then you can change the background to colors more pleasing for the eyes.
2. Refactoring your code is an easy way to change variable names, method names, etc. without having to do it by hand. Doing it by hand is tedious and dumb.
3. Using the search function is a major time saver. Simply select a method and press Ctrl + H on your keyboard to search for any references of the method selected. (Look on YouTube for more info.)
4. Is a method not working correctly? Well it may not be overriding the original method created in another class file. If you look to the left of your coding area, you can see a green arrow. If it is there, you are correctly overriding a method.
5. Console messages are a neat thing to use if you want to know if a certain method is being called. Simply add "System.out.println("Message");" anywhere in the method.
There are so many other neat things that Eclipse can do that's it pretty much another tutorial in and of itself!

A Few Minecraft Coding Hints


Having trouble with your code? Well, here are a few things that may help you along your way.

1. Outdated methods? Just check another class file that used the same method for assistance. For example, if you didn't know a while back that the method "entityJoinedWorld" had changed to "spawnEntityInWorld" then you could go to the ItemBow file to see that when the arrow is being called to be put in the world, it will use the new method.
2. Override annotations are used for indicating that one method is inheriting the same method from it's super class's method. You don't have to use these, but they are helpful.
3. TODO annotations are like little markers to use when you want to remember where a certain method is within a class. Putting "// TODO: Place marker" above a method you will return to will leave a little, blue box out to the right side of the coding area. Simply click on it to go to the method location.
4. Backing up and saving code versions may just save your life. Keep all the source code from every update to your mod on hand and organized. It would probably be a good time to get a mediafire or dropbox account to keep your source code and images nice and safe in the cloud. Alternatively, you can keep your code on a back-up drive or flash drive. This way, you won't break a sweat if your computer crashes.
5. If you come across a situation where you have a method that doesn't include something (like if the method doesn't include entity, but you need to reference an entity), then simply add "public Entity entity;" at the top of the file. There! Problem solved!
6. Create separate packages inside the source folder (whether you are using ModLoader of Forge) to keep all of your classes apart from the regular package. Your "mod_" file should be the only file in the src package.

Final Words - Things to Keep in Mind


Well, that about concludes this article, so if you didn't understand something, feel free to ask or research online. The internet is the best tool in your toolbox. Also, it isn't a bad idea to go to your local library to find books about coding. There are SO many great book resources out there. I will be coming out with tutorials on Java-related things more frequently, but overall, it is your decision to learn Java well or not. Remember to keep a positive attitude when coding. Please leave a diamond if you thought this article was helpful in any way. Enjoy your day and happy modding!

Helpful Online Resources:


1. Google Code - has great coding resources
2. Eclipse Color Theme Plugin - amazing new colors
3. Thenewboston - this man has amazing coding tutorials as well as some other things
4. GitHub - a great way to store your code on the cloud in an organized way
5. Dropbox - free cloud storage for your code
6. Stack Overflow - join these forums to get your questions answered quickly by pros
7. Java Code Geeks - great Java tutorials
8. Eclipse and Java Resources - the title says it all
9. Download Eclipse - a Java programmer's best friend
10. Email: rockeyhound1234@gmail.com - if you have any questions, send me an email!
Credityofreke for guidance
Tags

Create an account or sign in to comment.

taa1taa
10/19/2013 8:47 am
Level 64 : High Grandmaster Blob
I shall like this piece of blog!
1
SmashBro97
12/14/2012 5:32 pm
Level 1 : New Explorer
Why you should never put your mods on PMC:

Admins and moderators will trash it and say to you: "It's not unique enough."

(They need to keep in mind that everyone's first mod is never going to be "unique enough" to be on here and they need to give the beginners more time to update it and make it better)

Trashing courtesy of Paril.
1
taa1taa
10/19/2013 8:47 am
Level 64 : High Grandmaster Blob
There is no point in making mods what everyone is already making tho, thats the point. I think Paril does the right thing.
1
Assasin794
05/04/2013 9:52 am
Level 12 : Journeyman Scuttles
I'v gotten so many things taken off of PMC because "Apparently" They weren't mine?
1
TheTuffy56
12/22/2012 6:12 pm
Level 4 : Apprentice Robot
So true.
1
Surseance
12/14/2012 6:40 pm
Level 67 : High Grandmaster Modder
Eh, some people need to think of new ideas. I think the "Mo' Tools" idea is completely overused.
1
SmashBro97
12/14/2012 9:38 pm
Level 1 : New Explorer
And I have to admit, this guide here did help me a bit after I took a gander at it. :)
1
SmashBro97
12/14/2012 9:36 pm
Level 1 : New Explorer
I do sort of agree, the Mo' Tools or whatever is a bit clishe, but the mod I posted had potential and I was continuing to update it until it got removed. (I was a much higher level at the time)
But the problem is, what should these people create? And how are they going to do it? Of course they need to start somewhere, and they also need to remember that the Mo' stuff is getting kinda old too.
1
Surseance
12/15/2012 8:05 am
Level 67 : High Grandmaster Modder
That is a very good question, and I'm glad you asked it. If you need ideas, I've got plenty of them that will be both a challenge and a reward to those who can really code things. Just feel free to send a PM asking for ideas, and I'll be more than happy to give you some!
1
Benjamater848
12/10/2012 1:21 pm
Level 25 : Expert Engineer
Yay now I know some tips for modding! THANKS!
1

Welcome