- Хроники
- Chaotic Throne: High Five
- Исходники
- Отсутствуют
- Сборка
- 0
I have an issue when trying to add some functionality to a server I'm working on.
I have created a new class in data/scripts/ai and tied it to an xml through "ai_type" property.
Below is the class("LuckyTest") and another class I use to hold the modified NpcInstance.
The issue arises when starting the game, at casting super.getActor() to TestClass which is extending NpcInstance.
This is the issue I get when starting the game. Maybe someone has experienced this and can help out.
Caused by: java.lang.ClassCastException: class l2f.gameserver.model.instances.MonsterInstance cannot be cast to class ai.LuckyTest$TestClass (l2f.gameserver.model.instances.MonsterInstance and ai.LuckyTest$TestClass are in unnamed module of loader 'app')
at ai.LuckyTest.getActor(LuckyTest.java:26)
at ai.LuckyTest.getActor(LuckyTest.java:7)
at l2f.gameserver.ai.DefaultAI.<init>(DefaultAI.java:266)
at ai.LuckyTest.<init>(LuckyTest.java:11)
I have created a new class in data/scripts/ai and tied it to an xml through "ai_type" property.
Below is the class("LuckyTest") and another class I use to hold the modified NpcInstance.
The issue arises when starting the game, at casting super.getActor() to TestClass which is extending NpcInstance.
Java:
package.ai
import l2f.gameserver.ai.DefaultAI;
import l2f.gameserver.model.instances.NpcInstance;
import l2f.gameserver.templates.npc.NpcTemplate;
public class LuckyTest extends DefaultAI {
public LuckyTest(NpcInstance actor)
{
super(actor);
}
@Override
protected boolean thinkActive() {
super.thinkActive();
TestClass actor = getActor();
return false;
}
@Override
public TestClass getActor()
{
return (TestClass) super.getActor();
}
public final class TestClass extends NpcInstance {
public TestClass(int objectId, NpcTemplate template)
{
super(objectId, template);
}
}
}
This is the issue I get when starting the game. Maybe someone has experienced this and can help out.
Caused by: java.lang.ClassCastException: class l2f.gameserver.model.instances.MonsterInstance cannot be cast to class ai.LuckyTest$TestClass (l2f.gameserver.model.instances.MonsterInstance and ai.LuckyTest$TestClass are in unnamed module of loader 'app')
at ai.LuckyTest.getActor(LuckyTest.java:26)
at ai.LuckyTest.getActor(LuckyTest.java:7)
at l2f.gameserver.ai.DefaultAI.<init>(DefaultAI.java:266)
at ai.LuckyTest.<init>(LuckyTest.java:11)