Mod-Making Crash Course Tutorial

View previous topic View next topic Go down

Mod-Making Crash Course Tutorial

Post by Ciabatta on Sat Jul 23, 2016 12:29 am

PART 1 - Instantiating your Mod

Note: Please be sure to follow this tutorial first as this one directly continues from its last step: http://bigsister.forumotion.com/t891-setup-modding-environment-windows


  1. Delete the package "com.example.examplemod" as we no longer need this and it may get in the way.

  2. Right-click on the "src/main/java" folder and select New > Package.

  3. In the New Java Package window, in the "Name" field add a name for your new mod package.  You can call it what you like, but to be consistent with other mods try to use the "com.yourname.yourmodname" convention.  So for this tutorial, I will call this:

    com.bigsis.spookjams

    ...obviously tailor it to your own preference. 
    Once you're done, click the Finish button.

  4. Repeat the process in #3 to create a separate package called:

    com.bigsis.spookjams.proxy

    This will be important later when we create server interfaces for our mod, but for now this has to be here as a placeholder.

  5. Right-click on "com.bigsis.spookjams.proxy" and choose New > Interface. In the "Name" field of the New Java Class window, type in "CommonProxy" and press Finish. No further edits are needed in this interface class at this time.

  6. Right-click on "com.bigsis.spookjams.proxy" and choose New > Class. In the "Name" field of the New Java Class window, type in "ClientProxy" and press Finish. Edit the contents of "ClientProxy.java" to read as follows:

    Code:
    package com.bigsis.spookjams.proxy;

    public class ClientProxy implements CommonProxy {

    }


  7. Right-click on "com.bigsis.spookjams.proxy" and choose New > Class. In the "Name" field of the New Java Class window, type in "ServerProxy" and press Finish. Edit the contents of "ServerProxy.java" to read as follows:

    Code:
    package com.bigsis.spookjams.proxy;

    public class ServerProxy implements CommonProxy {

    }

  8. Right-click on "com.bigsis.spookjams" and choose New > Class. In the "Name" field of the New Java Class window, type in "Reference" and press Finish. Edit the contents of "Reference.java" to read as follows:

    Code:
    package com.bigsis.spookjams; //My comments in this class are present in light-colored lines like this one that follow two forward-slashes ("//"). To remove these, go to "Edit > Find/Replace...", add "//.*" to the Find field, and press "Replace All".

    public class Reference //This is a collection of constants used throughout the mod to help keep the code cleaner by keeping most variable information stored here in a single location.
    {
       public static final String MOD_ID = "bssjm"; //Internal name of your mod, it MUST be unique to prevent clashing with other mods.
       public static final String NAME = "Big Sister's SpookJam Crash Course Mod"; //The name of your mod as displayed on the Minecraft Mod Detail screen.
       public static final String VERSION = "0.1-wheat"; //Your version identifier; you can use numbers, decimals, alpha/beta tags, or you can be like me and get creative (I'm naming my alpha versions after grains and pulses!).
       public static final String MINECRAFT_VERSION = "[1.9.4]"; //The version of Minecraft that this mod is compatible with; you can use a static value, or use special syntax to have it be compatible with other Minecraft version variants.

       public static final String CLIENT_PROXY_CLASS = "com.bigsis.spookjams.proxy.ClientProxy"; //Pointer to the Minecraft client proxy; references the ClientProxy.java class inside the com.bigsis.spookjams.proxy package.
       public static final String SERVER_PROXY_CLASS = "com.bigsis.spookjams.proxy.ServerProxy"; //Pointer to the Minecraft server proxy; references the ServerProxy.java class inside the com.bigsis.spookjams.proxy package.
    }

    If the above is too hard to read because of the word-wrapping, try this link:
    https://gist.github.com/79903e21222e1fa4cf4ec34d63d7b6bf

  9. Right-click on "com.bigsis.spookjams" and choose New > Class. In the "Name" field of the New Java Class window, type in "Spookjams" and press Finish. Edit the contents of "Spookjams.java" to read as follows:

    Code:
    package com.bigsis.spookjams; //My comments in this class are present in light-colored lines like this one that follow two forward-slashes ("//"). To remove these, go to "Edit > Find/Replace...", add "//.*" to the Find field, and press "Replace All".

    import com.bigsis.spookjams.proxy.CommonProxy; //Import this to make our custom CommonProxy instance work.

    import net.minecraftforge.fml.common.Mod; //Import this to make the @Mod annotation work
    import net.minecraftforge.fml.common.Mod.EventHandler; //Import this to make the @EventHandler annotation work
    import net.minecraftforge.fml.common.Mod.Instance; //Import this to make the @Instance annotation work
    import net.minecraftforge.fml.common.SidedProxy; //Import this to make the @SidedProxy annotation work
    import net.minecraftforge.fml.common.event.FMLInitializationEvent; //import this to make this Initialization event work
    import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; //import this to make this Post Initialization event work
    import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; //import this to make this Pre Initialization event work

    @Mod
    (
     modid = Reference.MOD_ID, //Specify the unique MOD ID of your mod, we're getting this from the Reference.java class.
     name = Reference.NAME, //Specify the name of your mod; also being pulled from Reference.java.
     version = Reference.VERSION, //Specify the version of your mod; also being pulled from Reference.java.
     acceptedMinecraftVersions = Reference.MINECRAFT_VERSION //Specify which Minecraft version(s) this mod works on; also being pulled from Reference.java.
    )
    public class Spookjams
    {
     @Instance
     public static Spookjams instance; //Need this to allow Minecraft to instantiate this mod.
     
     @SidedProxy(
     clientSide = Reference.CLIENT_PROXY_CLASS, //Specify the Client proxy; being pulled from Reference.java.
     serverSide = Reference.SERVER_PROXY_CLASS //Specify the Server proxy; being pulled from Reference.java.
     )
     public static CommonProxy proxy; //Need this to instantiate the proxy interface with Minecraft.
     
     @EventHandler
     public void preInit(FMLPreInitializationEvent event) //define what gets called first when this mod is loaded (e.g., loading item or block intialization)
     {
     System.out.println("Pre-Init"); //just some dummy text to serve as a placeholder for future event info -- note that this will appear in the Minecraft Launch Log to let you know when it gets called!
     }
     
     @EventHandler
     public void init(FMLInitializationEvent event) //define what gets called next after the pre-initialization (e.g., loading less critical items or entities)
     {
     System.out.println("Init"); //just some dummy text to serve as a placeholder for future event info -- note that this will appear in the Minecraft Launch Log to let you know when it gets called!
     }
     
     @EventHandler
     public void postInit(FMLPostInitializationEvent event) //define what gets done after everything is loaded in the mod (e.g., loading another mod if it exists)
     {
     System.out.println("Post-Init"); //just some dummy text to serve as a placeholder for future event info -- note that this will appear in the Minecraft Launch Log to let you know when it gets called!
     }
    }

    If the above is too hard to read due to the word-wrapping, try this link:
    https://gist.github.com/ab7971e9de38db4e47b4dc29daeb31dc
     

  10. Going back to the Package Explorer, open the "src/main/resources" folder and open the file in there called "mcmod.info".  This will be a standard text file, not Java, so you will need to recreate some of your earlier work in "Resources.java" by hand.  The end result should be a file that looks like this:

    Code:
    [
    {
      "modid": "bssjm",
      "name": "Big Sister's SpookJam Crash Course Mod",
      "description": "Ciabatta's poor excuse for an attempt to document beginner's Minecraft modding.",
      "version": "0.1-wheat",
      "mcversion": "1.9.4",
      "url": "http://bigsister.forumotion.com/forum",
      "updateUrl": "",
      "authorList": ["Ciabatta"],
      "credits": "To all the wonderful contributors of the Big Sister Gulliver Minecraft Server Community!",
      "logoFile": "",
      "screenshots": [],
      "dependencies": []
    }
    ]

  11. Now you're finished!  Look for a green "Run Client" button in the top panel of Eclipse and click on it.  This will launch a localized instance of Minecraft 1.9.4, meanwhile the Console feedback will show traces of your new mod.

  12. Once in the Minecraft main menu screen, click on the Mods button and look for your fancy new mod in action!  CONGRATULATIONS!!!  You now have a brand new (if currently-empty) MINECRAFT MOD!!!!





