Merged Julialy's code for Minecraft Forge.