I've been attempting to develop a Minecraft mod, but have hit a road block in which I have had no luck in surpassing. In my attempts to find a fix for this issue, I have sifted through multiple other questions and websites, but to no avail.
The closest I have gotten would be where I created the variable outside of the method and then set the value inside of the method. But, the issue with this is that it would always return with null.
Also, if it was not clear, I am talking about the "taskEntriesMethod" variable.
Here's my code:
public void getExecutingTaskEntries(Profiler profiler)
{
try
{
Class<?> AITasks = Class.forName("net.minecraft.entity.ai.EntityAITasks");
Field taskEntries = AITasks.getDeclaredField("executingTaskEntries");
taskEntries.setAccessible(true);
Object AITasksObj = taskEntries.get(new EntityAITasks(profiler));
Set<EntityAITasks.EntityAITaskEntry> taskEntriesMethod = (Set<EntityAITaskEntry>) AITasksObj;
}
catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException exception) { exception.printStackTrace(); }
}
private final Set<EntityAITasks.EntityAITaskEntry> executingTaskEntries = taskEntriesMethod; // <-- (this is what errors out)