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))
 
(12 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{NoticeOutdated}}
+
{{stub}}
 +
Ask on the BTW Discord for more info
  
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==
  
Better Than Wolves is made freely available under the [https://creativecommons.org/licenses/by/4.0/ Creative Commons Attribution 4.0 International Public License]. Minecraft, however, has its own separate End User License Agreement, viewable [https://www.minecraft.net/en-us/eula here].
+
Better Than Wolves is made freely available under the [https://creativecommons.org/licenses/by/4.0/ Creative Commons Attribution 4.0 International Public License]. Minecraft, however, has its own separate End User License Agreement, viewable [https://www.minecraft.net/en-us/eula 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.
+
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.
+
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:
 
*# Java JDK
 
*#* Grab the latest Java se JDK from [http://www.oracle.com/technetwork/java/javase/downloads/index.html here.]
 
*#* Download and install the proper version for your computer.
 
*#* Make sure that the paths are set, more information on paths can be found [http://www.java.com/en/download/help/path.xml here.]
 
*# MCP v.7.51 for Minecraft 1.5.2
 
*#* Download the MCP from [http://mcp.ocean-labs.de/download.php?view.5 here.] ([http://www.mediafire.com/file/95vlzp1a4n4wjqw/ Direct link if website is down.])
 
*# BTW Source Code
 
*#* Download the latest BTW version directly from the [https://github.com/BTW-Community/BTW-Public/releases 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).
 
*# Eclipse IDE (Optional but Recommended)
 
*#* Download and install the latest version of the [https://www.eclipse.org/downloads/packages/installer 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.
 
 
 
===Errors===
 
 
 
{| class="wikitable"
 
! style="color:red" | Error
 
! style="color:green" | Fix
 
|-
 
|'''<code>error: Source option 6 is no longer supported. Use 7 or later.</code>'''
 
 
 
'''<code>error: Target option 6 is no longer supported. Use 7 or later.</code>'''
 
|
 
*Download and install [https://www.oracle.com/ca-en/java/technologies/javase-java-archive-javase6-downloads.html Java JDK version 1.6]
 
*Run the '''<code>mcp751/updatemd5.bat</code>''' to recompile with the correct java version.
 
|-
 
|When Launching the client/server run configuration in Eclipse (green play button)
 
 
 
'''<code>Unrecognized option: -Xincgc</code>'''
 
|
 
* Click the down arrow beside the green play button and select 'Run Configurations'
 
* Under the 'Arguments' tab remove '''<code>-Xincgc</code>'''
 
* Click '''Apply''' and '''Run'''
 
|}
 
 
 
==Creating an Add-On==
 
[http://www.sargunster.com/btwforum/viewtopic.php?f=12&t=7606 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.
 
 
 
<pre>
 
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) {}
 
}
 
 
 
</pre>
 
 
 
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:
 
 
 
<pre>
 
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
 
 
}
 
 
 
</pre>
 
 
 
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 [https://github.com/BTW-Community/BTW-Addon-Extended 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 [http://www.sargunster.com/btwforum/viewtopic.php?f=12&t=9808 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:
 
 
 
<pre>protected YOUR_CLASS_NAME_HERE()
 
{
 
    super("Name", "Version", "Prefix");
 
}
 
</pre>
 
 
 
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'
 

Latest revision as of 10:33, 27 January 2024

Ask on the BTW Discord for more info


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.