Difference between revisions of "Creating Addons"

From Better Than Wolves Wiki
Jump to: navigation, search
(Setting Up: Remove unnecessary tut machine build info (should work across various platforms))
(Get people excited)
Line 1: Line 1:
{{NoticeOutdated}}
 
 
For Add-Ons there's a special section on the BTW forums: http://www.sargunster.com/btwforum/viewforum.php?f=12
 
 
 
==Things to keep in mind while creating addons==
 
==Things to keep in mind while creating addons==
  
Line 32: Line 28:
 
*#* Under Run -> Run Configurations, remove the text "-Xincgc" and save changes.
 
*#* Under Run -> Run Configurations, remove the text "-Xincgc" and save changes.
  
You should now be ready to create an addon for the BTW Mod.
+
You should now be ready to create an addon for the BTW Mod. Try to enjoy the process, ask for help and share what you're proud of.  There's a whole section on the forums dedicated to [http://www.sargunster.com/btwforum/viewforum.php?f=12 BTW Addons and Texture Packs], and there is also a [https://github.com/BTW-Community GitHub Community] that houses many addons from creators just like you!  We look forward to seeing you and celebrating your work with you.  Hey, and there's also a [https://discord.com/invite/fhMK5kx BTW Discord Server] where you can post questions and get help on the content-creation channel.  Get over there and say hi!  <3
  
 
===Errors===
 
===Errors===

Revision as of 23:58, 12 March 2022

Things to keep in mind while creating addons

Better Than Wolves is made freely available under the Creative Commons Attribution 4.0 International Public License. Minecraft, however, has its own separate End User License Agreement, viewable here.

As afforded by the CC-BY-4.0 license, you are free to modify and redistribute Better Than Wolves binaries, assets, and source code, but FlowerChild (the originator of the mod) would appreciate an acknowledgment if you do. Keep in mind however that parts of BTW may be based on modified versions of Mojang's code and assets, and it is left to anyone redistributing portions of BTW to make sure they are appropriately considering Mojang's intellectual property and licensing as well.

When creating your own addons for Better than wolves, special care should be taken with regards to decompiled vanilla Minecraft source code in use (anything without an FC prefix, basically). Posting decompiled, lightly-altered Minecraft source code files could be grounds for legal trouble. There are ways to post only the changes to your repository, as seen on the BTW-Public repo, but ultimately, it may just be easier to avoid those files unless needed for addon instantiation or invasive changes. And ultimately, you are responsible for the legality of what you post. These are just guidelines to help keep you out of trouble.

Setting Up

  • Lets start by installing some things:
    1. Java JDK
      • Grab the latest Java se JDK from here.
      • Download and install the proper version for your computer.
      • Make sure that the paths are set, more information on paths can be found here.
    2. MCP v.7.51 for Minecraft 1.5.2
    3. BTW Source Code
      • Download the latest BTW version directly from the BTW-Public Repo.
      • The source files here are in diff patch format, and will need to be merged with the decompiled Minecraft source code.
      • Extract the contents of the BTW-Public source code archive to a desired location, and place mcp751.zip into the extracted folder (the one with gradlew.bat, gradlew.sh, etc.).
      • If on windows, run gradlew.bat. Otherwise, run gradlew.sh. This will take several minutes, but should result in a fully-patched src folder and MCP pre-configured (both inside the newly created "mcp" folder).
    4. Eclipse IDE (Optional but Recommended)
      • Download and install the latest version of the Eclipse Integrated Development Environment
      • This IDE pairs well with MCP, as it has a preconfigured workspace specifically for Eclipse.
      • When we move to Fabric, you will have more choices of pre-configured IDE workspaces.
      • To make use of Eclipse, open it and create a workspace from the folders in mcp/eclipse.
      • Under Run -> Run Configurations, remove the text "-Xincgc" and save changes.

You should now be ready to create an addon for the BTW Mod. Try to enjoy the process, ask for help and share what you're proud of. There's a whole section on the forums dedicated to BTW Addons and Texture Packs, and there is also a GitHub Community that houses many addons from creators just like you! We look forward to seeing you and celebrating your work with you. Hey, and there's also a BTW Discord Server where you can post questions and get help on the content-creation channel. Get over there and say hi! <3

Errors

Error Fix
error: Source option 6 is no longer supported. Use 7 or later.

error: Target option 6 is no longer supported. Use 7 or later.

  • Download and install Java JDK version 1.6
  • Run the mcp751/updatemd5.bat to recompile with the correct java version.
When Launching the client/server run configuration in Eclipse (green play button)

Unrecognized option: -Xincgc

  • Click the down arrow beside the green play button and select 'Run Configurations'
  • Under the 'Arguments' tab remove -Xincgc
  • Click Apply and Run

Creating an Add-On

Official forum post on Add-Ons creation. We will need to create a base class to instantiate our add-on with. Make sure to have your main class extend the 'FCAddOn' class. This should be a good boilerplate for an add-on class.

package net.minecraft.src;

public class YOUR_CLASS_NAME_HERE extends FCAddOn
{
    public void PreInitialize() {}

    public abstract void Initialize();

    public void PostInitialize() {}

    public void OnLanguageLoaded(StringTranslate var1) {}
}

Another hitch in the whole creation of an Add-On is that in order for the JVM to even look at our class we need some other portion of the code (any other vanilla Minecraft class, basically) to point or somehow look at our code.(make a request/call) This will tell the JVM that there is a class that needs to be loaded, and when game time comes we will have a working mod. The example listed here uses the BlockSponge class to instantiate the SmegmaAddon class:

package net.minecraft.src;

public class BlockSponge extends Block
{
    protected BlockSponge(int par1)
    {
        super(par1, Material.sponge);
        this.setCreativeTab(CreativeTabs.tabBlock);
    }
    
    //SMEGMA ADDON
    static {
    	SmegmaAddon.instance.getVersionString();
    }
    //END
 
}

Be aware that if any other mod uses the same vanilla class, using it together with yours, one will overwrite the other. So, if you want to also play with SMEGMA in this case, find your own VMC class! :P Also be aware that when MCP obfuscates the class for its use in the game, the file name will change to something shorter like acy.class. So, be sure to check, and if you end up with the same class(es) as someone else in your respective releases, that's going to make it incompatible with that mod.


From here on out I will leave you kiddies to your business and allow you to create the most beautiful monstrosities around.

BTW Extended Addon API

If you want your addon to make use of Dawnraider's extended addon API, then after fixing the errors in decompilation, download the API source from github and copy it into your source folder. Then, run updatemd5 so that API files do not get reobfuscated.

Documentation for the API can be found on the forum thread or within the code itself.

If you use the API, you must make your addon class extend AddonExt instead of FCAddOn and add a constructor to initialize some values like this:

protected YOUR_CLASS_NAME_HERE()
{
    super("Name", "Version", "Prefix");
}

Name is the name of the addon, which will appear on login.

Version is the version string (e.g. 1.0.0) which is used in server version checking and will appear on login.

Prefix is used for the default packet channels provided by AddonExt.

Obfuscation

  • Decompile the code, modify and recompile.
  • Start "reobfuscate.bat" to start the reobfuscation step, it will automatically detect changed classes and reobfuscate them.
  • Your obfuscated classes are now available in 'mcp751\reobf\minecraft' and 'mcp751\reobf\minecraft_server', ready to be injected in MC.

Final Notes

For any other information on how to use the mcp refer to the docs file in 'mcp751\docs\README-MCP.TXT'