CompatLayer for Minecraft 1.11/1.10.2
CompatLayer Mod is a small library/mod that allows you to write mods that run on 1.10.2 and 1.11 with the same binary jar. At least upto some point. At the very least it helps to minimize the source changes between your 1.10.2 version and 1.11 version of your mod in case you do need to have two versions for whatever reason.
How does it work? Basically CompatLayer is nothing more then a set of classes and functions that help abstract away the differences between 1.10.2 and 1.11. At this moment it contains:
- CompatBlock: A simple extension of Block that overrides methods that have changed in 1.11 and calls CompatLayer specific versions that you can override instead in your code. Currently supports ‘neighborChanged’ and ‘onBlockActivated’
- CompatItem: A simple extension of Item that basically does the same thing as CompatBlock but then for items. Currently contains ‘onItemRightClick’
- CompatInventory: an interface that inherits from IInventory and adds a default implementation for the new func_191420_l function.
- CompatSidedInventory: same for ISidedInventory.
- ChatTools: contains a simple message ‘addChatMessage’ that avoids the new parameter that player.addChatComponentMessage() has.
- ItemStackTools: this is the biggest reason for this mod. ItemStack handling has changed a lot in 1.11. Basically itemstacks are never ‘null’. Instead there is a new empty itemstack. This class makes abstraction of that. If you carefully go through all your code that uses itemstacks and replace all calls and tests (especially things like ‘stack = null’ or ‘if (stack == null)’) with methods from this class.
In addition to that you also have to do the following to make sure your mod runs on 1.10.2 and 1.11:
- Replace TileEntity.worldObj with getWorld() which works on 1.10.2 and 1.11
- Replace EntityPlayer.worldObj with getEntityWorld()
- Make sure your modid is lowercase
- Make sure all your resource files (json files, texture files, …) are lowercase!
- Keep the lang files same case as before (en_US.lang)
- Make sure all your registry names for blocks and items are lowercase.
- Make sure your mod runs on older versions of MC by adding this to your @Mod() line: acceptedMinecraftVersions = “[1.9,1.12)”
- Add a pack.mcmeta with pack format set to 2 so that en_US.lang works too on 1.11
If you had to change the case of some of the above things and you need your 1.10.2 mod to be compatible with old worlds you have to add a FMLMissingMappingsEvent to your code like this:
How to install:
- Install the version of Forge that corresponds with the mod (http://files.minecraftforge.net/ Choose the installer version of Forge)
- Download the CompatLayer Mod.
- Drop the entire zipped file into your mods folder (Search %appdata% on your PC then go into .minecraft, then mods(create this folder if it is not there))
- Open Minecraft and make sure your profile is set to Forge
- Start Minecraft and enjoy!
This mod is made by McJty, all credit to modder. Visit the original mod thread here for all info.