Merge pull request #2684 from Adam-/npc-despawn
fire npc despawn event before composition is nulled
This commit is contained in:
@@ -36,4 +36,6 @@ import java.lang.annotation.Target;
|
||||
public @interface FieldHook
|
||||
{
|
||||
String value();
|
||||
|
||||
boolean before() default false;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,6 @@ import net.runelite.api.events.GameStateChanged;
|
||||
import net.runelite.api.events.GrandExchangeOfferChanged;
|
||||
import net.runelite.api.events.MapRegionChanged;
|
||||
import net.runelite.api.events.MenuEntryAdded;
|
||||
import net.runelite.api.events.NpcDespawned;
|
||||
import net.runelite.api.events.NpcSpawned;
|
||||
import net.runelite.api.events.PlayerDespawned;
|
||||
import net.runelite.api.events.PlayerMenuOptionsChanged;
|
||||
@@ -127,9 +126,6 @@ public abstract class RSClientMixin implements RSClient
|
||||
@Inject
|
||||
private static RSPlayer[] oldPlayers = new RSPlayer[2048];
|
||||
|
||||
@Inject
|
||||
private static RSNPC[] oldNpcs = new RSNPC[32768];
|
||||
|
||||
@Inject
|
||||
private static int itemPressedDurationBuffer;
|
||||
|
||||
@@ -805,17 +801,7 @@ public abstract class RSClientMixin implements RSClient
|
||||
if (npc != null)
|
||||
{
|
||||
npc.setIndex(idx);
|
||||
}
|
||||
|
||||
RSNPC oldNpc = oldNpcs[idx];
|
||||
oldNpcs[idx] = npc;
|
||||
|
||||
if (oldNpc != null)
|
||||
{
|
||||
eventBus.post(new NpcDespawned(oldNpc));
|
||||
}
|
||||
if (npc != null)
|
||||
{
|
||||
deferredEventBus.post(new NpcSpawned(npc));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,11 +24,14 @@
|
||||
*/
|
||||
package net.runelite.mixins;
|
||||
|
||||
import net.runelite.api.events.NpcDespawned;
|
||||
import net.runelite.api.mixins.Copy;
|
||||
import net.runelite.api.mixins.FieldHook;
|
||||
import net.runelite.api.mixins.Inject;
|
||||
import net.runelite.api.mixins.Mixin;
|
||||
import net.runelite.api.mixins.Replace;
|
||||
import net.runelite.api.mixins.Shadow;
|
||||
import static net.runelite.client.callback.Hooks.eventBus;
|
||||
import net.runelite.rs.api.RSClient;
|
||||
import net.runelite.rs.api.RSModel;
|
||||
import net.runelite.rs.api.RSNPC;
|
||||
@@ -93,6 +96,16 @@ public abstract class RSNPCMixin implements RSNPC
|
||||
npcIndex = id;
|
||||
}
|
||||
|
||||
@FieldHook(value = "composition", before = true)
|
||||
@Inject
|
||||
public void onCompositionChanged(RSNPCComposition composition)
|
||||
{
|
||||
if (composition == null)
|
||||
{
|
||||
eventBus.post(new NpcDespawned(this));
|
||||
}
|
||||
}
|
||||
|
||||
@Copy("getModel")
|
||||
public abstract RSModel rs$getModel();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user