Development How to Code a New Planet

jasonB221

Member
Jul 27, 2013
124
9
18
Lost in Space
THIS IS NOT A DOWNLOAD!!!! THIS IS A TUTORIAL TO TRY AND HELP YOU MAKE YOUR OWN ADDON TO THE MOD, AND ADD YOUR OWN PLANET!!!

This tutorial assumes you know the basics of java and forge modding, and you already have your forge workspace set up. If not, go to this link: http://www.minecraftforge.net/wiki/Installation/Source

Once you have that done, you need to make some modifications to the file. Go to this link: https://github.com/micdoodle8/Galacticraft and on the right hand side of the page, there should be a button that says "Download Zip". Download the zip, and extract it somewhere.

IF YOU DO NOT WANT TO VIOLATE THE LISCENSE, THE NEXT STEP IS VERY IMPORTANT. IF YOU DON'T DO THIS STEP, YOU MIGHT GET AN ANGRY MICDOODLE8 BANNING YOU FROM THIS FORUM! YOU HAVE BEEN WARNED!

Go into the newly extracted file, and go to /micdoodle8/mods/galacticraft. Once there, delete both the "Core" and "Moon" folders, but leave the "API" folder. Copy that folder into wherever you have forge installed, in the folder /forge/mcp/src. Be sure to get the whole folder, including the /micdoodle8/mods/glacticraft, otherwise you will have compile and run-time errors. Once you have done that, go into the /forge/mcp folder and run "updatemd5" All that does is make sure that you won't distribute micdoodle's code when you release your addon.

Almost there, you just need to update your library.

These instructions are for eclipse, since if you mod, you should probably be using Eclipse. Download the latest micdoodle8core and Galacticraft jars from the website. Put those files in /forge/mcp/lib. Next, in eclipse, change your workspace to /forge/mcp/eclipse. Once done, there should be a single project called "Minecraft". Right click on the title, and then click on "properties", at the bottom of the menu. Go to "Java Build Path" and click "Add External Jars". Select the GalacticraftCore jar from the lib folder, then repeat the process for Micdoodle8Core.

LETS GET READY TO CODE!!!!!
From here on out, you better know how to use forge, mcp, java, and eclipse. No more nice, explain everything in the littlest of details.
Create your @Mod class. If you have no clue what I am talking about, you don't know jackshlit about forge, and you should go here: http://www.minecraftforge.net/wiki/Basic_Modding and then to here: http://www.minecraftforge.net/wiki/Tutorials
Inside your @Mod class, set up the basics, and add a Configuration File to your class. Go to the tutorials if you don't know how to do that. There is an optional parameter you can add to the @mod declaration to make sure your mod loads after galacticraft, which is
Code:
dependencies="required-after:GalacticraftCore"
Just put that into your @Mod declaration after the version and you should be good.

Once you have a config file set up, in the FMLInitialiationEvent method, add this code:
Code:
int dimID = configurationFile.getInteger(Configuration.CATEGORY_GENERAL, "MyOwnPlanetDimensionID", -30).getInt();
DimensionManager.registerProviderType(dimID, new PlanetWorldProvider(), false);
DimensionManager.registerDimension(dimID, dimID);
The first line loads the configurable dimension id from a config file. It should be configurable because if another mod uses that same id, then you have a compatibility problem. If you allow the user to configure it, then it is a win-win. In the next line, you should have a red line under DimensionManager and PlanetWorldProvider(). Press ctrl+shift+o in eclipse to fix the DimensionManager red line, and wait for the next step to fix the PlanetWorldProvider error. The false in that line is a boolean to determine whether or not to keep the dimension always loaded. I cannot think of a single reason why that would be. The third line actually registers the dimension with forge so you can do stuff with it.

In the FMLPreInitalizationEvent method, add the following line of code:
Code:
GalacticraftRegistry.registerTeleportType(PlanetWorldProvider.class, new PlanetTeleportType());
This code is used later, in determining where to spawn players on the new planet.

Eclipse should import the needed files for you, however if it doesn't, after every step just remember to press ctrl+shift+o to import needed files.

PlanetWorldProvider Class
This is the place to do the second most configuration of the planet. The only other place is the world generation file. This class needs to extend WorldProvider, and should implement some Galacticraft API classes. Those classes include IGalacticraftWorldProvider, IExitHeight, and possibly ISolarLevel. As this is a long class, I will just provide a pastebin of the example code. The Pastebin: http://adfoc.us/1701631

