Difference between revisions of "Creating Addons"

From Better Than Wolves Wiki
Jump to: navigation, search
(Clarify a bit of copyright violation avoidance)
 
(21 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]
+
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].
  
You are free to modify and redistribute portions of BTW and its code as you wish, but FlowerChild would appreciate acknowledgment if you do so. 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.  Special care should be taken with regards to decompiled vanilla Minecraft source code (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.
+
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.
  
==Setting Up==
+
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.
(This tutorial is being done on a win7 x64 machine.)
 
 
 
*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.])
 
*# Vanilla Minecraft .jars
 
*#* Download the 1.5.2 [https://launcher.mojang.com/v1/objects/f9ae3f651319151ce99a0bfad6b34fa16eb6775f/server.jar server] and [https://launcher.mojang.com/v1/objects/465378c9dc2f779ae1d6e8046ebc46fb53a57968/client.jar client] jars for minecraft.
 
*#*Be sure to rename <code>server.jar</code> to <code>minecraft_server.jar</code> and the <code>client.jar</code> to <code>minecraft.jar</code>
 
*# Latest BTW version
 
*#* Snag the latest BTW version from the [http://www.sargunster.com/btwforum/viewforum.php?f=3 BTW forums.]
 
*# Latest Eclipse
 
*#* This is my preferred IDE, if you have one that you like more, then please feel free to use it instead.
 
*#* Get the latest version of the IDE [http://www.eclipse.org/downloads/? here.]
 
*#* Unzip the downloaded file to the preferred install location.
 
*Next we will unzip the <code>mcp751.zip</code> file to the desired location.
 
*Shove the <code>minecraft_server.jar</code> from earlier into the <code>mcp751/jars</code> folder.
 
*Now for a tricky part, we require the assets and such from the 1.5.2 version of minecraft. To do this go to your favorite minecraft launcher and create a new profile/instance for 1.5.2 (remember you have the 1.5.2.jar if you need it)
 
*Run the 1.5.2 instance right to the load game menu. Exit minecraft then go to your <code>.minecraft</code> folder (usually located in <code>%appdata&</code>)
 
*Copy out the <code>.minecraft/bin</code> and <code>.minecraft/resources</code> folder into the <code>mcp751/jars</code> folder.
 
