Jump to content
  • 0

Mobs wont despawn // cast error


Question

Posted

i get this error when i kill any creature IG, can someone help me resolve it? i tried to find whats wrong but there are no errors on eclipse and its the 1st time i run into it. 

 

Thanks.

 

Exception in thread "pool-2-thread-150" java.lang.ClassCastException: class org.l2jmobius.gameserver.model.actor.instance.MonsterInstance cannot be cast to class org.l2jmobius.gameserver.model.actor.instance.PlayerInstance (org.l2jmobius.gameserver.model.actor.instance.MonsterInstance and org.l2jmobius.gameserver.model.actor.instance.PlayerInstance are in unnamed module of loader 'app')
	at org.l2jmobius.gameserver.network.serverpackets.Die.<init>(Die.java:58)
	at org.l2jmobius.gameserver.ai.AbstractAI.clientNotifyDead(AbstractAI.java:660)
	at org.l2jmobius.gameserver.ai.CreatureAI.onEvtDead(CreatureAI.java:843)
	at org.l2jmobius.gameserver.ai.AbstractAI.notifyEvent(AbstractAI.java:337)
	at org.l2jmobius.gameserver.ai.AbstractAI.notifyEvent(AbstractAI.java:224)
	at org.l2jmobius.gameserver.model.actor.Creature.doDie(Creature.java:1620)
	at org.l2jmobius.gameserver.model.actor.Npc.doDie(Npc.java:893)
	at org.l2jmobius.gameserver.model.actor.Attackable.doDie(Attackable.java:294)
	at org.l2jmobius.gameserver.model.actor.status.CreatureStatus.reduceHp(CreatureStatus.java:188)
	at org.l2jmobius.gameserver.model.actor.status.NpcStatus.reduceHp(NpcStatus.java:57)
	at org.l2jmobius.gameserver.model.actor.status.AttackableStatus.reduceHp(AttackableStatus.java:65)
	at org.l2jmobius.gameserver.model.actor.Creature.reduceCurrentHp(Creature.java:4516)
	at org.l2jmobius.gameserver.model.actor.Attackable.reduceCurrentHp(Attackable.java:268)
	at org.l2jmobius.gameserver.model.actor.Creature.doAttack(Creature.java:4382)
	at org.l2jmobius.gameserver.model.actor.Creature.onHitTarget(Creature.java:3744)
	at org.l2jmobius.gameserver.model.actor.Creature.onFirstHitTimeForDual(Creature.java:3706)
	at org.l2jmobius.gameserver.model.actor.Creature.lambda$doAutoAttack$9(Creature.java:1120)
	at org.l2jmobius.commons.concurrent.RunnableWrapper.run(RunnableWrapper.java:38)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)

 

4 answers to this question

Recommended Posts

  • 0
Posted
/*
 * This file is part of the L2J Mobius project.
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
package org.l2jmobius.gameserver.network.serverpackets;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.instancemanager.CastleManager;
import org.l2jmobius.gameserver.instancemanager.FortManager;
import org.l2jmobius.gameserver.model.AccessLevel;
import org.l2jmobius.gameserver.model.SiegeClan;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.model.clan.Clan;
import org.l2jmobius.gameserver.model.entity.Castle;
import org.l2jmobius.gameserver.model.entity.Fort;
import org.l2jmobius.gameserver.model.entity.GameEvent;
import org.l2jmobius.gameserver.model.zone.ZoneId;
import org.l2jmobius.gameserver.network.OutgoingPackets;

/**
 * @author UnAfraid, Nos
 */
public class Die implements IClientOutgoingPacket
{
	private final int _objectId;
	private boolean _toVillage;
	private boolean _toClanHall;
	private boolean _toCastle;
	private boolean _toOutpost;
	private final boolean _isSweepable;
	private boolean _useFeather;
	private boolean _toFortress;
	private boolean _hideAnimation;
	private List<Integer> _items = null;
	private boolean _itemsEnabled;
	private AccessLevel _access;
	private final int _charObjId;
	private Clan _clan;
	Creature _activeChar;
	@SuppressWarnings("unused")
	private boolean _canTeleport;
	