Last edited by Ciabatta on Sat Jul 23, 2016 8:01 pm; edited 5 times in total
avatar
Ciabatta
Admin

Posts : 3884
Join date : 2014-01-03
Age : 26
Location : On the road

RP Character Sheet
Name: Ciabatta Sylvia
Personality Trait: Busy
Character Description:

View user profile http://bigsister.forumotion.com

Back to top Go down

Re: Mod-Making Crash Course Tutorial

Post by Ciabatta on Sat Jul 23, 2016 2:06 pm

Edited the main comments to illustrate a way by which you can use the Find/Replace feature in Eclipse to remove all my comments. ^^

_________________
avatar
Ciabatta
Admin

Posts : 3884
Join date : 2014-01-03
Age : 26
Location : On the road

RP Character Sheet
Name: Ciabatta Sylvia
Personality Trait: Busy
Character Description:

View user profile http://bigsister.forumotion.com

Back to top Go down

Re: Mod-Making Crash Course Tutorial

Post by Ciabatta on Sat Jul 23, 2016 8:03 pm

I renamed some of the names to make this tutorial a bit more universal -- so instead of "ciabatta", it now reads "bigsis", and instead of that LOOOONG MOD_ID (which was getting annoying), I renamed it to "bssjm" (or "Big Sister SpookJam Mod"). ^^

_________________
avatar
Ciabatta
Admin

Posts : 3884
Join date : 2014-01-03
Age : 26
Location : On the road

RP Character Sheet
Name: Ciabatta Sylvia
Personality Trait: Busy
Character Description:

View user profile http://bigsister.forumotion.com

Back to top Go down

Re: Mod-Making Crash Course Tutorial

Post by Ciabatta on Sat Jul 23, 2016 8:40 pm

Part 2 - Creating Your First Custom Item

