Block.getById should now work for older versions of mc

This commit is contained in:
libraryaddict 2014-09-24 02:52:38 +12:00
parent d766d8c1a5
commit d672013583

View File

@ -87,8 +87,14 @@ public class DisguiseUtilities {
cSection.setAccessible(true); cSection.setAccessible(true);
Object chunkSection = ReflectionManager.getNmsClass("ChunkSection").getConstructor(int.class, boolean.class) Object chunkSection = ReflectionManager.getNmsClass("ChunkSection").getConstructor(int.class, boolean.class)
.newInstance(0, false); .newInstance(0, false);
Object block = ReflectionManager.getNmsClass("Block").getMethod("getById", int.class) Object block;
try {
block = ReflectionManager.getNmsClass("Block").getMethod("getById", int.class)
.invoke(null, Material.BED_BLOCK.getId()); // TODO Method name exists in older versions? .invoke(null, Material.BED_BLOCK.getId()); // TODO Method name exists in older versions?
} catch (Exception ex) {
block = ((Object[]) ReflectionManager.getNmsField(ReflectionManager.getNmsClass("Block"), "byId").get(null))[Material.BED_BLOCK
.getId()];
}
Method setId = chunkSection.getClass().getMethod("setTypeId", int.class, int.class, int.class, Method setId = chunkSection.getClass().getMethod("setTypeId", int.class, int.class, int.class,
ReflectionManager.getNmsClass("Block")); ReflectionManager.getNmsClass("Block"));
Method setData = chunkSection.getClass().getMethod("setData", int.class, int.class, int.class, int.class); Method setData = chunkSection.getClass().getMethod("setData", int.class, int.class, int.class, int.class);