Jump to content

Recommended Posts

Posted (edited)

Today I'm going to start modding.
Wish me luck! :D

--Gotlyfe--

 

I will be editing this post and providing sources for the reasoning behind my actions in the spoilers.

 

Updates:

-Downloaded and installed Java version of Minecraft from https://minecraft.net/download/

-Downloaded and installed Minecraft forge(recommended version 1.12.2 - 14.23.3.2655) from https://files.minecraftforge.net/

-Ran once to test it was working properly

Spoiler

Need Minecraft and Forge installed to create and test mods.


-Removed all versions of Java from my computer
-Installed Java 8u171 from Oracle 8u171 Download

Spoiler
On 2/21/2018 at 11:30 PM, Cadiboo said:

I dont believe you need the Development kit, but I've always downloaded it just to be safe (it includes normal java in it) and its worked fine


 

How to change it:

It could be complicated, you should be able to change it with commands but that didn't work for me (MacBook Pro 2013) so I deleted java completely then installed the right java

Java 8u151:

http://www.oracle.com/technetwork/java/javase/downloads/java-archive-javase8-2177648.html

 

MAKE SURE you download 8u151 not 8u152 (8u151 is the second release from the to, and the 3rd item from the top)

 

Minecraftforge Forum minecraft-forge-server-wont-start-when-trying-to-add-rammac
This thread went on to discuss that you should only have the working version of java installed or you might get an error such as I did.  "Could not determine java version from '10.0.1'."

 


I was unable to get specifically 8u151 as 8u151 Release Notes states that "This JRE (version 8u151) will expire with the release of the next critical patch update scheduled for January 16, 2018."

Instead I installed the newest version of Java 8 (8u171) which, to my knowledge, should be compatible.


-Downloaded Forge source distribution(mdk) from http://files.minecraftforge.net/ (same version as installed earlier)

-Extracted zip file into empty folder
-Copied build.gradle gradlew.bat gradlew and the gradle folder to a new folder for project

Spoiler

In the Forge Documentation
http://mcforge.readthedocs.io/en/latest/gettingstarted/
Step 1-3


-Installed Eclipse from https://www.eclipse.org/downloads/

Spoiler

In the Forge Documentation
http://mcforge.readthedocs.io/en/latest/gettingstarted/
Step 5

 

Quote

Forge explicitly supports developing with Eclipse or IntelliJ environments, but any environment, from Netbeans to vi/emacs, can be made to work.

 

 

-Opened Command Prompt as administrator

-Navigated to project Folder
-ran gradlew -Dorg.gradle.jvmargs=-Xmx3000m setupDecompWorkspace eclipse to set up workspace, set up for eclipse and make sure it had enough RAM to complete
-Completed in 11 mins 23 seconds

Spoiler

In the Forge Documentation
http://mcforge.readthedocs.io/en/latest/gettingstarted/
Step 4-5

 

Then when I found myself stuck at 56% decompileMC

On 5/3/2017 at 2:52 PM, SubDivide said:

Happens a lot to me, Just use:

 



gradlew -Dorg.gradle.jvmargs=-Xmx3000m setupDecompWorkspace eclipse

 

Fixes my issue perfectly, I'm not sure if it's the right way of doing things but it certainly works for me

from the thread Minecraftforge Forum forgegradlemcdeps-stays-at-56

 

-Opened Eclipse and set workspace one level above project folder

-Added Project to package explorer by Import > General > Existing Projects into Workspace > Select Root Directory

Spoiler

 

-Altered Mod Information, changing build name, "maven coordinates", and version number under build.gradle

 

-Created new source folder for java, package inside source folder, project class inside package

-Created new source folder for resources

-Creating mcmod.info file in resources and fill with metadata about mod

Spoiler

mcmod.info example included in forge distribution mdk under src/main/resources

Spoiler


[
{
  "modid": "examplemod",
  "name": "Example Mod",
  "description": "Example placeholder mod.",
  "version": "${version}",
  "mcversion": "${mcversion}",
  "url": "",
  "updateUrl": "",
  "authorList": ["ExampleDude"],
  "credits": "The Forge and FML guys, for making this example",
  "logoFile": "",
  "screenshots": [],
  "dependencies": []
}
]

 