	public Die(Creature creature)
	{
		_activeChar = creature;
		if (creature instanceof PlayerInstance)
		{
			PlayerInstance player = (PlayerInstance) creature;
			_access = player.getAccessLevel();
			_clan = player.getClan();
		}
		
		_charObjId = creature.getObjectId();
		_canTeleport = !(((creature instanceof PlayerInstance) && GameEvent.isOn() && GameEvent.isPlayerParticipant(_charObjId)) || creature.isPendingRevive());
		
		if (_activeChar.isOnEvent())
		{
			_canTeleport = false;
		}
		
		_objectId = creature.getObjectId();
		if (creature.isPlayer())
		{
			final Clan clan = creature.getActingPlayer().getClan();
			boolean isInCastleDefense = false;
			boolean isInFortDefense = false;
			SiegeClan siegeClan = null;
			final Castle castle = CastleManager.getInstance().getCastle(creature);
			final Fort fort = FortManager.getInstance().getFort(creature);
			if ((castle != null) && castle.getSiege().isInProgress())
			{
				siegeClan = castle.getSiege().getAttackerClan(clan);
				isInCastleDefense = (siegeClan == null) && castle.getSiege().checkIsDefender(clan);
			}
			else if ((fort != null) && fort.getSiege().isInProgress())
			{
				siegeClan = fort.getSiege().getAttackerClan(clan);
				isInFortDefense = (siegeClan == null) && fort.getSiege().checkIsDefender(clan);
			}
			_toVillage = creature.canRevive() && !creature.isPendingRevive();
			_toClanHall = (clan != null) && (clan.getHideoutId() > 0);
			_toCastle = ((clan != null) && (clan.getCastleId() > 0)) || isInCastleDefense;
			_toOutpost = ((siegeClan != null) && !isInCastleDefense && !isInFortDefense && !siegeClan.getFlag().isEmpty());
			_useFeather = creature.getAccessLevel().allowFixedRes() || creature.getInventory().haveItemForSelfResurrection();
			_toFortress = ((clan != null) && (clan.getFortId() > 0)) || isInFortDefense;
		}
		_isSweepable = creature.isAttackable() && creature.isSweepActive();
	}
	
	public void setHideAnimation(boolean value)
	{
		_hideAnimation = value;
	}
	
	public void addItem(int itemId)
	{
		if (_items == null)
		{
			_items = new ArrayList<>(8);
		}
		
		if (_items.size() < 8)
		{
			_items.add(itemId);
		}
		else
		{
			throw new IndexOutOfBoundsException("Die packet doesn't support more then 8 items!");
		}
	}
	
	public List<Integer> getItems()
	{
		return _items != null ? _items : Collections.emptyList();
	}
	
	public void setItemsEnabled(boolean value)
	{
		_itemsEnabled = value;
	}
	
	@Override
	public boolean write(PacketWriter packet)
	{
		OutgoingPackets.DIE.writeId(packet);
		
		packet.writeD(_objectId);
		if (_activeChar.isInsideZone(ZoneId.PVP_FLAG))
		{
			packet.writeD(0);
			packet.writeD(_canTeleport ? 0x01 : 0x00);
			packet.writeD(0);
			packet.writeD(0);
			packet.writeD(0);
			packet.writeD(0);
			packet.writeD(0);
			packet.writeD(0);
		}
		else
		{
			packet.writeD(_toVillage ? 0x01 : 0x00);
			packet.writeD(_toClanHall ? 0x01 : 0x00);
			packet.writeD(_toCastle ? 0x01 : 0x00);
			packet.writeD(_toOutpost ? 0x01 : 0x00);
			packet.writeD(_isSweepable ? 0x01 : 0x00);
			packet.writeD(_useFeather ? 0x01 : 0x00);
			packet.writeD(_toFortress ? 0x01 : 0x00);
			
			packet.writeD(0x00); // Disables use Feather button for X seconds
			packet.writeD(0x00); // Adventure's Song
			packet.writeC(_hideAnimation ? 0x01 : 0x00);
			
			packet.writeD(_itemsEnabled ? 0x01 : 0x00);
			packet.writeD(getItems().size());
			getItems().forEach(packet::writeD);
		}
		return true;
		
	}
}
12 minutes ago, An4rchy said:

Show Die.java write() method so we know why it's trying to cast Monster to Player.

 

  • 0
Posted (edited)
7 minutes ago, Mobius said:

These sources are old AF.

Use latest?

From what hole you dug these up?

i know that these are old but im working on something after a year and i want to get it done before i have to move everything to the newest release (trying to include solo leveling (manga) story/game system as best as posible)

 

Edited by Drazeal

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...