Note: Please be sure to complete Part 1 of this tutorial first as this is a direct continuation of it: http://bigsister.forumotion.com/t895-mod-making-crash-course-tutorial#15583


  1. Right-click over the "src/main/resources" folder and select New > Package. Name this package "assets.bssjm" and press Finish.

  2. Right-click over the "assets.bssjm" package and select New > Package. Name this package "assets.bssjm.lang" and press Finish.

  3. Right-click over the "assets.bssjm" package and select New > Package. Name this package "assets.bssjm.models" and press Finish.

  4. Right-click over the "assets.bssjm" package and select New > Package. Name this package "assets.bssjm.textures" and press Finish.

  5. Right-click over the "assets.bssjm.models" package and select New > Package. Name this package "assets.bssjm.models.item" and press Finish.

  6. Right-click over the "assets.bssjm.textures" package and select New > Package. Name this package "assets.bssjm.textures.items" and press Finish.

  7. You should now have all the resources folders set up to accommodate the creation of a new custom item.  Don't worry if some of the packages disappear or bleed into one another, what matters is that the hierarchy for these packages is maintained.  If you want a less-confusing view, you can click on the View Menu button in the Project Explorer toolbar and switch the Package Presentation to "Hierarchical" rather than "Flat", but that's a matter of preference.

  8. Return to the "src/main/java" folder and right-click over it to select New > Package. Name this package "init" and press Finish.

  9. Right-click again over the "src/main/java" folder and right-click over it to select New Package. Name this package "items" and press Finish.

  10. Right-click over the "init" package and select New > Package. Name this class "ModItems" and press Finish. This class will be used to initialize your new custom items and registering them with Forge.

  11. Right-click over the "items" package and select New > Class.  Name this class "ItemCheese" [we will be creating cheese as our first item!]; but unlike with other classes we've created so far, we will also replace the value in the Superclass field with:

    net.minecraft.item.Item

    Once this is done, you can press Finish.

  12. Before we edit the new classes, let's update Reference.java to accommodate our new cheese item. Go into the "src/main/java" folder, go into the "com.bigsis.spookjams" package, and then open the "Reference.java" class. Edit the file to read as follows:

    Code:
    package com.bigsis.spookjams; //My comments in this class are present in light-colored lines like this one that follow two forward-slashes ("//"). To remove these, go to "Edit > Find/Replace...", add "//.*" to the Find field, and press "Replace All".

    public class Reference //This is a collection of constants used throughout the mod to help keep the code cleaner by keeping most variable information stored here in a single location.
    {
     public static final String MOD_ID = "bssjm"; //Internal name of your mod, it MUST be unique to prevent clashing with other mods.
     public static final String NAME = "Big Sister's SpookJam Crash Course Mod"; //The name of your mod as displayed on the Minecraft Mod Detail screen.
     public static final String VERSION = "0.1-wheat"; //Your version identifier; you can use numbers, decimals, alpha/beta tags, or you can be like me and get creative (I'm naming my alpha versions after grains and pulses!).
     public static final String MINECRAFT_VERSION = "[1.9.4]"; //The version of Minecraft that this mod is compatible with; you can use a static value, or use special syntax to have it be compatible with other Minecraft version variants.

     public static final String CLIENT_PROXY_CLASS = "com.bigsis.spookjams.proxy.ClientProxy"; //Pointer to the Minecraft client proxy; references the ClientProxy.java class inside the com.bigsis.spookjams.proxy package.
     public static final String SERVER_PROXY_CLASS = "com.bigsis.spookjams.proxy.ServerProxy"; //Pointer to the Minecraft server proxy; references the ServerProxy.java class inside the com.bigsis.spookjams.proxy package.

     public static enum SpookjamItems //An enum type is a special data type that enables for a variable to be a set of predefined constants.
     {
     CHEESE("cheese","ItemCheese"); //We are declaring a CHEESE enum to be its common and system name. The declarations go first before the actual instructions on how to parse this below.
     
     private String unlocalizedName; //Declare a blank text string to hold the common name variable of this enum.
     private String registryName; //Declare a blank text string to hold the system name variable of this enum.
     
     SpookjamItems(String unlocalizedNameTarget, String registryNameTarget) //Instructions on how to parse each enum that is declared (in this example: "CHEESE("cheese","ItemCheese"). Note that two parameters are allotted to this enum.
     {
     this.unlocalizedName = unlocalizedNameTarget; //Populate unlocalizedName with the first parameter of the enum (in this example, "cheese").
     this.registryName = registryNameTarget; //Populate registryName with the second parameter of the enum (in this example, "ItemCheese").
     }
     
     public String getUnlocalizedName() //Declare a Get method in order to extract the common name variable of this enum, since it may get referenced again throughout the code.
     {
     return unlocalizedName; //Have this String method return the common name variable of this enum.
     }
     
     public String getRegistryName() //Declare a Get method in order to extract the system name variable of this enum, since it may get referenced again throughout the code.
     {
     return registryName; //Have this String method return the system name variable of this enum.
     }
     }
    }

    If the above is too hard to read due to the word-wrapping, try this link:
    https://gist.github.com/a93aa3c405c246ca3ac8971729c6d53d

  13. Go into the "src/main/java" folder, go into the "com.bigsis.spookjams" package, go into the "Items" package, and then open the "ItemCheese.java" class. Edit the file to read as follows:

    Code:
    package com.bigsis.spookjams.items; //My comments in this class are present in light-colored lines like this one that follow two forward-slashes ("//"). To remove these, go to "Edit > Find/Replace...", add "//.*" to the Find field, and press "Replace All".

    import com.bigsis.spookjams.Reference;  //Import this to recognize our custom Reference.java class.

    import net.minecraft.item.Item; //Need this to recognize Minecraft Item objects.

    public class ItemCheese extends Item
    {
     public ItemCheese() //This is the constructor for your new Cheese Item.
     {
     setUnlocalizedName(Reference.SpookjamItems.CHEESE.getUnlocalizedName()); //Set the common name of this new item from the CHEESE enum we declared in Reference.java.
     setRegistryName(Reference.SpookjamItems.CHEESE.getRegistryName()); //Set the system name of this new item from the CHEESE enum we declared in Reference.java.
     }
    }


    If the above is too hard to read due to the word-wrapping, try this link:
    https://gist.github.com/a07a051b0f6ed3e84e0fc7f46160f60b


  14. Go into the "src/main/java" folder, go into the "com.bigsis.spookjams" package, go into the "init" package, and then open the "ModItems.java" class. Edit the file to read as follows:


    Code:
    package com.bigsis.spookjams.init; //My comments in this class are present in light-colored lines like this one that follow two forward-slashes ("//"). To remove these, go to "Edit > Find/Replace...", add "//.*" to the Find field, and press "Replace All".

    import com.bigsis.spookjams.Reference; //Import this to recognize our custom Reference.java class.
    import com.bigsis.spookjams.items.ItemCheese; //Import this to recognize our custom ItemCheese.java class.

    import net.minecraft.client.Minecraft; //Imported to allow the Minecraft client to be recognized
    import net.minecraft.client.renderer.block.model.ModelResourceLocation; //Imported to allow the ModelResourceLocation class to be recognized.
    import net.minecraft.item.Item; //Imported to allow for Minecraft objects to be registered.
    import net.minecraftforge.fml.common.registry.GameRegistry; //Imported to recognize the use of the GameRegistry class.

    public class ModItems
    {
     public static Item cheese; //This is the name of our new custom item.
     
     public static void init() //This method will initialize this object.
     {
     cheese = new ItemCheese(); //Set the new Item to be a new instance of our custom cheese object as defined in ItemCheese.java.
     }
     
     public static void register() //This will register the item into the game.
     {
     GameRegistry.register(cheese); //Register our custom item in Minecraft using the new Item object we initiated above.
     }
     
     public static void registerRenders() //This will contain all the calls to register the render for each item.
     {
     registerRender(cheese); //Call the private method below.
     }
     
     private static void registerRender(Item item) //This is the new item object that you will register into Minecraft.
     {
     Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory")); //Register this new item by referencing its system name, and specifying that it will be an Inventory item.
     }
    }

    If the above is too hard to read due to the word-wrapping, try this link:
    https://gist.github.com/419c6b3983ac587d9b2a2408d9026aa7


  15. Go into the "src/main/java" folder, go into the "com.bigsis.spookjams" package, go into the "Proxy" package, and then open the "CommonProxy.java" instance. Edit the file to read as follows:

    Code:
    package com.bigsis.spookjams.proxy;

    public interface CommonProxy {
     public void init();
    }

  16. In the same "Proxy" package, and open the "ServerProxy.java" class. Edit the file to read as follows:

    Code:
    package com.bigsis.spookjams.proxy;

    public class ServerProxy implements CommonProxy {
     @Override
     public void init() {}
    }


  17. In the same "Proxy" package, and open the "ClientProxy.java" class. Edit the file to read as follows:

    Code:
    package com.bigsis.spookjams.proxy;

    import com.bigsis.spookjams.init.ModItems;

    public class ClientProxy implements CommonProxy {
     @Override
     public void init() {
     ModItems.registerRenders(); //only call this on the client side and not the server side (for now).
     }
    }

  18. Go into the "src/main/java" folder, go into the "com.bigsis.spookjams" package, and then open the "Spookjams.java" class. Edit the file to read as follows:

    Code:
    package com.bigsis.spookjams; //My comments in this class are present in light-colored lines like this one that follow two forward-slashes ("//"). To remove these, go to "Edit > Find/Replace...", add "//.*" to the Find field, and press "Replace All".

    import com.bigsis.spookjams.init.ModItems; //Import this to recognize our custom ModItems.java class.
    import com.bigsis.spookjams.proxy.CommonProxy; //Import this to recognize our custom CommonProxy.java instance.

    import net.minecraftforge.fml.common.Mod; //Import this to make the @Mod annotation work
    import net.minecraftforge.fml.common.Mod.EventHandler; //Import this to make the @EventHandler annotation work
    import net.minecraftforge.fml.common.Mod.Instance; //Import this to make the @Instance annotation work
    import net.minecraftforge.fml.common.SidedProxy; //Import this to make the @SidedProxy annotation work
    import net.minecraftforge.fml.common.event.FMLInitializationEvent; //import this to make this Initialization event work
    import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; //import this to make this Post Initialization event work
    import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; //import this to make this Pre Initialization event work

    @Mod
    (
     modid = Reference.MOD_ID, //Specify the unique MOD ID of your mod, we're getting this from the Reference.java class.
     name = Reference.NAME, //Specify the name of your mod; also being pulled from Reference.java.
     version = Reference.VERSION, //Specify the version of your mod; also being pulled from Reference.java.
     acceptedMinecraftVersions = Reference.MINECRAFT_VERSION //Specify which Minecraft version(s) this mod works on; also being pulled from Reference.java.
    )
    public class Spookjams
    {
     @Instance
     public static Spookjams instance; //Need this to allow Minecraft to instantiate this mod.
     
     @SidedProxy(
     clientSide = Reference.CLIENT_PROXY_CLASS, //Specify the Client proxy; being pulled from Reference.java.
     serverSide = Reference.SERVER_PROXY_CLASS //Specify the Server proxy; being pulled from Reference.java.
     )
     public static CommonProxy proxy; //Need this to instantiate the proxy interface with Minecraft.
     
     @EventHandler
     public void preInit(FMLPreInitializationEvent event) //define what gets called first when this mod is loaded (e.g., loading item or block intialization)
     {
     System.out.println("Pre-Init"); //just some dummy text to serve as a placeholder for future event info -- note that this will appear in the Minecraft Launch Log to let you know when it gets called!
     
     ModItems.init();
     ModItems.register();
     }
     
     @EventHandler
     public void init(FMLInitializationEvent event) //define what gets called next after the pre-initialization (e.g., loading less critical items or entities)
     {
     System.out.println("Init"); //just some dummy text to serve as a placeholder for future event info -- note that this will appear in the Minecraft Launch Log to let you know when it gets called!
     proxy.init(); //initialize the client and server proxies that interface with Minecraft..
     }
     
     @EventHandler
     public void postInit(FMLPostInitializationEvent event) //define what gets done after everything is loaded in the mod (e.g., loading another mod if it exists)
     {
     System.out.println("Post-Init"); //just some dummy text to serve as a placeholder for future event info -- note that this will appear in the Minecraft Launch Log to let you know when it gets called!
     }
    }

    If the above is too hard to read due to the word-wrapping, try this link:
    https://gist.github.com/a23ee2aa15be60b91db3fbbf89085ce1


  19. This concludes the last of the programming requirements for adding a new item, now it's time to get into the nitty-gritty model and textures!  First, create an image of cheese that has a transparent background, is 16x16, and is saved in a PNG format... if you don't know how, you can also find a free sample asset of cheese, or other similar assets, here...

    http://bigsister.forumotion.com/t896-item-texture-assets

  20. Inside your Windows' file explorer, copy your new cheese.png file and save it inside your mod's asset location inside the Eclipse folder.  Assuming you remember how to get into the SpookJams folder (see the tutorial on setting up the development environment in Windows), the location to save it in will be.... 

    ...Spookjams\src\main\resources\assets\bssjm\textures\items


  21. While you're in your Windows' file explorer, go into your mod's models folder location inside the Eclipse folder; the location to travel to will be....

    ...Spookjams\src\main\resources\assets\bssjm\models\item

    Once there, create a new blank text file and name it "ItemCheese.json".

  22. While you're still in your Windows' file explorer, go into your mod's lang folder location inside the Eclipse folder; the location to travel to will be....

    ...Spookjams\src\main\resources\assets\bssjm\lang

    Once there, create a new blank text file and name it "en_US.lang".


  23. Return to Eclipse, go back into the "src/main/resources" folder, open the "assets.bssjm" package, open the "models.item" package, and open the "ItemCheese.json" file... we can edit it here in Eclipse using its native text editor. Edit ItemCheese.json so it reads as follows:

    Code:
    {
        "parent": "item/generated",
        "textures": {
            "layer0": "bssjm:items/cheese"
        },
        "display": {
            "thirdperson": {
                "rotation": [ -90, 0, 9 ],
                "translation": [ 0, 1, -3 ],
                "scale": [ 0.55, 0.55, 0.55 ]
            },
            "firstperson": {
                "rotation": [ 0, -135, 25 ],
                "translation": [ 0, 4, 2],
                "scale": [ 1.7, 1.7, 1.7 ]
            }
        }
    }


  24. Go back into the "src/main/resources" folder, open the "assets.bssjm" package, and open the "lang" package, and then open the "en_US.lang" file. Edit it to include the following line:

    Code:
    item.cheese.name=Cheese

  25. And you're finished! Use the Run Client button in the Eclipse toolbar to launch Minecraft, and in creative you can use this command to give yourself your new item:

    /give @a bssjm:ItemCheese

    Have fun!