But explanations of mcmod.info from https://mcforge.readthedocs.io/en/latest/gettingstarted/structuring/#the-mcmodinfo-file

 

-Adding parts one by one to project class from ExampleMod.java

Spoiler

 ExampleMod.java is in the forge distribution mdk under src/main/java

Spoiler


package com.example.examplemod;

import net.minecraft.init.Blocks;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import org.apache.logging.log4j.Logger;

@Mod(modid = ExampleMod.MODID, name = ExampleMod.NAME, version = ExampleMod.VERSION)
public class ExampleMod
{
    public static final String MODID = "examplemod";
    public static final String NAME = "Example Mod";
    public static final String VERSION = "1.0";

    private static Logger logger;

    @EventHandler
    public void preInit(FMLPreInitializationEvent event)
    {
        logger = event.getModLog();
    }

    @EventHandler
    public void init(FMLInitializationEvent event)
    {
        // some example code
        logger.info("DIRT BLOCK >> {}", Blocks.DIRT.getRegistryName());
    }
}

 

 

-Adding

@Mod(modid = ClassName.MODID, name = ClassName.NAME, version = ClassName.VERSION)

 above public class ClassName which requires 


import net.minecraftforge.fml.common.Mod;
Spoiler

@Mod is described as 

Quote

This is an annotation indicating to the Forge Mod Loader that the class is a Mod entry point. It contains various metadata about the mod. It also designates the class that will receive @EventHandler events.

from https://mcforge.readthedocs.io/en/latest/gettingstarted/structuring/#what-is-mod

 

The parameters are to give the metadata that mcmod.info otherwise provided or set the useMetadata property to true to override what is written here with the information from mcmod.info.

 

-Adding public static final strings to project class definition for previously used metadata in @Mod 

Spoiler

public static final String MODID = "examplemod";
public static final String NAME = "Example Mod";
public static final String VERSION = "1.0";

MODID and NAME being the same as in mcmod.info

Version best practices explained by https://semver.org/

 

-Adding

private static Logger logger;

into class which requires

import org.apache.logging.log4j.Logger;
Spoiler

This is for any logging operations to be done.

Documentation can be found at https://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/Logger.html

 

It is my understanding there are numerous logging libraries to choose from.

 

The example uses 


logger = event.getModLog();

which is more easily explained through the examples at ProgramCreek FMLPreInitializationEvent.getModLog()

 

 

 

-Creating initialization event functions

@EventHandler
    public void preInit(FMLPreInitializationEvent event)
    { 
  		logger = event.getModLog();
    }

@EventHandler
    public void init(FMLInitializationEvent event)
    { }

@EventHandler
    public void postInit(FMLPostInitializationEvent event)
    { }

which requires


import net.minecraftforge.fml.common.Mod.EventHandler;

to handle events at all and

import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;

to handle these specific events.

Spoiler

The forge initialization events are all described here https://mcforge.readthedocs.io/en/latest/conventions/loadstages/

There are some specific actions which can only be done upon these events and only inside the @Mod class

 

Spoiler

 

Need to re-work these, see Comments below

-Create 3 new classes in package Common Proxy, ClientOnlyProxy and DedicatedServerProxy

Spoiler

The details of the need for the 3 proxy classes is explained well here GreyMinecraftCoder how-forge-starts-up-your-code

by @TheGreyGhost

 

Some details also described in the documentation at https://mcforge.readthedocs.io/en/latest/networking/simpleimpl/

 

-The Common Proxy being an abstract class and the Client and Server classes being extensions of it.


public abstract class CommonProxy {
}

public class DedicatedServerProxy extends CommonProxy{
}

public class ClientOnlyProxy extends CommonProxy{
}

giving each of them the functions


	public void preInit()
	  { }
	public void init()
	  { }
	public void postInit()
	  { }
	abstract public boolean isDedicatedServer();

but having the Client return false and the Server return true for the isDedicatedServer(); and removing the abstract keyword

 

 

 

 

-Created build by using the cmd in the project folder directory to run gradlew build

