I'm currently working on a project and I need to be able to override a super call with my data, but I don't even know if it's possible. Here's the class: https://hastebin.com/silosupece.java and here's the class that is extended: https://hastebin.com/ubowoqixuk.java. Using reflection I'm modifying the variable c found in the second class, but the super call is overriding the new c variable I insterted. If this is not possible can someone tell me how to?
(I'm not sending my code as I don't think it's needed, but if it is just ask!) void register(net.minecraft.server.v1_13_R1.World nmsWorld, World world, final BiomeGenerator biome) throws IllegalAccessException { CraftWorld craftWorld = (CraftWorld) world;
ChunkGeneratorAbstract generator = (ChunkGeneratorAbstract) craftWorld.getHandle().worldProvider.getChunkGenerator();
FieldUtils.writeField(generator, "c", new CustomWorldChunkManager(biome), true);
Field field = FieldUtils.getField(generator.getClass(), "a", true);
GeneratorAccess access = (GeneratorAccess) field.get(generator);
ChunkProviderGenerate generate = (ChunkProviderGenerate) generator;
Field field1 = FieldUtils.getField(generate.getClass(), "k", true);
GeneratorSettingsOverworld generatorSettingsOverworld = (GeneratorSettingsOverworld) field1.get(generate);
try {
Constructor<?> constructor = generate.getClass().getConstructor(GeneratorAccess.class, WorldChunkManager.class, GeneratorSettingsOverworld.class);
constructor.newInstance(access, new CustomWorldChunkManager(biome), generatorSettingsOverworld);
} catch (InstantiationException | InvocationTargetException | NoSuchMethodException e) {
e.printStackTrace();
}
if(craftWorld.getHandle().worldProvider.getChunkGenerator().getWorldChunkManager() instanceof CustomWorldChunkManager){
System.out.println("YES");
System.out.println(craftWorld.getHandle().worldProvider.getChunkGenerator().getWorldChunkManager());
}else {
System.out.println("NO");
System.out.println(craftWorld.getHandle().worldProvider.getChunkGenerator().getWorldChunkManager());
}
}
This is what I tried but I'm just creating a new instance and that's not what I want Ps: A friend is helping mem but still no idea on how to
Aucun commentaire:
Enregistrer un commentaire