配置开发环境

首先需要下载IDEA和JDK8。

然后需要配置Forge MDK环境,打开Forge1.12.2的官网,往下找到MDK,点击后面的”i“。然后将下载的文件解压到纯英文的路径,并把文件夹名称改为你的模组名称。

在文件夹里右键打开CMD,输入gradlew setupDecompWorkspace,出现BUILD SUCCESSFUL输入gradlew genIntellijRuns,出现IDEA输入gradlew genintellijRuns,接下来就可以用IDEA打开了。(14.23.5.2855之后直接在IDEA里运行build.gradle文件)。

在你的模组的@Mod()方法里的dependencies添加”required-after:GalacticraftCore;“。

下载星系开发版本,记得要开加速器,3个都要下载。在根目录下创建一个libs文件夹,把文件放进去,在build.gradle的dependencies里添加

compile fileTree(dir: 'libs', include: '*.jar'),之后重新构建一次开发环境就行了,IDEA一般会直接重新构建。

现在你已经导入了星系的API,可以按照平常制作模组,需要使用星系的文件时使用Import语句导入星系的文件就行了。


添加一个星球

Once you have a config file set up, in the FMLInitialiationEvent method, add this 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:

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:

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:

@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();     }