avatar
Ciabatta
Admin

Posts : 3884
Join date : 2014-01-03
Age : 26
Location : On the road

RP Character Sheet
Name: Ciabatta Sylvia
Personality Trait: Busy
Character Description:

View user profile http://bigsister.forumotion.com

Back to top Go down

Re: Mod-Making Crash Course Tutorial

Post by Asonja_Masenko on Sat Jul 23, 2016 9:52 pm

The next thing on your list: Mix those two together XD

This was basically the exact same steps that I followed. And let me point this out: Once you make the first item (Which is the most complicated), the more after that will become SUPER easy.
avatar
Asonja_Masenko

Posts : 28
Join date : 2016-07-04
Age : 17

RP Character Sheet
Name: Asonja Masenko
Personality Trait: Quiet
Character Description:

View user profile

Back to top Go down

Re: Mod-Making Crash Course Tutorial

Post by PTpirahna on Sun Jul 24, 2016 4:05 am

All I can say is that I'm astonished that I managed to name the package the correct thing before we were given a standardized name. (Well almost)
avatar
PTpirahna

Posts : 196
Join date : 2014-09-27
Age : 15
Location : Watching you on the dynmap

RP Character Sheet
Name: ???
Personality Trait: Loyal
Character Description:

View user profile

Back to top Go down

Re: Mod-Making Crash Course Tutorial

Post by Ciabatta on Sun Jul 24, 2016 10:34 pm

Part 3 - Creating a Crafting Recipe for your First Custom Item