-Copied the output file ([archivesBaseName]-[version].jar from build/libs into .minecraft\mods

 

Success!

 

-- Will start a new thread specific to the kind of mod I am going to make it into. This seems to be a good general starting mod thread in my opinion.

Edited by Gotlyfe
  • Thanks 1
Posted

This is not by any chance a tutorial.

 

This is mostly copy-paste from the existing Forge docs intro (which is perfectly fine for people new to modding), and gave code which users can copy-paste into their files without learning anything, resulting in the same code as the example source. 

 

Also, the CommonProxy system doesn't make sense. Read Code Style, issue #1.

 

Your proxies shouldn't have code to distinguish the dedicated server from the integrated server. Almost all logic should be done on both servers, not just on one of them. That'll cause issues on the other server.

  • Sad 1

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Posted
51 minutes ago, larsgerrits said:

This is not by any chance a tutorial.

 

This is mostly copy-paste from the existing Forge docs intro (which is perfectly fine for people new to modding), and gave code which users can copy-paste into their files without learning anything, resulting in the same code as the example source. 

I think you really missed the point of this topic. Not trying to be a tutorial, that's why this isn't in the user-submitted-tutorials. It was a description of what I did and the places I went to, to figure out how to get the basics of a mod set up.

 

 

52 minutes ago, larsgerrits said:

Also, the CommonProxy system doesn't make sense. Read Code Style, issue #1.

 

Your proxies shouldn't have code to distinguish the dedicated server from the integrated server. Almost all logic should be done on both servers, not just on one of them. That'll cause issues on the other server.

Thanks, I'll re-work my code straight away.

  • 1 month later...

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • After some time minecraft crashes with an error. Here is the log https://drive.google.com/file/d/1o-2R6KZaC8sxjtLaw5qj0A-GkG_SuoB5/view?usp=sharing
    • The specific issue is that items in my inventory wont stack properly. For instance, if I punch a tree down to collect wood, the first block I collected goes to my hand. So when I punch the second block of wood to collect it, it drops, but instead of stacking with the piece of wood already in my hand, it goes to the second slot in my hotbar instead. Another example is that I'll get some dirt, and then when I'm placing it down later I'll accidentally place a block where I don't want it. When I harvest it again, it doesn't go back to the stack that it came from on my hotbar, where it should have gone, but rather into my inventory. That means that if my inventory is full, then the dirt wont be picked up even though there should be space available in the stack I'm holding. The forge version I'm using is 40.3.0, for java 1.18.2. I'll leave the mods I'm using here, and I'd appreciate it if anybody can point me in the right direction in regards to figuring out how to fix this. I forgot to mention that I think it only happens on my server but I'm not entirely sure. PLEASE HELP ME! LIST OF THE MODS. aaa_particles Adorn AdvancementPlaques AI-Improvements AkashicTome alexsdelight alexsmobs AmbientSounds amwplushies Animalistic another_furniture AppleSkin Aquaculture aquamirae architectury artifacts Atlas-Lib AutoLeveling AutoRegLib auudio balm betterfpsdist biggerstacks biomancy BiomesOPlenty blockui blueprint Bookshelf born_in_chaos Botania braincell BrassAmberBattleTowers brutalbosses camera CasinoCraft cfm (MrCrayfish’s Furniture Mod) chat_heads citadel cloth-config Clumps CMDCam CNB cobweb collective comforts convenientcurioscontainer cookingforblockheads coroutil CosmeticArmorReworked CozyHome CrabbersDelight crashexploitfixer crashutilities Create CreativeCore creeperoverhaul cristellib crittersandcompanions Croptopia CroptopiaAdditions CullLessLeaves curios curiouslanterns curiouslights Curses' Naturals CustomNPCs CyclopsCore dannys_expansion decocraft Decoration Mod DecorationDelightRefurbished Decorative Blocks Disenchanting DistantHorizons doubledoors DramaticDoors drippyloadingscreen durabilitytooltip dynamic-fps dynamiclights DynamicTrees DynamicTreesBOP DynamicTreesPlus Easy Dungeons EasyAnvils EasyMagic easy_npc eatinganimation ecologics effective_fg elevatorid embeddium emotecraft enchantlimiter EnchantmentDescriptions EnderMail engineersdecor entityculling entity_model_features entity_texture_features epicfight EvilCraft exlinefurniture expandability explosiveenhancement factory-blocks fairylights fancymenu FancyVideo FarmersDelight fast-ip-ping FastSuite ferritecore finsandtails FixMySpawnR Forge Middle Ages fossil FpsReducer2 furnish GamingDeco geckolib goblintraders goldenfood goodall H.e.b habitat harvest-with-ease hexerei hole_filler huge-structure-blocks HunterIllager iammusicplayer Iceberg illuminations immersive_paintings incubation infinitybuttons inventoryhud InventoryProfilesNext invocore ItemBorders itemzoom Jade jei (Just Enough Items) JetAndEliasArmors journeymap JRFTL justzoom kiwiboi Kobolds konkrete kotlinforforge lazydfu LegendaryTooltips libIPN lightspeed lmft lodestone LongNbtKiller LuckPerms Lucky77 MagmaMonsters malum ManyIdeasCore ManyIdeasDoors marbledsarsenal marg mcw-furniture mcw-lights mcw-paths mcw-stairs mcw-trapdoors mcw-windows meetyourfight melody memoryleakfix Mimic minecraft-comes-alive MineTraps minibosses MmmMmmMmmMmm MOAdecor (ART, BATH, COOKERY, GARDEN, HOLIDAYS, LIGHTS, SCIENCE) MobCatcher modonomicon mods_optimizer morehitboxes mowziesmobs MutantMonsters mysticalworld naturalist NaturesAura neapolitan NekosEnchantedBooks neoncraft2 nerb nifty NightConfigFixes nightlights nocube's_villagers_sell_animals NoSeeNoTick notenoughanimations obscure_api oculus oresabovediamonds otyacraftengine Paraglider Patchouli physics-mod Pillagers Gun PizzaCraft placeableitems Placebo player-animation-lib pneumaticcraft-repressurized polymorph PrettyPipes Prism projectbrazier Psychadelic-Chemistry PuzzlesLib realmrpg_imps_and_demons RecipesLibrary reeves-furniture RegionsUnexplored restrictedportals revive-me Scary_Mobs_And_Bosses selene shetiphiancore ShoulderSurfing smoothboot
    • Hi everyone, I'm currently developing a Forge 1.21 mod for Minecraft and I want to display a custom HUD overlay for a minigame. My goal: When the game starts, all players should see an item/block icon (from the base game, not a custom texture) plus its name/text in the HUD – similar to how the bossbar overlay works. The HUD should appear centered above the hotbar (or at a similar prominent spot), and update dynamically (icon and name change as the target item changes). What I've tried: I looked at many online tutorials and several GitHub repos (e.g. SeasonHUD, MiniHUD), but most of them use NeoForge or Forge versions <1.20 that provide the IGuiOverlay API (e.g. implements IGuiOverlay, RegisterGuiOverlaysEvent). In Forge 1.21, it seems that neither IGuiOverlay nor RegisterGuiOverlaysEvent exist anymore – at least, I can't import them and they are missing from the docs and code completion. I tried using RenderLevelStageEvent as a workaround but it is probably not intended for custom HUDs. I am not using NeoForge, and switching the project to NeoForge is currently not an option for me. I tried to look at the original minecraft source code to see how elements like hearts, hotbar etc are drawn on the screen but I am too new to Minecraft modding to understand. What I'm looking for: What is the correct way to add a custom HUD element (icon + text) in Forge 1.21, given that the previous overlay API is missing? Is there a new recommended event, callback, or method in Forge 1.21 for custom HUD overlays, or is everyone just using a workaround? Is there a minimal open-source example repo for Forge 1.21 that demonstrates a working HUD overlay without relying on NeoForge or deprecated Forge APIs? My ideal solution: Centered HUD element with an in-game item/block icon (from the base game's assets, e.g. a diamond or any ItemStack / Item) and its name as text, with a transparent background rectangle. It should be visible to the players when the mini game is running. Easy to update the item (e.g. static variable or other method), so it can change dynamically during the game. Any help, code snippets, or up-to-date references would be really appreciated! If this is simply not possible right now in Forge 1.21, it would also help to know that for sure. Thank you very much in advance!
    • The simple answer is there is not an easy way. You would need to know how to program in Java, as well as at least some familiarity with how Forge works so you could port the differences. You would also need the sourcecode for the original mod, and permission from the author to modify it, if they did not use some sort of open source license. So it's not impossible, but it would take some effort, but doing so would open up a whole new world of possibilities for you!
  • Topics

×
×
  • Create New...

Important Information

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