There should be some errors underneath the code "PlanetWorldChunkManager" and "PlanetWorldChunkProvider" To fix that, create the class "PlanetWorldChunkProvider" and copy the code from the file "net.minecraft.world.gen.ChunkProviderGenerate" To fix the error under PlanetWorldChunkManager, create that class and copy the code from "net.minecraft.world.biome.WorldChunkManager". On both of those cases, be sure to change the name of the class and package back to what they should be. And be sure to press ctrl+shift+o in every single class at this point. I won't post the code, and if you use this code your planet shouldn't be open-source, as that might be a violation of Mojang's license.

PlanetTeleporterType Class
This class determines how each player will be teleported to the new planet. This class just needs to implement ITeleportType, and fill in the methods from there. Pastebin example here: http://adfoc.us/17016331620265 and once again, be sure to press ctrl+shift+o. All of these methods are pretty self-explanatory.

PlanetTutorial Class
Create a new class and name it PlanetTutorial, and it should implement IPlanet. There is a single method unique to IPlanet, and a couple of methods shared with IMoon, which is what you would implement if you wanted to create a moon for the planet. Pastebin for the file: http://adfoc.us/17016331624235
This also needs to be registered with Galacticraft. Add the following code in the @Mod file in the FMLPreInitializationEvent method:
Code:
GalacticraftRegistry.registerCelestialBody(new PlanetTutorial());
One more file to go... EDIT: I LIED SORRY. THERE IS ANOTHER FILE AFTER THIS!
TutorialPlanetMapObject
This is the class that renders the planet on the universe map. You can do a lot of fancy graphics here, however in this case I am just going to take the overworld code and modify a few numbers to make it rotate twice as far out. Create a class called TutorialPlanetMapObject that implements IMapObject. Inside that class copy and paste the code from the pastebin, or from the Galacticraft source code file "/micdoodle8/mods/galacticraft/client/GCCoreMapPlanetOverworld" Pastebin here with modified code and comments: http://adfoc.us/17016331624905

TutorialPlanetSlotRenderer class
This class actually has only three methods. You need to implement ICelestialBodyRenderer, and use the following code:
Code:
 @Override
    public ResourceLocation getPlanetSprite()
    {
        return new ResourceLocation(GalacticraftCore.TEXTURE_DOMAIN, "textures/gui/planets/overworld.png");
    }

    @Override
    public String getPlanetName()
    {
        return "TutorialPlanet";//Replace this string with the name of your dimension as defined in the WorldProvider class.
    }

    @Override
    public void renderSlot(int index, int x, int y, float slotHeight, Tessellator tessellator)
    {
        tessellator.startDrawingQuads();
        tessellator.addVertexWithUV(x + 12 - slotHeight, y - 11 + slotHeight, -90.0D, 0.0, 1.0);
        tessellator.addVertexWithUV(x + 12, y - 11 + slotHeight, -90.0D, 1.0, 1.0);
        tessellator.addVertexWithUV(x + 12, y - 11, -90.0D, 1.0, 0.0);
        tessellator.addVertexWithUV(x + 12 - slotHeight, y - 11, -90.0D, 0.0, 0.0);
        tessellator.draw();
    }

Thats it!!!! It should be fully working now. But I will tell you how to release it, for everyone's sake :)
Be sure to ctrl+shift+o again, on every file edited. That way the imports are good. Then be sure to ctrl+shift+s to save every single file. In the /forge/mcp folder, there is a script called "recompile". Run that, and once it is done, run the script "reobfuscate_srg" in the same folder. Then go to the folder /forge/mcp/reobf/minecraft, and your files should be in there. Select every single file and folder in there, and add them all to a zip archive. That zip archive can be distributed as your mod, and the install instructions are to just drop it in the mods folder in the players /.minecraft

Don't ask for a video tutorial, as my computer is not powerful enough to handle recording.
If this helped you, make a new planet. Learn some more about forge and make a new dimension, new entites. Actually edit the getSlotRenderer() method in the mapobject class. And leave a like :)
Also check out my addon, SpaceX. Link in my signature. Have a good day!

Source Code minus Copyrighted Files: http://adfoc.us/17016331626009
I made this release available, and I don't want any bug reports for it unless it relates to an error in the code above. It shouldn't.
PS: Mic, I never intended to violate any part of a license. If I did, feel free to edit it to take out the offending part, and I ask that you drop me a pm saying you did so and explaining how I violated it. I hope that isn't necessary.
 
Last edited:

fadi

Member
Aug 7, 2013
85
1
8
32
GUYS how to active the code where i can active it and if i have actived what i can need to do then ? Help!!!
 

mimi4460

Member
Apr 12, 2013
82
2
8
30
Minecraft
You could clearly explain the configuration file ? (give an example with pastebin)
I do not understand the tutorials on other sites.
 

jasonB221

