Bassebombecraft

Bassebombecraft

18.5k Downloads

Mod reports exception NoSuchFieldException at AiUtils.captureGoals(..)

Closed this issue ยท 3 comments

commented

Stacktrace:

java.lang.NoSuchFieldException: goals at java.lang.Class.getDeclaredField(Unknown Source) at bassebombecraft.entity.ai.AiUtils.captureGoals(AiUtils.java:79) at bassebombecraft.event.charm.CharmedMob.<init>(CharmedMob.java:45) at bassebombecraft.event.charm.CharmedMob.getInstance(CharmedMob.java:80) at bassebombecraft.event.charm.DefaultCharmedMobsRepository.add(DefaultCharmedMobsRepository.java:38) at bassebombecraft.item.action.mist.entity.BeastmasterMist.applyEffectToEntity(BeastmasterMist.java:44) at bassebombecraft.item.action.mist.entity.GenericEntityMist.applyEffect(GenericEntityMist.java:141) at bassebombecraft.item.action.mist.entity.GenericEntityMist.onUpdate(GenericEntityMist.java:169) at bassebombecraft.item.book.GenericRightClickedBook.func_77663_a(GenericRightClickedBook.java:127) at net.minecraft.item.ItemStack.func_77945_a(ItemStack.java:405) at net.minecraft.entity.player.PlayerInventory.func_70429_k(PlayerInventory.java:265) at net.minecraft.entity.player.PlayerEntity.func_70636_d(PlayerEntity.java:492) at net.minecraft.entity.LivingEntity.func_70071_h_(LivingEntity.java:2032) at net.minecraft.entity.player.PlayerEntity.func_70071_h_(PlayerEntity.java:232) at net.minecraft.entity.player.ServerPlayerEntity.func_71127_g(ServerPlayerEntity.java:365) at net.minecraft.network.play.ServerPlayNetHandler.func_73660_a(ServerPlayNetHandler.java:183) at net.minecraft.network.NetworkManager.func_74428_b(NetworkManager.java:228) at net.minecraft.network.NetworkSystem.func_151269_c(NetworkSystem.java:135) at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:846) at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:764) at net.minecraft.server.integrated.IntegratedServer.func_71217_p(IntegratedServer.java:112) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:622) at java.lang.Thread.run(Unknown Source)

commented

Exception isn't thrown in forge development) environment:
build.gradle:

    mappings channel: 'snapshot', version: '20190920-1.14.3'
    minecraft 'net.minecraftforge:forge:1.14.4-28.1.10'

..using the beast charm idol
or beast charming mist
or beast charming book.

Development configuration: 1.8.0_211;1.14.4;28.1.10;20190829.143755;
Candidate configuration for the error: 1.8.0_51;1.14.4;28.1.87;20190829.143755;

commented

Observation:
Stacktrace is related to used of reflection to access private field in GoalSelector class:
private final Set<PrioritizedGoal> goals = Sets.newLinkedHashSet();
See #451

The goals field is accessed using standard reflection:
Field field = selector.getClass().getDeclaredField("goals");

This is a problem when the mod is used with obfuscated classes (but not in the IDE).

Solution:
The solution is the usage of the forge access transformer.
The visibilitiy of the goals field in the GoalSelector is modfied using the accesstranformer.cfg:

# access goals field
public net.minecraft.entity.ai.goal.GoalSelector field_220892_d # goals

And activating processing of the transformer in build.gradle:

minecraft {
    // activate access forge tranformer to access private methods and fields.
    accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')

Links:
https://www.minecraftforge.net/forum/topic/69257-113how-to-use-access-transformer/
https://github.com/Cadiboo/NoCubes/blob/9e47ebe0924e5f846babd238bb34b7ee0c2b45d7/build.gradle#L42

commented

Closed by commit febd956.