How_to_Mod_Minecraft
Harmonised
2020-10-17
How to Mod Minecraft https://files.minecraftforge.net/ Download Forge MDK Choose the Minecraft Version you want to start Modding on, as shown on the attached Picture Download the Latest MDK Download and Install an IDE (Your Editor/Compiler) (CHOOSE ONE) IntelliJ Eclipse Free Powerful Smart Free Less Powerful Less Smart Available for Linux, Windows, and Mac https://www.jetbrains.com/idea/download/#section=windows Community Version is free Available for Linux, Windows, and Mac https://www.eclipse.org/downloads/ Setting up your Modding Environment Extract the downloaded MDK Enter the newly created folder with your MDK inside of it Open up a terminal inside this folder If you don't know what this means, the easiest way to do it is to HOLD SHIFT and Right Click inside the folder Choose "Open PowerShell window here" Type this into the Terminal OPTIONAL ./gradlew tasks Displays all the actions you can choose from, the next steps are included in here, too Required IntelliJ Eclipse ./gradlew genIntellijRuns ./gradlew genEclipseRuns Wait until it is Finished Should look something like this Open up your IDE IntelliJ Open your Project Choose build.gradle from inside the folder you have Extracted before Open as Project Expand the main branch of your working tree Import Gradle Project (Should appear at the bottom right of your IntelliJ IDE) This will take a while if you have a slower Broadband I believe this download might be throttled, as it takes about 10 minutes on a 15MB/s Download speed You will know it's finished when this blue line dissapears Setting up your build.gradle, and other important files This guide will not be covering how to configure your build.gradle and /src/main/ resources, as I do not feel like I know enough about it to give you any real advice. I would Highly suggest visiting https://discord.com/invite/EDbExcX for help Examples that I got from the MMD Discord Server ModdingSkeletonMixin 1.16 1.15 https://github.com/Tfarcenim/ModdingSkeletonMixin/tree/master https://github.com/Tfarcenim/ModdingSkeletonMixin/tree/1.16.x Versions /build.gradle /gradle.properties /src/main/resources/pack.mcmeta /src/main/resources/META-INF/mods.toml Starting to mod! Compiling your Mod Open up the terminal in your Mod Directory, just like you did before Type in ./gradlew build After it is finished The compiled mod will appear in /build/libs This file is ready to be put into /mods/ and played Ultimate is free for Students for Educational Purposes Helpful Resources Thanks to MMD bot's and people running it Events Paste Sites hastebin Free: 50,000 character upload limit. Free: 100MB Membership required Free: 1MB - Members get: 6MB Free: 15MB Free: 512KB - Paid users get: 10MB Updating your Forge/Mappings Version Go to your build.gradle Find this section Change the version to the one you want to update to Can be found on https://files.minecraftforge.net/ Reimport your Gradle Might need to also ReRun genIntellijRuns In Terminal ./gradlew genIntellijRuns Forge Mappings Change the version to the one you want to update to Writing Code Files you need to setup before starting your Mod Mixin Languages Java Helpful Minecraft Resources Client Only Minecraft.getInstance() player world currentScreen mainWindow Server Only MinecraftForge EVENT_BUS used for registering your events Classes GUI Screen Button IntelliJ Tricks n Tips Ctrl+Shift+N You can use this to find Minecraft Classes Good for finding examples of how Minecraft does things Ctrl+R Replace inside of the current file Ctrl+Shift+R Replace throughout All files Shortcuts Shift+F6 The correct (safe) way to rename Files and Fields Hold Ctrl + Left Mouse Click Brings you to the definition of the field you clicked on If you clicked on the definition of a field, it will show you all the uses of this field Plugins Minecraft Development https://plugins.jetbrains.com/plugin/8327-minecraft-development Amazing for Access Transformer / Mixin Development Access Transformer Allows you to modify Minecraft Classes fields from private/protected to public Github Allows Backups Each backup has a message Each Backup can be viewed in detail as to what changed since last Backup Allows for Multiple devs contribution to a single project Free Tools GitKraken Offers GUI for Github Only free for Public Repositories [THERE ARE OTHERS] THIS GUIDE BARELY COVERS Eclipse, IntelliJ IS USED IN THIS GUIDE MAINLY hatebin gist paste.ee paste.gg pastebin Free: 400KB Helpful Online Resources Youtube MMD Discord Channel Other Discord Channels Google Documentations Forge Java Mixin Others Github https://mcforge.readthedocs.io/en/1.15.x/ https://github.com/SpongePowered/Mixin/wiki https://docs.oracle.com/en/java/ Debug Mode How to Start Breakpoints Clicking right of the line number makes a Breakpoint Breakpoints Stop your code when that line is executed inside your program - in this case - Mod When Stopped, you are offered all Fields to be inspected Recompiling Live (Change code without Restarting Minecraft) Hotkey After Modifying code, press the hotkey for Compile and Reload File Note! Only reloads the currently open file, not all at once Gradle Compile Options Let IntelliJ Handle Compiling (Faster) Events Examples BreakEvent Anytime a block is broken, this event is fired PlayerInteractionEvent Anytime a player does something, this event is fired Ways to implement Events A Registered Class (Recommended method) Create a new Package (Directory) Hit Enter Inside the newly created Package, create a Java Class Call it "events" Call it "EventHandler" Hit Enter Enter this newly created Class by double clicking it Registering the Class as an Event Handling Class Inside your main Class (In this case, ExampleMod) Put this line into your Constructor MinecraftForge.EVENT_BUS.register( EventHandler.class ); We have now used the Forge's EVENT_BUS to register your EventHandler Class Subscribe to an Event @SubscribeEvent has to be present before every Event. This is how we tell Forge's Event Bus to register this Method to this specific Event. To find different event types, simply start typing into the Parameters field of your Method, and look for a suggestion If you launch the game now, your Console will tell you what type of an event was fired everytime it is fired. This will happen anytime the player Interacts with the world. You can then create other handlers for Specific events Adding more Events is as easy as repeating the same step Registering the Handler Method directly Inside your Main Class Constructor, register a specific method, in this case, the method is called "setup", which can be seen below in the Screenshot .isRemote() a VERY important way to know if you are on Server side, or Client side true = Client false = Server