1. Nivyox

    Nivyox <p>roast-, meme- and daberator \o> dab</p>

    NIVYOX
    Mod
    monky MONKY
    Member
    Messages:
    4,236
    Hey Guys, it's me! :^)

    Today I will try to teach you on how to start coding chat based mods.

    Disclaimer: I am not an professional coder! I learned this all by myself from watching tutorials on YouTube.
    Disclaimer: I will be using Eclipse for this tutorial.


    Experience with C# or Java is nice to have :p
    It might get really complicated.


    So let's begin!

    [EDIT:]
    Step 0.

    Install Java JDK and at Java_Home to your system variables. Tutorial here: "
    https://confluence.atlassian.com/doc/setting-the-java_home-variable-in-windows-8895.html"

    []
    Step 1.
    Setting up your workspace.

    What you first want to do is download Eclipse Mars,
    Eclipse is the most used Java based programming software.

    [​IMG]

    You can download Eclipse Mars here. (credits to @Samuel_420)

    You probably want to download the installer since it is really easy to use,

    Once you have downloaded it, simply execute it by clicking on it.

    [​IMG]

    You want to download the Eclipse DSL Tool.
    Simple follow the installation wizard and you will see!

    When the installation is done, you simply press launch.

    Step 2.
    Downloading Forge Source Version.
    Now you have to download the right Forge version,
    since Hypixel is now only 1.8, will we download the 1.8 Forge version.
    You can get the Forge files here.
    In this tutorial I will use the forge version forge-1.8-11.14.1334-src, click here if you also want to use this version.
    [​IMG]
    Step 3.
    Setting up Forge in Eclipse

    Once you downloaded the right Forge version, you can place the .ZIP file somewhere where you want your workspace.

    For example, I have my Forge Files at:
    C:\Users\Niek\Desktop\Forge Source versions\forge-1.8 II Hypixel Tutorial

    So, if you know the location of where you want your workspace to be. Extract the Forge Files into that directory, so it will look like this.
    [​IMG]

    Now press shift + right click on white space,
    [​IMG]
    If you press that, the cmd will show up.

    [​IMG]
    Type in the cmd,
    "gradlew setupDevWorkspace eclipse"
    and then press ENTER
    While Forge is setting up the workspace, you can get some popcorn or something to eat :^)
    If you get any errors, please quote me in a message with the error log so I can help fix it.

    When it finished setting up the workspace it should say:
    BUILD SUCCESSFUL

    Step 4.
    The enjoyable part about making Minecraft mods.
    Coding.


    [​IMG]

    When starting Eclipse, a message should popup,
    Your workspace should be at the directory where you extracted your files, and then /eclipse so mine is:
    "C:\Users\Niek\Desktop\Forge Source versions\forge-1.8 II Hypixel Tutorial\eclipse"

    Then press continue.

    So, everything is set up, so we are ready to go!

    Disclaimer: I am not a professional, so the way I am explaining this could be confusing.

    If everything went alright, you will be able to see something like this.
    [​IMG]
    First, we want to rename the package,
    a package is a namespace that organizes sets of classes.

    How do you rename it?
    Like this:
    [​IMG]
    I am going to rename it to me.Niek
    For a general tutorial on renaming packages, click here.

    The first thing what we want to do is registering our events.
    You can do that with this:
    Code:
    @EventHandler
        public void init(FMLInitializationEvent event)
        {
            FMLCommonHandler.instance().bus().register(this);
            MinecraftForge.EVENT_BUS.register(this);
        }
    
    Now we can register our events by using @SubscribeEvent
    Example:

    Code:
    //Fired when a chat message is about to be displayed on the client
    @SubscribeEvent
    public void onChat(ClientChatReceivedEvent event) {
        String message = event.message.getUnformattedText();
            if(message.contains("hi")) {
                     Minecraft.getMinecraft().toggleFullscreen();
            }
    }
    
    What this will do, it will toggle fullscreen if a chat message contains hi.
    If you think about it, it is all really simple, but you have to understand the logic behind it :)

    So, if you want to make a mod which shows you the amount of coins you are earning in a game.
    You can do that like this.
    1. Get the coin message.
    2. Split the message so you only have the amount of coins, (Example: +30 coins (P2WGuy123's Network Booster, double coins weekend), try split the message in a way so the only thing you have in a message is the +30)

    Since you guys may not really understand my type of explanations, will I show you how you can do it!
    Code:
        @SubscribeEvent
        public void xd(ClientChatReceivedEvent event) {
            String message = event.message.getUnformattedText();
            //message is the message which the client receives.
            if(message.startsWith("+") && message.contains("coins") && !message.endsWith("for being generous")) {
                //Checks if the coin message you got isn't the tip message 
                String[] splittedMessage = message.split("coins");
                message = splittedMessage[0].replace("+", "");
                message = message.replace(" ", "");
                int coins = Integer.parseInt(message);
                totalCoins = totalCoins + coins;
            }
        }
    
    So, now you have the coin message you can try to render a string on your screen by using the RenderGameOverlayEvent.
    Code:
    @SubscribeEvent
        public void render(RenderGameOverlayEvent event) {
            if (event.isCancelable() || event.type != ElementType.EXPERIENCE) {
                return;
            }
            FontRenderer fRender = Minecraft.getMinecraft().fontRendererObj;
            fRender.drawString(EnumChatFormatting.GREEN + "Coins: " + EnumChatFormatting.WHITE + totalCoins, 5, 5, 0);
        }
    
    The rendering is done in a really simple way, I am not making it too complicated for now :)

    So, this was my quick tutorial on how to start modding with Minecraft Forge,

    If you need any help, tag me in your reply on this message please,
    I hope you learned something from this,

    I hope you have a nice day!

    If you want to use you mod on Hypixel, make sure you ask
    permission, pm JamieTheGeek if you want to use your mod,
    please don't come to me if you got banned for using something.
     
    #1
    Last edited: Nov 28, 2017
    • Useful x 87
    • Like x 47
    • Hype Train x 4
    • Creative x 3
    • Dislike x 2
    • Agree x 1
    • Helper Lapis x 1
  2. Nivyox

    Nivyox <p>roast-, meme- and daberator \o> dab</p>

    NIVYOX
    Mod
    monky MONKY
    Member
    Messages:
    4,236
    RESERVED

    Update 3/22/2016 -
    When I am home I'll make a tutorial on how to fix the start build error! Patience is key for now!
     
    #2
    Last edited: Mar 22, 2016
    • Like Like x 5
    • Hype Train Hype Train x 1
  3. Nice ;)
     
    #3
    • Like Like x 2
    • Agree Agree x 1
  4. OPDRACHTVENSTER HIER OPENEN
     
    #4
    • Funny Funny x 8
    • Like Like x 6
  5. Nivyox

    Nivyox <p>roast-, meme- and daberator \o> dab</p>

    NIVYOX
    Mod
    monky MONKY
    Member
    Messages:
    4,236
    Ik heb toch uitgelegd dat dat anders is in t engels pannekoek
     
    #5
    • Funny Funny x 9
    • Like Like x 4
    • Agree Agree x 2
  6. Hot damn man! This is a great guide. *bookmarks for later*
     
    #6
    • Agree Agree x 4
    • Like Like x 2
    • Funny Funny x 1
  7. TheAluMinion

    TheAluMinion Well-Known Member

    TheAluMinion
    MVP+
    Messages:
    3,112
    Very useful - still suck at code though.
     
    #7
    • Funny Funny x 3
    • Agree Agree x 1
  8. Nivyox

    Nivyox <p>roast-, meme- and daberator \o> dab</p>

    NIVYOX
    Mod
    monky MONKY
    Member
    Messages:
    4,236
    It is hard tho :p, there are lots of tutorials on YouTube, on how to start coding mods,

    Here is the one:
    https://www.youtube.com/user/ScratchForFun
     
    #8
    • Useful Useful x 3
  9. TheAluMinion

    TheAluMinion Well-Known Member

    TheAluMinion
    MVP+
    Messages:
    3,112
    #9
    • Hype Train Hype Train x 1
  10. - Kevy -

    - Kevy - Well-Known Member

    Kevy
    MVP+
    Death Grips CLUTCH
    MEMBER
    Messages:
    333
    ew eclipse
     
    #10
    • Like Like x 1
    • Agree Agree x 1
    • Hype Train Hype Train x 1
  11. idek how to add mods to minecraft xD
     
    #11
    • Funny Funny x 1
  12. Nivyox

    Nivyox <p>roast-, meme- and daberator \o> dab</p>

    NIVYOX
    Mod
    monky MONKY
    Member
    Messages:
    4,236
    IF you use IntelIJ, what does it actually make better?
    Quick question :p
     
    #12
    • Dislike Dislike x 2
  13. Eclipse can't be installed :-:
    It says: "The installation has failed with an error"
     
    #13
  14. Nivyox

    Nivyox <p>roast-, meme- and daberator \o> dab</p>

    NIVYOX
    Mod
    monky MONKY
    Member
    Messages:
    4,236
    Is that the whole error message?
     
    #14
  15. Yes ;-;
     
    #15
  16. Nivyox

    Nivyox <p>roast-, meme- and daberator \o> dab</p>

    NIVYOX
    Mod
    monky MONKY
    Member
    Messages:
    4,236
    Try reinstalling
     
    #16
  17. Not working
    It says "Installation failed with an error" or "An error was detected" :(
     
    #17
  18. Nivyox

    Nivyox <p>roast-, meme- and daberator \o> dab</p>

    NIVYOX
    Mod
    monky MONKY
    Member
    Messages:
    4,236
    Ill help you tomorrow after Ive done my homework
     
    #18
  19. Okay tyvm, but can you help me in the weekend?
     
    #19
  20. Nivyox

    Nivyox <p>roast-, meme- and daberator \o> dab</p>

    NIVYOX
    Mod
    monky MONKY
    Member
    Messages:
    4,236
    Uhm sure!
     
    #20
    • Like Like x 2

Share This Page