Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Using Intellij IDEA for Mod-Development with ForgeGradle

Recommended Posts

Note (Sep. 2017): This post is now getting very old, but it still applies. Regardless you might want to refer to the IntelliJ section in the official Getting Started guide instead.


In this Tutorial I will describe how you can use the Intellij IDEA IDE for Mod-Development.


First, you are going to need to download the Mod Development Kit ("MDK") package from http://files.minecraftforge.net/ ("src" for old versions) and unzip it.


Next, start up Intellij. If you already have a Project opened, select File > Open, otherwise select "Open Project". Navigate to the directory where you unzipped Forge to and select the build.gradle file. Leave the import-settings at default and click OK.

Intellij will now take a while to import the project. Once that's done, open the Gradle-sidebar.

If the sidebar is not visible, click the view-switcher in the bottom-left corner: oeiuGXW.png


Select the setupDecompWorkspace task from the list and run it (double-click). If you don't need the Minecraft source code visible, run setupDevWorkspace instead, it will be faster.

Once the task has finished, click the Refresh button in the Gradle-sidebar. That will again take a moment. Once Intellij has finished refreshing, your project is already almost ready to go. You should be able to see all the libraries used by Forge & Minecraft on the left and also the source code for the ExampleMod inside src/main/java.


All that is left to do are the run configurations, so that you can actually start Minecraft. For those again open the Gradle sidebar and run the genIntellijRuns task. Intellij might ask to reload the project, click OK if it does.


If your run configurations show an error in most recent versions of IntelliJ you have to go into Run > Edit Configurations and adjust both run configurations like shown below.



That's it!

Edited by diesieben07
Updated for new forum and new ForgeGradle / IntelliJ versions
  • Like 2
Link to comment
Share on other sites

I followed this and discovered this problem when trying to run the client:


/usr/lib/jvm/java-7-oracle/bin/java -Xincgc -Xmx1024M -Xms1024M -Djava.library.path=/home/jorrit/mc/forge_1.7.10_src/build/natives -Dfml.ignoreInvalidMinecraftCertificates=true -Didea.launcher.port=7533 -Didea.launcher.bin.path=/home/jorrit/idea-IC-135.909/bin -Dfile.encoding=UTF-8 -classpath /usr/lib/jvm/java-7-oracle/jre/lib/deploy.jar:/usr/lib/jvm/java-7-oracle/jre/lib/charsets.jar:/usr/lib/jvm/java-7-oracle/jre/lib/jce.jar:/usr/lib/jvm/java-7-oracle/jre/lib/management-agent.jar:/usr/lib/jvm/java-7-oracle/jre/lib/plugin.jar:/usr/lib/jvm/java-7-oracle/jre/lib/javaws.jar:/usr/lib/jvm/java-7-oracle/jre/lib/resources.jar:/usr/lib/jvm/java-7-oracle/jre/lib/rt.jar:/usr/lib/jvm/java-7-oracle/jre/lib/jfr.jar:/usr/lib/jvm/java-7-oracle/jre/lib/jfxrt.jar:/usr/lib/jvm/java-7-oracle/jre/lib/jsse.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/zipfs.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/localedata.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/sunpkcs11.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/dnsns.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/sunec.jar:/usr/lib/jvm/java-7-oracle/jre/lib/ext/sunjce_provider.jar:/home/jorrit/mc/forge_1.7.10_src/classes/production/forge_1.7.10_src:/home/jorrit/.gradle/caches/minecraft/net/minecraftforge/forge/1.7.10- com.intellij.rt.execution.application.AppMain GradleStart
[19:40:19] [main/INFO] [GradleStart]: No arguments specified, assuming client.
[19:40:19] [main/INFO] [GradleStart]: Extra: []
Exception in thread "main" java.lang.RuntimeException: java.io.FileNotFoundException: /home/jorrit/.gradle/caches/minecraft/assets/indexes/{ASSET_INDEX}.json (No such file or directory)
at com.google.common.base.Throwables.propagate(Throwables.java:160)
at GradleStart.setupAssets(GradleStart.java:274)
at GradleStart.startClient(GradleStart.java:82)
at GradleStart.main(GradleStart.java:56)
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.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
Caused by: java.io.FileNotFoundException: /home/jorrit/.gradle/caches/minecraft/assets/indexes/{ASSET_INDEX}.json (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:146)
at java.io.FileReader.<init>(FileReader.java:72)
at GradleStart.loadAssetsIndex(GradleStart.java:280)
at GradleStart.setupAssets(GradleStart.java:218)
... 7 more

