Add a proxy system for better cross-version compat (#831)

This commit is contained in:
Nicholas Ignoffo 2016-07-07 17:52:47 -07:00
parent d314d84fbe
commit ab73edf5d3
5 changed files with 96 additions and 7 deletions

View file

@ -0,0 +1,24 @@
package WayofTime.bloodmagic.compat.minecraft;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.ReflectionHelper;
import java.lang.reflect.Method;
public class CrossVersionProxy110 implements ICrossVersionProxy {
@Override
public TileEntity createTileFromData(World world, NBTTagCompound tagCompound)
{
Method m = ReflectionHelper.findMethod(TileEntity.class, null, new String[] { "create", "func_190200_a", "a" }, World.class, NBTTagCompound.class);
try
{
return (TileEntity) m.invoke(null, world, tagCompound);
} catch (Exception e)
{
return null;
}
}
}

View file

@ -0,0 +1,24 @@
package WayofTime.bloodmagic.compat.minecraft;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.ReflectionHelper;
import java.lang.reflect.Method;
public class CrossVersionProxy19 implements ICrossVersionProxy {
@Override
public TileEntity createTileFromData(World world, NBTTagCompound tagCompound)
{
Method m = ReflectionHelper.findMethod(TileEntity.class, null, new String[] { "create", "func_189514_c", "c" }, NBTTagCompound.class);
try
{
return (TileEntity) m.invoke(null, tagCompound);
} catch (Exception e)
{
return null;
}
}
}

View file

@ -0,0 +1,15 @@
package WayofTime.bloodmagic.compat.minecraft;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
/**
* Allows for Blood Magic to support multiple MC versions that have only slight changes.
*
* Implementation copied from <a href="https://github.com/williewillus/Botania">Botania</a>.
*/
public interface ICrossVersionProxy
{
TileEntity createTileFromData(World world, NBTTagCompound tagCompound);
}