Merge pull request #2838 from Mohist-Community/v3.0

Support Mohist
This commit is contained in:
mikeprimm 2020-04-12 19:33:46 -05:00 committed by GitHub
commit c7f438dda9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 6 deletions

View File

@ -60,9 +60,14 @@ public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric {
Server srv = Bukkit.getServer();
/* Get getHandle() method */
try {
Method m = srv.getClass().getMethod("getHandle");
Object scm = m.invoke(srv); /* And use it to get SCM (nms object) */
return scm.getClass().getPackage().getName();
try {
Class.forName("red.mohist.Mohist");
return "net.minecraft.server.v1_12_R1";
} catch (Exception x) {
Method m = srv.getClass().getMethod("getHandle");
Object scm = m.invoke(srv); /* And use it to get SCM (nms object) */
return scm.getClass().getPackage().getName();
}
} catch (Exception x) {
Log.severe("Error finding net.minecraft.server packages");
return null;
@ -72,7 +77,11 @@ public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric {
protected void loadNMS() {
// Get block fields
nmsblock = getNMSClass("net.minecraft.server.Block");
nmsblockarray = getNMSClass("[Lnet.minecraft.server.Block;");
try {
nmsblockarray = getNMSClass("[Lnet.minecraft.block.Block;");
} catch (Exception x) {
nmsblockarray = getNMSClass("[Lnet.minecraft.server.Block;");
}
nmsmaterial = getNMSClass("net.minecraft.server.Material");
if (isBlockIdNeeded()) { // Not needed for 1.13+
blockbyid = getFieldNoFail(nmsblock, new String[] { "byId" }, nmsblockarray);
@ -88,7 +97,11 @@ public class BukkitVersionHelperCB extends BukkitVersionHelperGeneric {
/* Set up biomebase fields */
biomebase = getNMSClass("net.minecraft.server.BiomeBase");
biomebasearray = getNMSClass("[Lnet.minecraft.server.BiomeBase;");
try {
biomebasearray = getNMSClass("[Lnet.minecraft.world.biome.Biome;");
} catch (Exception x) {
biomebasearray = getNMSClass("[Lnet.minecraft.server.BiomeBase;");
}
biomebaselist = getPrivateFieldNoFail(biomebase, new String[] { "biomes" }, biomebasearray);
if ((biomebaselist == null) && isBiomeBaseListNeeded()) {
getbiomefunc = getMethodNoFail(biomebase, new String[] { "getBiome" }, new Class[] { int.class, biomebase });

View File

@ -132,7 +132,11 @@ public abstract class BukkitVersionHelperGeneric extends BukkitVersionHelper {
cw_gethandle = getMethod(craftworld, new String[] { "getHandle" }, new Class[0]);
/* CraftChunkSnapshot */
craftchunksnapshot = getOBCClass("org.bukkit.craftbukkit.CraftChunkSnapshot");
biomebasearray = getNMSClass("[Lnet.minecraft.server.BiomeBase;");
try {
biomebasearray = getNMSClass("[Lnet.minecraft.world.biome.Biome;");
} catch (Exception x) {
biomebasearray = getNMSClass("[Lnet.minecraft.server.BiomeBase;");
}
ccss_biome = getPrivateFieldNoFail(craftchunksnapshot, new String[] { "biome" }, biomebasearray);
if(ccss_biome == null) {
biomestorage = getNMSClass("net.minecraft.server.BiomeStorage");