Process finished with exit code 1


Anything I missed?

Link to comment
Share on other sites

Actually that works! Thanks a lot. Now I need to make my very first mod :-)


I do have another question though. Now to add my own mod I suppose I need to make a module? I did that and copied the example mod code from forge. Added Forge dependencies and it compiles fine. However, how can I change my run configuration to actually add my mod when I run MC?



Link to comment
Share on other sites

I'm a bit confused on how to setup IntelliJ/gradle and github so that I can have a github repository with several mods (each with source and assets) and how to integrade that into the src/main/java dirs and src/main/resources. Is there a good guide on how to set that up with MC and IntelliJ in mind?


That's initially why I thought of using modules so that every module could have its own github directory but now it seems that I have to split assets and source?



Link to comment
Share on other sites

Hmm, doesn't that take up a lot of disk space? Seems not very handy to work like that. Especially if the mods are supposed to work together. Also that still doesn't solve how I can get the separate 'src/main/java' and 'src/main/resources' into a single github repository?

Link to comment
Share on other sites

Why do you want a single repository? That makes no sense. One Repo per mod.

And no, it does not take up a lot of disk space. All the dependencies (including forge, minecraft and their sourcecode) is stored in a central location, thanks to gradle. Even if you have 100 workspaces using the same forge version, you will only get one jar file containing forge, which is used by all workspaces.

Link to comment
Share on other sites

Yes I mean one repo for one mod. But the problem is that that repo should contain both the source and the assets dir. But the build dir contains separate src and resource folders. How do I map the folders on my HD to the single repository on github?

Link to comment
Share on other sites

Ok, but that example doesn't seem to have any resources/assets. And that's my problem. With the actual mod it has to be called 'assets' but it is called 'resources' in the project that I created. I guess I'm a bit confused how I could get my assets in the correct place in the github repository.


Ah oops! Missed the resources inside the main folder. Sorry!

Link to comment
Share on other sites

  • 1 month later...
  • 2 months later...
  • 3 weeks later...

I'm trying to rebuild everything on IntelliJ IDEA 14.0 Ultimate (Yes i bought it). But it gives a crash when adding your fix for assets : Error:(1,0) Gradle DSL method not found: 'sourceSets()', is that normal ?


After second problem, when i arrive to rebuild the workspace without the crashing line of code (sourceSets thing), my game launches, forge find my mod, but no assets can be compiled, i tried everything and nothing works. The only way i found is forcing resource building by copying folders myself on the classes output folder.