Note: Please be sure to complete Part 2 of this tutorial first as this is a direct continuation of it: http://bigsister.forumotion.com/t895-mod-making-crash-course-tutorial#15597


  1. Go to the "src/main/java" package, go to the "com.bigsis.spookjams" package, right-click the "init" package, and select New > Class. Name this new class "ModCrafting" and press Finish.

  2. Open the new "ModCrafting" class and edit the contents as follows to add a crafting recipe for cheese,... since milk is involved and milk comes in EXPENSIVE iron buckets, we also sprinkle a bit more code to get the bucket back when finished:

    Code:
    package com.bigsis.spookjams.init; //My comments in this class are present in light-colored lines like this one that follow two forward-slashes ("//"). To remove these, go to "Edit > Find/Replace...", add "//.*" to the Find field, and press "Replace All".

    import net.minecraft.init.Blocks; //Imported to recognize Minecraft Block objects.
    import net.minecraft.init.Items; //Imported to recognize Minecraft Item objects.
    import net.minecraft.item.ItemStack; //Imported to recognize the ItemStack object.
    import net.minecraftforge.fml.common.registry.GameRegistry; //Imported to recognize the GameRegistry object.

    public class ModCrafting {
       public static void register()
       {
          GameRegistry.addShapedRecipe //This creates a shaped recipe, which is the type of recipe that requires specific placement on the crafting grid.
          (
                new ItemStack(ModItems.cheese, 4), //This recipe is to make cheese, specifically 4 wedges of it.
                "BMB", //This recipe specifically calls for a horizontal row of a milk bucket in the center, flanked by two brown mushrooms; note that since we only specify one row on the grid, you can craft these items on any row.
                'B', Blocks.BROWN_MUSHROOM, //This specifies that "B" stands for the Brown Mushroom "bush", not the block from a giant brown mushroom. Note that the use of the single quote it intentional... it MUST BE IN SINGLE QUOTES!
                'M', new ItemStack(Items.MILK_BUCKET.setContainerItem(Items.BUCKET)) //This specifies that "M" stands for a milk-filled bucket; to avoid using up a whole metal bucket just to make cheese, we also indicate that an empty bucket be returned after this crafting recipe is processed.  Note that the use of the single quote it intentional... it MUST BE IN SINGLE QUOTES!
          );
       }
    }

    If the above is too hard to read due to the word-wrapping, try this link:
    https://gist.github.com/dd5056ab118c4fad67d0fffb766f763f


  3. Go to the "src/main/java" package, go to the "com.bigsis.spookjams" package, and open the "Spookjams.java" class.  Edit the contents of it as follows:

    Code:
    package com.bigsis.spookjams; //My comments in this class are present in light-colored lines like this one that follow two forward-slashes ("//"). To remove these, go to "Edit > Find/Replace...", add "//.*" to the Find field, and press "Replace All".

    import com.bigsis.spookjams.init.ModCrafting; //Import this to recognize our custom ModCrafting.java class.
    import com.bigsis.spookjams.init.ModItems; //Import this to recognize our custom ModItems.java class.
    import com.bigsis.spookjams.proxy.CommonProxy; //Import this to recognize our custom CommonProxy.java instance.

    import net.minecraftforge.fml.common.Mod; //Import this to make the @Mod annotation work
    import net.minecraftforge.fml.common.Mod.EventHandler; //Import this to make the @EventHandler annotation work
    import net.minecraftforge.fml.common.Mod.Instance; //Import this to make the @Instance annotation work
    import net.minecraftforge.fml.common.SidedProxy; //Import this to make the @SidedProxy annotation work
    import net.minecraftforge.fml.common.event.FMLInitializationEvent; //import this to make this Initialization event work
    import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; //import this to make this Post Initialization event work
    import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; //import this to make this Pre Initialization event work

    @Mod
    (
       modid = Reference.MOD_ID,                        //Specify the unique MOD ID of your mod, we're getting this from the Reference.java class.
       name = Reference.NAME,                           //Specify the name of your mod; also being pulled from Reference.java.
       version = Reference.VERSION,                      //Specify the version of your mod; also being pulled from Reference.java.
       acceptedMinecraftVersions = Reference.MINECRAFT_VERSION   //Specify which Minecraft version(s) this mod works on; also being pulled from Reference.java.
    )
    public class Spookjams
    {
       @Instance
       public static Spookjams instance; //Need this to allow Minecraft to instantiate this mod.
       
       @SidedProxy(
                clientSide = Reference.CLIENT_PROXY_CLASS,   //Specify the Client proxy; being pulled from Reference.java.
                serverSide = Reference.SERVER_PROXY_CLASS    //Specify the Server proxy; being pulled from Reference.java.
                )
       public static CommonProxy proxy; //Need this to instantiate the proxy interface with Minecraft.
       
       @EventHandler
       public void preInit(FMLPreInitializationEvent event) //define what gets called first when this mod is loaded (e.g., loading item or block intialization)
       {
          System.out.println("Pre-Init"); //just some dummy text to serve as a placeholder for future event info -- note that this will appear in the Minecraft Launch Log to let you know when it gets called!
          
          ModItems.init(); //initialize our custom items
          ModItems.register(); //register our custom items
       }
       
       @EventHandler
       public void init(FMLInitializationEvent event) //define what gets called next after the pre-initialization (e.g., loading less critical items or entities)
       {
          System.out.println("Init"); //just some dummy text to serve as a placeholder for future event info -- note that this will appear in the Minecraft Launch Log to let you know when it gets called!
          proxy.init(); //initialize the client and server proxies that interface with Minecraft.
          
          ModCrafting.register(); //register our custom crafting recipes
       }
       
       @EventHandler
       public void postInit(FMLPostInitializationEvent event) //define what gets done after everything is loaded in the mod (e.g., loading another mod if it exists)
       {
          System.out.println("Post-Init"); //just some dummy text to serve as a placeholder for future event info -- note that this will appear in the Minecraft Launch Log to let you know when it gets called!
       }
    }

    If the above is too hard to read due to the word-wrapping, try this link:
    https://gist.github.com/b16bcd2dfca8c22f7f9ff5506ea6163e


  4. Congratulations, you're finished! See? that wasn't so bad!  Go ahead and press the Run Client button in the Eclipse toolbar to launch Minecraft with your crafting recipe update. When you put a single milk bucket in the middle of any of the crafting grid's rows, and then place two brown mushrooms on the left and right of it, it will let you craft 4 cheese wedges... and you get your bucket back too!  Enjoy!


avatar
Ciabatta
Admin

Posts : 3884
Join date : 2014-01-03
Age : 26
Location : On the road

RP Character Sheet
Name: Ciabatta Sylvia
Personality Trait: Busy
Character Description:

View user profile http://bigsister.forumotion.com

Back to top Go down

Re: Mod-Making Crash Course Tutorial

Post by Ciabatta on Sun Jul 24, 2016 10:56 pm

Part 4 - Adding your First Custom Item to the Creative Menu

Note: Please be sure to complete Part 3 of this tutorial first as this is a direct continuation of it: http://bigsister.forumotion.com/t895-mod-making-crash-course-tutorial#15601



  1. This tutorial will be brief since we only have to make a quick update to the "ItemCheese.java" class to allow your cheese to display on the Creative Menu!  Go to the "src/main/java" folder, go to the "com.bigsis.spookjams" package, go to the "items" package, and then open the "ItemCheese.java" class.  Edit the file as follows, paying attention to the "this.setCreativeTab" line:

    Code:
    package com.bigsis.spookjams.items; //My comments in this class are present in light-colored lines like this one that follow two forward-slashes ("//"). To remove these, go to "Edit > Find/Replace...", add "//.*" to the Find field, and press "Replace All".

    import com.bigsis.spookjams.Reference;  //Import this to recognize our custom Reference.java class.

    import net.minecraft.creativetab.CreativeTabs; //Import this to recognize Minecraft Creative Tabs.
    import net.minecraft.item.Item; //Need this to recognize Minecraft Item objects.

    public class ItemCheese extends Item
    {
       public ItemCheese() //This is the constructor for your new Cheese Item.
       {
          setUnlocalizedName(Reference.SpookjamItems.CHEESE.getUnlocalizedName()); //Set the common name of this new item from the CHEESE enum we declared in Reference.java.
          setRegistryName(Reference.SpookjamItems.CHEESE.getRegistryName()); //Set the system name of this new item from the CHEESE enum we declared in Reference.java.
          this.setCreativeTab(CreativeTabs.FOOD); //Specify that this item appear in the Foodstuffs category of the standard Creative Menu.
       }
    }

    If the above is too hard to read due to the word-wrapping, try this link:
    https://gist.github.com/5a43e7966cede356b65fa266b666b016


  2. And believe it or not, you're done!  Launch the game, go into Creative Mode, and enjoy the accessibility of your cheese item! Note that we could have always created a new Creative Tab and added the cheese there but... small steps, folks.  Small steps... ^^


