Add-Ons
For Add-Ons there's a special section on the BTW forums: http://www.sargunster.com/btwforum/viewforum.php?f=12
Contents
Things to keep in mind while creating addons
Better Than Wolves is made freely available under the 4.0 creative commons attribution license
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.
Setting Up
(This tutorial is being done on a win7 x64 machine.)
- Lets start by installing some things:
- Java JDK
- MCP v.7.51 for Minecraft 1.5.2
- Download the MCP from here. (Direct link if website is down.)
- Vanilla Minecraft .jars
- Latest BTW version
- Snag the latest BTW version from the 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 here.
- Unzip the downloaded file to the preferred install location.
- Next we will unzip the
mcp751.zip
file to the desired location. - Shove the
minecraft_server.jar
from earlier into themcp751/jars
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
.minecraft
folder (usually located in%appdata&
) - Copy out the
.minecraft/bin
and.minecraft/resources
folder into themcp751/jars
folder.- If you want to otherwise directly download the required files you can place the minecraft.jar, jinput.jar, lwjgl.jar, lwjgl_util.jar into the
./jars/bin/
directory, then the Jinput-natives(Windows, Linux, OSX) and LWGL-natives(Windows, Linux, OSX) into the./jars/bin/natives/
directory.
- If you want to otherwise directly download the required files you can place the minecraft.jar, jinput.jar, lwjgl.jar, lwjgl_util.jar into the
- Install the BTW mod into the
mcp751/jars/minecraft_server.jar
and themcp751/jars/bin/minecraft.jar
- Run the
mcp751/decompile.bat
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
mcp751/eclipse
- Now we need to get rid of those pesky errors. Find the classes that are erroring out
-
{Client,Server}/src/net.minecraft.src/EntityAnimal.java
- The methods
setRevengeTarget
,OnNearbyAnimalAttacked
,OnNearbyPlayerStartles
need all instances ofthis.breeding
to be changed tothis.entityLivingToAttack
. - Props to six for finding this out.
- The methods
-
{Client,Server}/src/net.minecraft.src/FCEntityGhast.java
- The method
updateEntityActionState
needs to havevar15
removed from theif()
statement.
- The method
-
{Client,Server}/src/net.minecraft.src/AxisAlignedBB {Client,Server}/src/net.minecraft.src/EntityMooshroom {Client,Server}/src/net.minecraft.src/FCEntityChicken {Client,Server}/src/net.minecraft.src/FCEntityCow {Client,Server}/src/net.minecraft.src/FCEntityOcelot {Client,Server}/src/net.minecraft.src/FCEntityPig {Client,Server}/src/net.minecraft.src/FCEntityVillager {Client,Server}/src/net.minecraft.src/FCEntityWolf {Client,Server}/src/net.minecraft.src/FCModelBlock {Client,Server}/src/net.minecraft.src/FCUtilsPrimitiveAABBWithBenefits {Client,Server}/src/net.minecraft.src/FCUtilsPrimitiveQuad
- These classes all have a duplicate method (and
FCUtilsPrimitiveAABBWithBenefits
has two). In the animals it is calledspawnBabyAnimal
; in the Villager it is calledfunc_90012_b
. - 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.
- These classes all have a duplicate method (and
-
{Client,Server}/src/net.minecraft.src/EntityVillager
- In
setRevengeTarget
you must make two edits:- Replace
this.randomTickDivider
withthis.entityLivingToAttack
. - Replace all instances of
this.isMating
withthis.revengeTimer
.
- Replace
- In
-
Client/src/net.minecraft.src/RenderGlobal
- In
doSpawnParticle
, change the type ofvar21
fromObject
toEntityFX
.
- In
-
- Save and exit the edited classes.
- Go back and run
mcp751/recompile.bat
- When it is finished recompiling run the
mcp751/updatemd5.bat
You should now be ready to create an addon for the BTW Mod.
Errors
Error | Fix |
---|---|
error: Source option 6 is no longer supported. Use 7 or later.
|
|
When Launching the client/server run configuration in Eclipse (green play button)
|
|
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 { protected FCAddOn() { FCAddOnHandler.AddMod(this); } 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 VMC 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.
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.
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'