EDIT : Ok, it's working now, just needed to add the spetial line of code after the rest of the file build.gradle

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.

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

    • You have invtweaks which is a mod for minecraft 1.16 and you have the version of jade for minecraft 1.18. Neither of these mods will work with minecraft 1.19   The 1.19 version of jade can be found here: https://www.curseforge.com/minecraft/mc-mods/jade/files/all?filter-game-version=1738749986%3a73407  
    • my ForgeSlider can't drag , it can only be click ,I'm not sure if I'm doing something wrong this is my Screen code public class MannequinScreen extends AbstractContainerScreen<MannequinMenu> { private EditBox NameBox; private final MannequinEntity mannequin; public final MannequinMenu menu; private ForgeSlider xRotationSlider; private ForgeSlider yRotationSlider; private ForgeSlider zRotationSlider; private ForgeSlider scaleSlider; private CycleButton<Part> partButton; private Part nowPart; private Rotations rotations; private float xMouse; private float yMouse; private static final ResourceLocation TEXTURE = new ResourceLocation(KpRandomThing.MODID, "textures/gui/mannequin.png"); public MannequinScreen(MannequinMenu container, Inventory inventory, Component text) { super(container, inventory, text); this.imageWidth = 176; this.imageHeight = 210; this.mannequin = container.mannequin; this.menu = container; } @Override public void render(PoseStack matrixStack, int mouseX, int mouseY, float partialTicks) { this.renderBackground(matrixStack); super.render(matrixStack, mouseX, mouseY, partialTicks); this.renderTooltip(matrixStack, mouseX, mouseY); this.xMouse = mouseX; this.yMouse = mouseY; } @Override protected void renderBg(PoseStack matrixStack, float partialTicks, int gx, int gy) { RenderSystem.setShaderColor(1, 1, 1, 1); RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); RenderSystem.setShaderTexture(0, TEXTURE); GuiComponent.blit(matrixStack, this.leftPos, this.topPos, 0, 0, this.imageWidth, this.imageHeight, this.imageWidth, this.imageHeight); RenderSystem.disableBlend(); int width = (this.width - this.imageWidth) / 2; int height = (this.height - this.imageHeight) / 2; InventoryScreen.renderEntityInInventory(width + 46, height + 106, 30, (float) (width + 51) - this.xMouse, (float) (height + 75 - 50) - this.yMouse, this.mannequin); } @Override public void init() { super.init(); this.minecraft.keyboardHandler.setSendRepeatsToGui(true); NameBox = new EditBox(this.font, this.leftPos + 6, this.topPos + 4, 99, 20, new TextComponent("name")); NameBox.setMaxLength(60); this.addRenderableWidget(NameBox); Button rename = new Button(this.leftPos + 114, this.topPos + 4, 54, 20, new TextComponent("Rename"), onPress -> { if (!NameBox.getValue().isEmpty()) { KpRandomThing.INSTANCE.sendToServer( new MessagePacket(1, new TextComponent(NameBox.getValue()))); } }); this.addRenderableWidget(rename); int sliderX = this.leftPos + 92; int sliderY = this.topPos + 5; this.partButton = createPartButton(sliderX, sliderY + 80); this.addRenderableWidget(partButton); rotations = this.partButton.getValue().getPose(mannequin); this.xRotationSlider = createAngleSlider(sliderX, sliderY + 20, 74, 20, "X:", rotations.getX()); this.yRotationSlider = createAngleSlider(sliderX, sliderY + 40, 74, 20, "Y:", rotations.getY()); this.zRotationSlider = createAngleSlider(sliderX, sliderY + 60, 74, 20, "Z:", rotations.getZ()); this.scaleSlider = new ForgeSlider(sliderX, sliderY + 100, 74, 20, new TranslatableComponent("button.kp_random_thing.scale"), TextComponent.EMPTY, 0.1, 2, mannequin.getScale(), 0, 2, true); this.addRenderableWidget(xRotationSlider); this.addRenderableWidget(yRotationSlider); this.addRenderableWidget(zRotationSlider); this.addRenderableWidget(scaleSlider); } @Override protected void renderLabels(PoseStack poseStack, int mouseX, int mouseY) { } @Override public boolean mouseReleased(double xMouse, double yMouse, int id) { updata(); return super.mouseReleased(xMouse, yMouse, id); } @Override public boolean keyPressed(int key, int b, int c) { if (key == 256) { this.minecraft.player.closeContainer(); return true; } return super.keyPressed(key, b, c); } private void updata() { if (nowPart != partButton.getValue()) switchPart(); String name = partButton.getValue().name; double x = xRotationSlider.getValue(); double y = yRotationSlider.getValue(); double z = zRotationSlider.getValue(); double scale = scaleSlider.getValue(); KpRandomThing.INSTANCE.sendToServer(new MessagePacket(0, x, y, z, scale, new TextComponent(name))); } private void switchPart() { Rotations rotations = partButton.getValue().getPose(mannequin); this.xRotationSlider.setValue(rotations.getX()); this.yRotationSlider.setValue(rotations.getY()); this.zRotationSlider.setValue(rotations.getZ()); this.nowPart = partButton.getValue(); } private CycleButton<Part> createPartButton(int width, int height) { CycleButton<Part> button = CycleButton.builder(Part::getName).withValues(Part.values()).create(width, height, 80, 20, new TranslatableComponent("button.kp_random_thing.part")); return button; } private ForgeSlider createAngleSlider(int x, int y, int width, int height, String prefix, double currentValue) { return new ForgeSlider(x, y, width, height, new TextComponent(prefix), TextComponent.EMPTY, -180D, 180D, currentValue, 0, 2, true); } public enum Part { HEAD(MannequinEntity.DATA_HEAD_POSE, MannequinEntity.HEAD), BODY(MannequinEntity.DATA_BODY_POSE, MannequinEntity.BODY), LEFT_ARM(MannequinEntity.DATA_LEFT_ARM_POSE, MannequinEntity.LEFT_ARM), RIGHT_ARM(MannequinEntity.DATA_RIGHT_ARM_POSE, MannequinEntity.RIGHT_ARM), LEFT_LEG(MannequinEntity.DATA_LEFT_LEG_POSE, MannequinEntity.LEFT_LEG), RIGHT_LEG(MannequinEntity.DATA_RIGHT_LEG_POSE, MannequinEntity.RIGHT_LEG); final EntityDataAccessor<Rotations> dataPose; final String name; Part(EntityDataAccessor<Rotations> dataPose, String name) { this.dataPose = dataPose; this.name = name; } public Rotations getPose(ArmorStand entity) { if (entity == null) { return new Rotations(0, 0, 0); } return entity.getEntityData().get(dataPose); } public Component getName() { return new TranslatableComponent("button.kp_random_thing.part." + name); } } }  
    • Hello, I am trying to install client-side mods, to better my minecraft experience on servers, but I run into a few issues with some dependencies missing, so I would like if someone would be able to help me.  Here are the following errors: Error loading mods 3 errors have occurred during loading --------------------------------------- InventoryTweaksRenewed(invtweaks) has failed to load correctly java.lang.NoClassDefFoundError:net/minecraft/client/gui/widget/Widget Jade(jade) has failed to load correctly java.lang.NoClassDefFoundError:net/minecraftforge/event/entity/EntityJoinWorldEvent Waila(Jade)(waila)has failed to load correctly java.lang.NoClassDefFoundError:net/minecraftforge/client/event/ClientPlayerNetworkEvent$LoggedOutEvent Here is a pastebin of the crash report: https://pastebin.com/uMxfcUP3
    • You don't show the error, or minecraft version or any other useful information. "It keeps on crashing and I can't get it to load" is useless.   The github project you posted is incomplete. It has no build.gradle, etc. so we can't build it ourselves to find out the problem you have.   GUESSING: I can see a number of obvious problems with your code:   1) https://github.com/Tucky143/Buzz/blob/a03ffc801f439a095e9c272dff6510970543f0e2/src/main/java/com/example/examplemod/villager/ModVillagers.java#L29 Here you are doing instance equality tests for a Holder<PoiType> with a PoiType. This will never be true.   2) https://github.com/Tucky143/Buzz/blob/a03ffc801f439a095e9c272dff6510970543f0e2/src/main/java/com/example/examplemod/villager/ModVillagers.java#L36 That reflection code does nothing. Look at the method you are calling. Although I suspect you can't find it. The signature of the method you are using is for 1.18.x while the above methods you are using in (1) above are the signatures of methods in 1.19.x    
  • Topics

  • Create New...

Important Information

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