avatar
Ciabatta
Admin

Posts : 3884
Join date : 2014-01-03
Age : 26
Location : On the road

RP Character Sheet
Name: Ciabatta Sylvia
Personality Trait: Busy
Character Description:

View user profile http://bigsister.forumotion.com

Back to top Go down

Re: Mod-Making Crash Course Tutorial

Post by Ciabatta on Sun Jul 24, 2016 11:34 pm

Part 5 - Making Your First Custom Item Edible

Note: Since this step obsoletes what was shown in Part 4, please be sure to complete Part 3 of this tutorial instead as this can be a direct continuation of it: http://bigsister.forumotion.com/t895-mod-making-crash-course-tutorial#15601


  1. This tutorial will be brief since we only have to make a quick update to the "ItemCheese.java" class to allow your cheese to display on the Creative Menu!  Go to the "src/main/java" folder, go to the "com.bigsis.spookjams" package, go to the "items" package, and then open the "ItemCheese.java" class.  Edit the file as follows, noting that we're converting it into an "ItemFood" rather than "Item" object, and adding some standard hunger-filling and saturation values:

    Code:
    package com.bigsis.spookjams.items; //My comments in this class are present in light-colored lines like this one that follow two forward-slashes ("//"). To remove these, go to "Edit > Find/Replace...", add "//.*" to the Find field, and press "Replace All".

    import com.bigsis.spookjams.Reference;  //Import this to recognize our custom Reference.java class.

    import net.minecraft.creativetab.CreativeTabs; //Import this to recognize Minecraft Creative Tabs.
    import net.minecraft.item.ItemFood; //Need this to recognize Minecraft Food Item objects.

    public class ItemCheese extends ItemFood //Give this item food attributes.
    {
       public ItemCheese() //This is the constructor for your new Cheese Item.
       {
          super(6, 0.7F, false); //Specify how many half-hearts are provided after eating the cheese, how long its saturation duration should be (because fat is highly satiating!), and whether you can feed this to wolves (NO! dairy isn't good for canines). ;)
          setUnlocalizedName(Reference.SpookjamItems.CHEESE.getUnlocalizedName()); //Set the common name of this new item from the CHEESE enum we declared in Reference.java.
          setRegistryName(Reference.SpookjamItems.CHEESE.getRegistryName()); //Set the system name of this new item from the CHEESE enum we declared in Reference.java.

          //The below is obsolete if we're already defining this as a food item, or if you're not planning to display this anywhere other than the Foodstuffs Creative Tab.
          //this.setCreativeTab(CreativeTabs.FOOD); //Specify that this item appear in the Foodstuffs category of the standard Creative Menu.
       }
    }

    If the above is too hard to read due to the word-wrapping, try this link:
    https://gist.github.com/052c52c18b22a31cf406a60d7897fa72

    Of interesting note, we are also disabling the Creative Tab code from Part 4, as this is already called automatically in the ItemFood object class... we may reenable it in the future if we create our own Creative Menu Tab, but for now this item WILL appear in the FoodStuffs Creative tab purely on account of being an "ItemFood".


  2. And that's all! The core Minecraft classes are already doing the heavy-lifting for you as far as the animation and other specifics are concerned. We can also add other cool nifty tricks to do things like add potion effects after eating,... we won't try this until much much later, but if you want to get a head start you can view the additional ItemFood methods by going to the "Referenced Libraries" folder, opening the "forgeSrc-..." jar, opening the "net" package, opening the "item" package, and opening the "ItemFood.class" file. 

    Enjoy your cheese wedge!


avatar
Ciabatta
Admin

Posts : 3884
Join date : 2014-01-03
Age : 26
Location : On the road

RP Character Sheet
Name: Ciabatta Sylvia
Personality Trait: Busy
Character Description:

View user profile http://bigsister.forumotion.com

Back to top Go down

Re: Mod-Making Crash Course Tutorial

Post by Ciabatta on Wed Jul 27, 2016 1:07 am

Whoops... haven't had a chance to progress this further but here are a few of the tutorials coming up next...

1) Adding additional item(s)
2) Adding a composite item from new custom items
3) Adding a new custom Creative tab
4) Adding a new furnace recipe
5) Adding a new block!  

Good times ahead!  Happy Cia

_________________
avatar
Ciabatta
Admin

Posts : 3884
Join date : 2014-01-03
Age : 26
Location : On the road

RP Character Sheet
Name: Ciabatta Sylvia
Personality Trait: Busy
Character Description:

View user profile http://bigsister.forumotion.com

Back to top Go down

Re: Mod-Making Crash Course Tutorial

Post by Ciabatta on Fri Jul 29, 2016 2:21 pm

Part 6 - Adding a Second Custom Item