Member
Jul 27, 2013
124
9
18
Lost in Space
I have lots of errors, :mad:
It would be better make a video.
if possible....
Well I have an airplane flight ahead of me. Might be done, otherwise will post full pastebin of code minus copyrighted stuff and a download.
guys eclipse dont work for me it says faild to load jni File Jvw Help ME!!!
Can't quite tell what you are trying to say, but it looks like you don't have the Java development kit installed. So therefore, go learn java. (Don't mean to be harsh, just firm)
You could clearly explain the configuration file ? (give an example with pastebin)
I do not understand the tutorials on other sites.
Sure. See full source code post as explained above.
 

mimi4460

Member
Apr 12, 2013
82
2
8
30
Minecraft
You could also do a tutorial to add a space station to a planet ? Please :)
I would like to fully use the API to make many additions.
It would be good to make many tutorials that fully explains the API
If you have the time to fully explain the API, you can help many people....
Naturally this is a difficult task, I understand if you refuse...
 

jasonB221

Member
Jul 27, 2013
124
9
18
Lost in Space
You could also do a tutorial to add a space station to a planet ? Please :)
I would like to fully use the API to make many additions.
It would be good to make many tutorials that fully explains the API
If you have the time to fully explain the API, you can help many people....
Naturally this is a difficult task, I understand if you refuse...
Adding a space station is not as easy as adding a planet. I am not quite sure how you would do it.
 

mimi4460

Member
Apr 12, 2013
82
2
8
30
Minecraft
I got the following error :
---- Minecraft Crash Report ----
// Who set us up the TNT?

Time: 20/08/13 02:33
Description: There was a severe problem during mod loading that has caused the game to fail

cpw.mods.fml.common.LoaderException: java.lang.NoSuchFieldError: field_76246_e
at cpw.mods.fml.common.LoadController.transition(LoadController.java:149)
at cpw.mods.fml.common.Loader.loadMods(Loader.java:522)
at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:181)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:470)
at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:796)
at net.minecraft.client.main.Main.main(Main.java:93)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:57)
at net.minecraft.launchwrapper.Launch.main(Launch.java:18)
Caused by: java.lang.NoSuchFieldError: field_76246_e
at micdoodle8.mods.galacticraft.moon.blocks.GCMoonBlock.<init>(GCMoonBlock.java:42)
at micdoodle8.mods.galacticraft.moon.blocks.GCMoonBlocks.initBlocks(GCMoonBlocks.java:18)
at micdoodle8.mods.galacticraft.moon.GalacticraftMoon.preLoad(GalacticraftMoon.java:56)
at micdoodle8.mods.galacticraft.core.GalacticraftCore.preInit(GalacticraftCore.java:167)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:540)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)
at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:313)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)
at com.google.common.eventbus.EventBus.post(EventBus.java:267)
at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:194)
at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:174)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)
at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:313)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)
at com.google.common.eventbus.EventBus.post(EventBus.java:267)
at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:105)
at cpw.mods.fml.common.Loader.loadMods(Loader.java:521)
... 10 more


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- System Details --
Details:
Minecraft Version: 1.6.2
Operating System: Windows 7 (amd64) version 6.1
Java Version: 1.7.0_25, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 874998800 bytes (834 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)
JVM Flags: 3 total; -Xincgc -Xms1024M -Xmx1024M
AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
Suspicious classes: FML and Forge are installed
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
FML: MCP v8.04 FML v6.2.51.835 Minecraft Forge 9.10.0.835 5 mods loaded, 5 mods active
mcp{8.04} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized
FML{6.2.51.835} [Forge Mod Loader] (coremods) Unloaded->Constructed->Pre-initialized
Forge{9.10.0.835} [Minecraft Forge] (coremods) Unloaded->Constructed->Pre-initialized
Micdoodlecore{} [Micdoodle8 Core] (coremods) Unloaded->Constructed->Pre-initialized
GalacticraftCore{0.1.39} [Galacticraft Core] (Galacticraft-1.6.2-a0.1.39.566.jar) Unloaded->Constructed->Errored

HELP ME ! :confused:
What is the problem ?
 

jasonB221

Member
Jul 27, 2013
124
9
18
Lost in Space
Its galacticraft core I'm pretty sure. Once you learn how to read an error log, it's very easy to tell what happens. The real error is this:
Caused by: java.lang.NoSuchFieldError: field_76246_e
at micdoodle8.mods.galacticraft.moon.blocks.GCMoonBlock.<init>(GCMoonBlock.java:42)
at micdoodle8.mods.galacticraft.moon.blocks.GCMoonBlocks.initBlocks(GCMoonBlocks.java:18)
at micdoodle8.mods.galacticraft.moon.GalacticraftMoon.preLoad(GalacticraftMoon.java:56)
at micdoodle8.mods.galacticraft.core.GalacticraftCore.preInit(GalacticraftCore.java:167)