**If you want to otherwise directly download the required files you can place the [https://launcher.mojang.com/v1/objects/465378c9dc2f779ae1d6e8046ebc46fb53a57968/client.jar minecraft.jar], [https://libraries.minecraft.net/net/java/jinput/jinput/2.0.5/jinput-2.0.5.jar jinput.jar], [https://libraries.minecraft.net/org/lwjgl/lwjgl/lwjgl/2.9.1/lwjgl-2.9.1.jar lwjgl.jar], [https://libraries.minecraft.net/org/lwjgl/lwjgl/lwjgl_util/2.9.1/lwjgl_util-2.9.1.jar lwjgl_util.jar] into the <code>./jars/bin/</code> directory, then the Jinput-natives([https://libraries.minecraft.net/net/java/jinput/jinput-platform/2.0.5/jinput-platform-2.0.5-natives-windows.jar Windows], [https://libraries.minecraft.net/net/java/jinput/jinput-platform/2.0.5/jinput-platform-2.0.5-natives-linux.jar Linux], [https://libraries.minecraft.net/net/java/jinput/jinput-platform/2.0.5/jinput-platform-2.0.5-natives-osx.jar OSX]) and LWGL-natives([https://libraries.minecraft.net/org/lwjgl/lwjgl/lwjgl-platform/2.9.1/lwjgl-platform-2.9.1-natives-windows.jar Windows], [https://libraries.minecraft.net/org/lwjgl/lwjgl/lwjgl-platform/2.9.1/lwjgl-platform-2.9.1-natives-linux.jar Linux], [https://libraries.minecraft.net/org/lwjgl/lwjgl/lwjgl-platform/2.9.1/lwjgl-platform-2.9.1-natives-osx.jar OSX]) into the <code>./jars/bin/natives/</code> directory.
 
*Install the BTW mod into the <code>mcp751/jars/minecraft_server.jar</code> and the <code>mcp751/jars/bin/minecraft.jar</code>
 
*Run the <code>mcp751/decompile.bat</code> file and wait for the interface to ask for a keypress to continue (this process can take anywhere from 1-30 minutes)
 
*There should be a couple errors, this is perfectly normal.(It might also say "Decompiling failed" just continue) Next we will setup eclipse.
 
*Start Eclipse, then when prompted for a workspace point it to <code>mcp751/eclipse</code>
 
*Now we need to get rid of those pesky errors. Find the classes that are erroring out
 
*# '''<code>{Client,Server}/src/net.minecraft.src/EntityAnimal.java</code>'''
 
*#* The methods <code>setRevengeTarget</code>, <code>OnNearbyAnimalAttacked</code>, <code>OnNearbyPlayerStartles</code> need all instances of <code>this.breeding</code> to be changed to <code>this.entityLivingToAttack</code>.
 
*#* [http://www.sargunster.com/btwforum/viewtopic.php?f=12&t=7606#p125588 Props to six for finding this out.]
 
*# '''<code>{Client,Server}/src/net.minecraft.src/FCEntityGhast.java</code>'''
 
*#* The method <code>updateEntityActionState</code> needs to have <code>var15</code> removed from the <code>if()</code> statement.
 
*# {{#tag:pre |<!--
 
-->{Client,Server}/src/net.minecraft.src/AxisAlignedBB&#10;<!--
 
-->{Client,Server}/src/net.minecraft.src/EntityMooshroom&#10;<!--
 
-->{Client,Server}/src/net.minecraft.src/FCEntityChicken&#10;<!--
 
-->{Client,Server}/src/net.minecraft.src/FCEntityCow&#10;<!--
 
-->{Client,Server}/src/net.minecraft.src/FCEntityOcelot&#10;<!--
 
-->{Client,Server}/src/net.minecraft.src/FCEntityPig&#10;<!--
 
-->{Client,Server}/src/net.minecraft.src/FCEntityVillager&#10;<!--
 
-->{Client,Server}/src/net.minecraft.src/FCEntityWolf&#10;<!--
 
-->{Client,Server}/src/net.minecraft.src/FCModelBlock&#10;<!--
 
-->{Client,Server}/src/net.minecraft.src/FCUtilsPrimitiveAABBWithBenefits&#10;<!--
 
-->{Client,Server}/src/net.minecraft.src/FCUtilsPrimitiveQuad&#10;<!--
 
-->}}
 
*#* These classes all have a duplicate method (and <code>FCUtilsPrimitiveAABBWithBenefits</code> has two).  In the animals it is called <code>spawnBabyAnimal</code>; in the Villager it is called <code>func_90012_b</code>.
 
*#* '''Delete the copies whose bodies appear to be calling themselves recursively.'''
 
*#* As of BTW 4.B00-b with MCP 7.51, the ones you want to delete are at the very bottom of the class in all cases.
 
*# '''<code>{Client,Server}/src/net.minecraft.src/EntityVillager</code>'''
 
*#* In <code>setRevengeTarget</code> you must make two edits:
 
*#** Replace <code>this.randomTickDivider</code> with <code>this.entityLivingToAttack</code>.
 
*#** Replace all instances of <code>this.isMating</code> with <code>this.revengeTimer</code>.
 
*# '''<code>Client/src/net.minecraft.src/RenderGlobal</code>'''
 
*#* In <code>doSpawnParticle</code>, change the type of <code>var21</code> from <code>Object</code> to <code>EntityFX</code>.
 
*Save and exit the edited classes.
 
*Go back and run <code>mcp751/recompile.bat</code>
 
*When it is finished recompiling run the <code>mcp751/updatemd5.bat</code>
 
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.