Fix for issue #247

Raised RealClasses.MAXIMUM_CLASS_BYTES to 16kB, because the
ChunkProviderSettings.Factory class was too big.
master
moulins 2016-11-17 16:51:24 -05:00
parent b69dc77e1d
commit 7eec61d3d3
5 changed files with 42 additions and 1 deletions

View File

@ -16,7 +16,7 @@ import amidst.documentation.Immutable;
public enum RealClasses {
;
private static final int MAXIMUM_CLASS_BYTES = 8000;
private static final int MAXIMUM_CLASS_BYTES = 16*1024;
private static final RealClassBuilder REAL_CLASS_BUILDER = new RealClassBuilder();
public static List<RealClass> fromJarFile(File jarFile) throws FileNotFoundException, JarFileParsingException {

View File

@ -46,6 +46,7 @@ public enum DefaultClassTranslator {
.optionalMethod(SymbolicNames.METHOD_GEN_LAYER_INITIALIZE_ALL_BIOME_GENERATORS_1, "a").real("long").end()
.optionalMethod(SymbolicNames.METHOD_GEN_LAYER_INITIALIZE_ALL_BIOME_GENERATORS_2, "a").real("long").symbolic("WorldType").end()
.optionalMethod(SymbolicNames.METHOD_GEN_LAYER_INITIALIZE_ALL_BIOME_GENERATORS_3, "a").real("long").symbolic("WorldType").real("String").end()
.optionalMethod(SymbolicNames.METHOD_GEN_LAYER_INITIALIZE_ALL_BIOME_GENERATORS_3A,"a").real("long").symbolic("WorldType").symbolic("ChunkProviderSettings").end()
.requiredMethod(SymbolicNames.METHOD_GEN_LAYER_GET_INTS, "a").real("int") .real("int") .real("int") .real("int").end()
.next()
.ifDetect(c ->
@ -59,6 +60,23 @@ public enum DefaultClassTranslator {
)
.thenDeclareOptional(SymbolicNames.CLASS_BLOCK_INIT)
.requiredMethod(SymbolicNames.METHOD_BLOCK_INIT_INITIALIZE, "c").end()
.next()
.ifDetect(c ->
//some leeway in case Mojang adds or removes fields in the future
c.getNumberOfFields() > 70 && c.getNumberOfFields() < 100
&& c.getNumberOfMethods() == 0
)
.thenDeclareOptional(SymbolicNames.CLASS_GEN_OPTIONS)
.next()
.ifDetect(c ->
//same as above
c.getNumberOfFields() > 70 && c.getNumberOfFields() < 100
&& c.getField(0).hasFlags(AccessFlags.STATIC | AccessFlags.FINAL)
&& c.getField(1).hasFlags(AccessFlags.PUBLIC)
)
.thenDeclareOptional(SymbolicNames.CLASS_GEN_OPTIONS_FACTORY)
.requiredMethod(SymbolicNames.METHOD_GEN_OPTIONS_FACTORY_BUILD, "b").end()
.requiredMethod(SymbolicNames.METHOD_GEN_OPTIONS_FACTORY_JSON_TO_FACTORY, "a").real("String").end()
.construct();
}
// @formatter:on

View File

@ -33,6 +33,7 @@ public class LocalMinecraftInterface implements MinecraftInterface {
private final SymbolicClass blockInitClass;
private final SymbolicClass genLayerClass;
private final SymbolicClass worldTypeClass;
private final SymbolicClass genOptionsFactoryClass;
private final RecognisedVersion recognisedVersion;
LocalMinecraftInterface(
@ -40,11 +41,13 @@ public class LocalMinecraftInterface implements MinecraftInterface {
SymbolicClass blockInitClass,
SymbolicClass genLayerClass,
SymbolicClass worldTypeClass,
SymbolicClass genOptionsFactoryClass,
RecognisedVersion recognisedVersion) {
this.intCacheClass = intCacheClass;
this.blockInitClass = blockInitClass;
this.genLayerClass = genLayerClass;
this.worldTypeClass = worldTypeClass;
this.genOptionsFactoryClass = genOptionsFactoryClass;
this.recognisedVersion = recognisedVersion;
}
@ -98,12 +101,25 @@ public class LocalMinecraftInterface implements MinecraftInterface {
throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
if (worldTypeClass == null) {
return (Object[]) genLayerClass.callStaticMethod(SymbolicNames.METHOD_GEN_LAYER_INITIALIZE_ALL_BIOME_GENERATORS_1, seed);
} else if (genLayerClass.hasMethod(SymbolicNames.METHOD_GEN_LAYER_INITIALIZE_ALL_BIOME_GENERATORS_3A)) {
SymbolicObject options = getGeneratorOptions(generatorOptions);
return (Object[]) genLayerClass.callStaticMethod(SymbolicNames.METHOD_GEN_LAYER_INITIALIZE_ALL_BIOME_GENERATORS_3A, seed, getWorldType(worldType).getObject(), options.getObject());
} else if (genLayerClass.hasMethod(SymbolicNames.METHOD_GEN_LAYER_INITIALIZE_ALL_BIOME_GENERATORS_3)) {
return (Object[]) genLayerClass.callStaticMethod(SymbolicNames.METHOD_GEN_LAYER_INITIALIZE_ALL_BIOME_GENERATORS_3, seed, getWorldType(worldType).getObject(), generatorOptions);
} else {
return (Object[]) genLayerClass.callStaticMethod(SymbolicNames.METHOD_GEN_LAYER_INITIALIZE_ALL_BIOME_GENERATORS_2, seed, getWorldType(worldType).getObject());
}
}
private SymbolicObject getGeneratorOptions(String generatorOptions)
throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
SymbolicObject factory = (SymbolicObject) genOptionsFactoryClass.callStaticMethod(SymbolicNames.METHOD_GEN_OPTIONS_FACTORY_JSON_TO_FACTORY, generatorOptions);
return (SymbolicObject) factory.callMethod(SymbolicNames.METHOD_GEN_OPTIONS_FACTORY_BUILD);
}
private SymbolicObject getWorldType(WorldType worldType)
throws IllegalArgumentException, IllegalAccessException {

View File

@ -40,6 +40,7 @@ public class LocalMinecraftInterfaceBuilder {
symbolicClassMap.get(SymbolicNames.CLASS_BLOCK_INIT),
symbolicClassMap.get(SymbolicNames.CLASS_GEN_LAYER),
symbolicClassMap.get(SymbolicNames.CLASS_WORLD_TYPE),
symbolicClassMap.get(SymbolicNames.CLASS_GEN_OPTIONS_FACTORY),
recognisedVersion);
} catch (MalformedURLException | ClassNotFoundException | FileNotFoundException | JarFileParsingException
| SymbolicClassGraphCreationException e) {

View File

@ -20,8 +20,14 @@ public enum SymbolicNames {
public static final String METHOD_GEN_LAYER_INITIALIZE_ALL_BIOME_GENERATORS_1 = "initializeAllBiomeGenerators1";
public static final String METHOD_GEN_LAYER_INITIALIZE_ALL_BIOME_GENERATORS_2 = "initializeAllBiomeGenerators2";
public static final String METHOD_GEN_LAYER_INITIALIZE_ALL_BIOME_GENERATORS_3 = "initializeAllBiomeGenerators3";
public static final String METHOD_GEN_LAYER_INITIALIZE_ALL_BIOME_GENERATORS_3A = "initializeAllBiomeGenerators3a";
public static final String METHOD_GEN_LAYER_GET_INTS = "getInts";
public static final String CLASS_BLOCK_INIT = "BlockInit";
public static final String METHOD_BLOCK_INIT_INITIALIZE = "initialize";
public static final String CLASS_GEN_OPTIONS = "ChunkProviderSettings";
public static final String CLASS_GEN_OPTIONS_FACTORY = CLASS_GEN_OPTIONS + ".Factory";
public static final String METHOD_GEN_OPTIONS_FACTORY_JSON_TO_FACTORY = "jsonToFactory";
public static final String METHOD_GEN_OPTIONS_FACTORY_BUILD = "build";
}