Difference between revisions of "Creating Addons"

From Better Than Wolves Wiki
Jump to: navigation, search
(Undo revision 19904 by AbbyRead (talk))
Line 1: Line 1:
 +
{{NoticeOutdated}}
 +
 
==Things to keep in mind while creating addons==
 
==Things to keep in mind while creating addons==
  

Revision as of 21:46, 2 January 2024

PD Important note: This page has not been updated to reflect recent changes to Better Than Wolves. As a result, some contents may be inaccurate or out-of-date. PD

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 OpenJDK 8 (Temurin 8) 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
      • Download the MCP from here.
    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. 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.
      • In Eclipse, change the workspace to 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

Known Eclipse 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 8
  • 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 (it needs to be in the classpath) we need some other portion of the code (any other vanilla Minecraft class, basically) to point or somehow look at our code. 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 YOUR_CLASS_NAME_HERE class:

package net.minecraft.src;

public class BlockSponge extends Block
{
    // Initialize our addon class
    static {
    	YOUR_CLASS_NAME_HERE.instance.getVersionString();
    }

    protected BlockSponge(int par1)
    {
        super(par1, Material.sponge);
        this.setCreativeTab(CreativeTabs.tabBlock);
    }
}

Be aware that if any other mod uses the same vanilla class, using it together with yours, one will overwrite the other. For example, BlockSponge is already used by at least one other addon, so you'd be incompatible with that addon. 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.

If you want it to be listed on the in-game chat under BTW-CE, you should make a call to the super as shown here:

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 the API.

BTW Extended Addon API

Dawnraider's Extended Addon-API is now part of BTW-CE. So, any addon to Better Than Wolves that would have extended AddonExt should now extend FCAddon instead. Just be aware in case you run across outdated info/examples. Documentation for the API can be found on the forum thread or within the code itself.

Obfuscation

Obfuscation is a necessary step for creating a functional release that can be added to anyone's game. It is not necessary until that point though, as you can simply make source code changes, recompile, and use the startclient.bat to test those changes. But when you are ready to create a releasable archive:

  • 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.
  • Add them to a zip file or package them in a jar, and that'll be what you distribute. You can use it that way in MultiMC and post it that way on the forum and/or on the releases page of your GitHub repo if you have one.

Final Notes

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