Eclipse Quick Tips - TriValleyCoderDojo/Minecraft-Jar-Hacks GitHub Wiki
What will be provided here is just a collection of quick tips that can help you with the Eclipse experience. If you would like to read a detailed tutorial, this would be a good one to start with:
http://www.vogella.com/tutorials/Eclipse/article.html
When the Forge ModLoader Eclipse project first loads, you will be faced with interface that may seem a little strange and alien, but its not. Here is a summary of what you are looking at:
- Along the very top is the Menu Bar, this is where you can issue Eclipse commands and operations.
- Just below that is the Tool Bar, this is where Eclipse puts frequently used tools for easy access.
- On the left hand side, you will see the a side panel with the "Project Explorer" view. This is a view into all of the Java packages and class files. You should have the Minecraft project in here.
- In the center, you will have your edit window. This will be where you open the Java class files and edit them.
- In the upper right hand side, you will have your outline view. This will provide an outline of the currently selected Java class.
- In the lower right hand side, you will have the Problems view, along with other workspace management views. This is where you manage what is going on with the projects in the workspace. There will be multiple views, available by clicking on the tabs, the two most important are the Problems, Markers and Console.
This is the default Workbench perspective. You may change it add different windows and move them around as you want.
Common Situations
My Windows have gotten all messed up, HELP!
Sometime you will be clicking around and moving your windows, closing and opening, and everything gets all weird. You have no idea what is going on... It's okay, take breath, and say "I can fix this". If you ever want to get back to the original default perspective, you can always do that going to the main menu bar and selecting:
Window-> Reset Perspective
It will first ask you if you are sure, but since you have nothing to loose, because everything is a mess anyway, you say "Yes", and you will be back to where you started when you first launched Eclipse.
How do I comment out the original code
While you are hacking around, you will probably want to keep around the original code written by the folks at Mojang. So one of the ways to do that would be to leave the original code in place, comment it out, and then do whatever customization comes to mind.
Java has two ways of adding comments. You could use the /* ... */ style of comments, which is intended for multi-line comments, or you could use the // in front of the code to comment out, obviously intended for a single line. However, Eclipse does one better and makes commenting one step easier by adding a keyboard short-cut. If you select a group of lines, using the press the left click button and dragging, once those lines have been selected, you can then press Ctrl + /, all of those lines will then commented out. It also works the other way to uncomment lines of code.
How do I fix errors
For most problems underlined with a problem highlight line, the Java editor can offer corrections with the Quick Fix feature. This is shown by the light bulb shown in the editor marker bar. To show that correction proposals are available for a problem or warning, a 'light bulb' is visible on the editor's annotation bar.
Left click on the light bulb or invoking Ctrl+1 (Edit > Quick Fix) brings up the proposals for the problem at the cursor position. Each quick fix shows a preview when selected in the proposal window.
Quick fix selection dialog
Quick fixes are also shown directly in problem hovers (but there, no preview is available).
Quick fix hover
Usage hint: Quick fixes are not only useful to fix errors that accidentally occurred. An other common usage pattern is to intentionally write "incorrect" code, for example by referring to a local variable that is not declared yet. Then, the Create local variable Quick Fix can generate the declaration in no time, and it can even infer the variable type.
How do I find a class
There are two ways to find a class, and the one to use depends upon what you know about the class. If you not sure what you are looking, then you might consider using the browser. If on the other hand you know the name of class (or kind of what the name is), then you might consider using the Resource Navigator.
Using the browser
When Eclipse is first launched the Minecraft project will appear in the Project Explorer and it will be collapsed.
To start the browsing all you need to do is to left click on the small triangle in front of the project to expand it. This is the first level, then left click on the triangle in front of src, which is the next level and reveals all of the top level Java packages.
From you can continue drilling down deeper and deeper, until you find something of interest.
Using the Resource Navigator
The Resource Navigator is a tool that allows you to quickly go directly to a class by name. There are two ways to launch the Resouce Navigator. The first is through the menu by going to the Menu Bar and selecting Navigator-> Open Resource. The second way is with the keyboard short-cut, Ctrl + Shift + R.
You can use the exact class name, if you know it, such as EntityZombie.java, or you can use regular expressions with wild card characters, such as *Zombie. Once the desired class appears in the list, all you need to do is click on it.
Note: Sometimes .class files will appear in the list. These are not the files you want, and you should not click on them. These are compiled byte code, and you won't be able to edit them.
Using Search to find something
We talked about how to find a class file above, but that may not always enough. Sometimes you will need to search for something other than a class file. For example, you might want to look for a specific method in a class. Another example, would be you want to check if an item id that you want to use for a new item is already being used by something else.
Search in the current class
To search for something in a specific class you would use the Find Replace tool. This tool can be launched in two ways. The first is with the menu by going to the Menu Bar and selecting Edit-> Find/Replace. The second way is with the keyboard short-cut, Ctrl + F.
Search across the entire workspace
Some times you will need to do a global search across all the files in the workspace. Eclipse provides this feature, and to launch it go to the Menu Bar and select
Search-> File
After launching it you will get a popup window which allows you to put in your search parameters. Generally, you usually only need to worry about the "Containing text:" and "File name patterns" entry boxes. In this case, we are search for the number 173 in all of the files with a .java extension (all the Java source code files). Then click the Search button to start the search.
Next, a searching pop-up will appear and the processing will continue. At some point, it will stop, and a new tab will appear in the bottom right hand window. This will be the Search Results view, and it will list all of match, the file they are in and what line they are on. You can click on any of the matches to take a closer look at it.