Note: Despite being a bit redundant, it's important to see just how much work is needed to create multiple new items in Minecraft -- assuming they are simple additions, it really doesn't require all that much extra work.  In any event, be sure to complete Part 5 of this tutorial first as this is a direct continuation of it: http://bigsister.forumotion.com/t895-mod-making-crash-course-tutorial#15603


  1. Go to the "src/main/java" folder and then open "Reference.java". Update the file as follows, noting the new enum declaration for our new item (gluten-free bread!) which requires us to turn the semi-colon after the CHEESE enum into a comma:

    Code:
    package com.bigsis.spookjams; //My comments in this class are present in light-colored lines like this one that follow two forward-slashes ("//"). To remove these, go to "Edit > Find/Replace...", add "//.*" to the Find field, and press "Replace All".

    public class Reference //This is a collection of constants used throughout the mod to help keep the code cleaner by keeping most variable information stored here in a single location.
    {
     public static final String MOD_ID = "bssjm"; //Internal name of your mod, it MUST be unique to prevent clashing with other mods.
     public static final String NAME = "Big Sister's SpookJam Crash Course Mod"; //The name of your mod as displayed on the Minecraft Mod Detail screen.
     public static final String VERSION = "0.1-wheat"; //Your version identifier; you can use numbers, decimals, alpha/beta tags, or you can be like me and get creative (I'm naming my alpha versions after grains and pulses!).
     public static final String MINECRAFT_VERSION = "[1.9.4]"; //The version of Minecraft that this mod is compatible with; you can use a static value, or use special syntax to have it be compatible with other Minecraft version variants.

     public static final String CLIENT_PROXY_CLASS = "com.bigsis.spookjams.proxy.ClientProxy"; //Pointer to the Minecraft client proxy; references the ClientProxy.java class inside the com.bigsis.spookjams.proxy package.
     public static final String SERVER_PROXY_CLASS = "com.bigsis.spookjams.proxy.ServerProxy"; //Pointer to the Minecraft server proxy; references the ServerProxy.java class inside the com.bigsis.spookjams.proxy package.

     public static enum SpookjamItems //An enum type is a special data type that enables for a variable to be a set of predefined constants.
     {
     CHEESE("cheese","ItemCheese"), //We are declaring a CHEESE enum to be its common and system name. The declarations go first before the actual instructions on how to parse this below.
     GF_BREAD("gf_bread","ItemGFBread"); //NOTE THE NEW COMMA AFTER THE CHEESE ENUM!!!  We are declaring a GF_BREAD enum to be its common and system name. The declarations go first before the actual instructions on how to parse this below.
     
     private String unlocalizedName; //Declare a blank text string to hold the common name variable of this enum.
     private String registryName; //Declare a blank text string to hold the system name variable of this enum.
     
     SpookjamItems(String unlocalizedNameTarget, String registryNameTarget) //Instructions on how to parse each enum that is declared (in this example: "CHEESE("cheese","ItemCheese"). Note that two parameters are allotted to this enum.
     {
     this.unlocalizedName = unlocalizedNameTarget; //Populate unlocalizedName with the first parameter of the enum (in this example, "cheese").
     this.registryName = registryNameTarget; //Populate registryName with the second parameter of the enum (in this example, "ItemCheese").
     }
     
     public String getUnlocalizedName() //Declare a Get method in order to extract the common name variable of this enum, since it may get referenced again throughout the code.
     {
     return unlocalizedName; //Have this String method return the common name variable of this enum.
     }
     
     public String getRegistryName() //Declare a Get method in order to extract the system name variable of this enum, since it may get referenced again throughout the code.
     {
     return registryName; //Have this String method return the system name variable of this enum.
     }
     }
    }

    If the above is too hard to read due to the word-wrapping, try this link:
    https://gist.github.com/e66fa851a5248e5284ef27cadc1603be



  2. Go to the "src/main/java" folder, click on the "items" package, and right-click to select New > Class. Name the class "ItemGFBread" and give it a Superclass of:

    net.minecraft.item.ItemFood

    Then open "ItemGFBread.java" and edit the file as follows:

    Code:
    package com.bigsis.spookjams.items; //My comments in this class are present in light-colored lines like this one that follow two forward-slashes ("//"). To remove these, go to "Edit > Find/Replace...", add "//.*" to the Find field, and press "Replace All".

    import com.bigsis.spookjams.Reference; //Import this to recognize our custom Reference.java class.
    import net.minecraft.item.ItemFood; //Import this to recognize Minecraft ItemFood objects.

    public class ItemGFBread extends ItemFood { //Give this item food attributes.

     public ItemGFBread() //This is the constructor for your new Cheese Item.
     {
     super(5, 0.6F, false);//Specify how many half-hearts are provided after eating the gluten-free bread, how long its saturation duration should be (this should be no different than wheat-based bread!), and whether you can feed this to wolves (NO! grains are HORRIBLE for canines).
     setUnlocalizedName(Reference.SpookjamItems.GF_BREAD.getUnlocalizedName()); //Set the common name of this new item from an enum we declared in Reference.java.
     setRegistryName(Reference.SpookjamItems.GF_BREAD.getRegistryName()); //Set the system name of this new item from an enum we declared in Reference.java.
     }


    }

    If the above is too hard to read due to the word-wrapping, try this link:
    https://gist.github.com/8b42d8326e9b4c77f99ec2f9ae37b114



  3. Go to the "src/main/java" folder, open the "init" package, and then open "ModItems.java". Update the file as follows, noting the addition of a new public static Item declaration and the new import line:

    Code:
    package com.bigsis.spookjams.init; //My comments in this class are present in light-colored lines like this one that follow two forward-slashes ("//"). To remove these, go to "Edit > Find/Replace...", add "//.*" to the Find field, and press "Replace All".

    import com.bigsis.spookjams.Reference; //Import this to recognize our custom Reference.java class.
    import com.bigsis.spookjams.items.ItemCheese; //Import this to recognize our custom ItemCheese.java class.
    import com.bigsis.spookjams.items.ItemGFBread; //Import this to recognize our custom ItemGFBread.java class.

    import net.minecraft.client.Minecraft; //Imported to allow the Minecraft client to be recognized
    import net.minecraft.client.renderer.block.model.ModelResourceLocation; //Imported to allow the ModelResourceLocation class to be recognized.
    import net.minecraft.item.Item; //Imported to allow for Minecraft objects to be registered.
    import net.minecraftforge.fml.common.registry.GameRegistry; //Imported to recognize the use of the GameRegistry class.

    public class ModItems
    {
     public static Item cheese; //This is the name of our new custom item.
     public static Item gf_bread; //This is the name of our second custom item.
     
     public static void init() //This method will initialize this object.
     {
     cheese = new ItemCheese(); //Set the new Item to be a new instance of our custom cheese object as defined in ItemCheese.java.
     gf_bread = new ItemGFBread(); //Set the second new Item to be a new instance of our gluten-free bread object as defined in ItemGFBread.java.
     }
     
     public static void register() //This will register the item into the game.
     {
     GameRegistry.register(cheese); //Register our custom item in Minecraft using the new Item object we initiated above.
     GameRegistry.register(gf_bread); //Register our second custom item.
     }
     
     public static void registerRenders() //This will contain all the calls to register the render for each item.
     {
     registerRender(cheese); //Call the private method below.
     registerRender(gf_bread); //Call the private method below.
     }
     
     private static void registerRender(Item item) //This is the new item object that you will register into Minecraft.
     {
     Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory")); //Register this new item by referencing its system name, and specifying that it will be an Inventory item.
     }
    }

    If the above is too hard to read due to the word-wrapping, try this link:
    https://gist.github.com/6d728ea672bc5608604b88b7263a7dfa



  4. In the same package open "ModCrafting.java" and edit it as follows to give the gluten-free bread a crafting recipe:

    Code:
    package com.bigsis.spookjams.init; //My comments in this class are present in light-colored lines like this one that follow two forward-slashes ("//"). To remove these, go to "Edit > Find/Replace...", add "//.*" to the Find field, and press "Replace All".

    import net.minecraft.init.Blocks; //Imported to recognize Minecraft Block objects.
    import net.minecraft.init.Items; //Imported to recognize Minecraft Item objects.
    import net.minecraft.item.ItemStack; //Imported to recognize the ItemStack object.
    import net.minecraftforge.fml.common.registry.GameRegistry; //Imported to recognize the GameRegistry object.

    public class ModCrafting {
     public static void register()
     {
     GameRegistry.addShapedRecipe //This creates a shaped recipe, which is the type of recipe that requires specific placement on the crafting grid.
     (
     new ItemStack(ModItems.cheese, 4), //This recipe is to make cheese, specifically 4 wedges of it.
     "BMB", //This recipe specifically calls for a horizontal row of a milk bucket in the center, flanked by two brown mushrooms; note that since we only specify one row on the grid, you can craft these items on any row.
     'B', Blocks.BROWN_MUSHROOM, //This specifies that "B" stands for the Brown Mushroom "bush", not the block from a giant brown mushroom. Note that the use of the single quote it intentional... it MUST BE IN SINGLE QUOTES!
     'M', new ItemStack(Items.MILK_BUCKET.setContainerItem(Items.BUCKET)) //This specifies that "M" stands for a milk-filled bucket; to avoid using up a whole metal bucket just to make cheese, we also indicate that an empty bucket be returned after this crafting recipe is processed.  Note that the use of the single quote it intentional... it MUST BE IN SINGLE QUOTES!
     );
     GameRegistry.addShapedRecipe
     (
     new ItemStack(ModItems.gf_bread, 3), //This recipe is to make gluten-free bread, specifically 3 loaves of it (because the ingredients are more nutrient-dense).
     "PPP", //This recipe specifically calls for a horizontal row of potatoes; note that since we only specify one row on the grid, you can craft these items on any row.
     'P', Items.POTATO //This specifies that "P" stands for "potato". Note that the use of the single quote it intentional... it MUST BE IN SINGLE QUOTES!
     );
     }
    }

    If the above is too hard to read due to the word-wrapping, try this link:
    https://gist.github.com/536e6a8546873f95f7f4b75a4857ab53



  5. Create an image of gluten-free bread that has a transparent background, is 16x16, and is saved in a PNG format... if you don't know how, you can also find a free sample asset of gluten-free bread from this link... 

    http://bigsister.forumotion.com/t896-item-texture-assets#15604


  6. Copy your new gf_bread.png file and save it inside your mod's asset location inside the Eclipse folder.  The location to save it in will be.... 

    ...Spookjams\src\main\resources\assets\bssjm\textures\items

    Alternatively, you can drag and drop gf_bread.png into the "src/main/resources" > "textures.items" package in Eclipse and it should allow you to import the asset directly.


  7. Go to the "src/main/resources" folder, open the "assets.bssjm" package, open the "models.item" package, and select the "ItemCheese.json" file, copy it, then paste it over itself to create a duplicate.  Name this duplicate "ItemGFBread.json" and edit it as follows:

    Code:
    {
        "parent": "item/generated",
        "textures": {
            "layer0": "bssjm:items/gf_bread"
        },
        "display": {
            "thirdperson": {
                "rotation": [ -90, 0, 9 ],
                "translation": [ 0, 1, -3 ],
                "scale": [ 0.55, 0.55, 0.55 ]
            },
            "firstperson": {
                "rotation": [ 0, -135, 25 ],
                "translation": [ 0, 4, 2],
                "scale": [ 1.7, 1.7, 1.7 ]
            }
        }
    }



  8. Go back into the "src/main/resources" folder, open the "assets.bssjm" package, and open the "lang" package, and then open the "en_US.lang" file. Edit it to include the following line:

    item.gf_bread.name=Gluten-Free Bread


  9. And you're done! Launch the game, and enjoy your cheese and gluten-free bread! Yum! Smile




avatar
Ciabatta
Admin

Posts : 3884
Join date : 2014-01-03
Age : 26
Location : On the road

RP Character Sheet
Name: Ciabatta Sylvia
Personality Trait: Busy
Character Description:

View user profile http://bigsister.forumotion.com

Back to top Go down

Re: Mod-Making Crash Course Tutorial

Post by Ciabatta on Sat Aug 20, 2016 9:19 pm

Part 7 - Creating a Furnace Recipe

Note: Be sure to complete Part 6 of this tutorial first as this is a direct continuation of it: 
http://bigsister.forumotion.com/t895-mod-making-crash-course-tutorial#15634


  1. Prior to beginning, I used Part 6 of this tutorial to create some new items for the game, specifically a boiled egg for this tutorial...



    I also created a milk chocolate bar more for fun and to reuse a decommissioned art asset: 



    It was also a good opportunity to practice the crafting lessons in Part 3 of this tutorial.  The actual crafting recipe for this milk chocolate bar is as follows [check the comments for more explanation]:

    Code:
     GameRegistry.addShapedRecipe
     (
     new ItemStack(ModItems.chocolatebar, 1), //This recipe is to make a milk
                                                chocolate bar -- inferior to
                                                dark chocolate, heh.  

     "SCS", //This represents the first row of recipe items,
              consisting of two sugars flanking a cocoa bean.

     "SCS", //This represents the second row of recipe items,
              consisting of two sugars flanking a cocoa bean.

     "SMS", //This represents the third row of recipe items,
              consisting of two sugars flanking a milk bucket.

     'S', Items.SUGAR, //This specifies that "S" stands for sugar [boo!].

     'C', new ItemStack(Items.DYE, 1, 3), //This specifies that "C" stands
                                            for cacao beans (one Dye with
                                            metadata #3).

     'M', new ItemStack(Items.MILK_BUCKET.setContainerItem(Items.BUCKET))
          //This specifies that "M" stands for a milk-filled bucket;
            to avoid using up a whole metal bucket just to make cheese,
            we also indicate that an empty bucket be returned after this
            crafting recipe is processed.  Note that the use of the single
            quote it intentional... it MUST BE IN SINGLE QUOTES!
     );

    And yields the following.....



    There is no need to go more in-depth into how these new items were created... just review the old lessons and you have a general understanding of how they're added.  Smile

  2. Now that we have our new assets, and especially our new ItemBoiledEgg, go ahead into the "src/main/java" folder, open the "init" package, and then open "ModCrafting.java". The actual syntax for adding new Furnace Recipes is pretty simple, you only need to add the following:

    Code:
    GameRegistry.addSmelting //this creates a smelting recipe,
                               which is a simple one-to-one exchange
    (
     Items.EGG, //Indicates the item you add into the furnace to smelt;
                  in this example, an egg.

     new ItemStack(ModItems.boiledegg, 1), //This specifies what item
                                             you get after it's
                                             smelted -- in this case,
                                             one boiled egg.

     0.2F //This is the amount of experience you get smelting
            this item; the lowest is 0.1F [cobblestone], and
            greatest is 1.0F [diamond ore]
    );

  3. And done!  Yep, that's it!  Load up Minecraft and enjoy your new boiled eggs!!!





avatar
Ciabatta
Admin

Posts : 3884
Join date : 2014-01-03
Age : 26
Location : On the road

RP Character Sheet
Name: Ciabatta Sylvia
Personality Trait: Busy
Character Description:

View user profile http://bigsister.forumotion.com

Back to top Go down

Re: Mod-Making Crash Course Tutorial

Post by Ciabatta on Sat Aug 20, 2016 10:19 pm

If you'd like the files for Part 7 of this tutorial, you can download the source code for version 0.02 "soy" here:

https://drive.google.com/open?id=0BxIXoO1h5CNtNG9mNU5PTm42Z2s

_________________
avatar
Ciabatta
Admin

Posts : 3884
Join date : 2014-01-03
Age : 26
Location : On the road

RP Character Sheet
Name: Ciabatta Sylvia
Personality Trait: Busy
Character Description:

View user profile http://bigsister.forumotion.com

Back to top Go down

Re: Mod-Making Crash Course Tutorial

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum