tested wow it works

This commit is contained in:
stone-wall
2020-03-12 13:11:26 -04:00
parent 86bf65612c
commit 4f414b0946
2 changed files with 35 additions and 26 deletions

View File

@@ -4,7 +4,7 @@ import lombok.Getter;
import net.runelite.api.Player; import net.runelite.api.Player;
import net.runelite.api.SkullIcon; import net.runelite.api.SkullIcon;
public class PlayerSkullChanged extends PlayerHeadIconChanged public class PlayerSkullChanged extends PlayerHeadIconChanged
{ {
@Getter @Getter
private final SkullIcon oldSkullIcon; private final SkullIcon oldSkullIcon;

View File

@@ -27,7 +27,6 @@ package net.runelite.mixins;
import java.awt.Polygon; import java.awt.Polygon;
import java.awt.Shape; import java.awt.Shape;
import java.util.ArrayList; import java.util.ArrayList;
import jdk.javadoc.internal.doclets.formats.html.markup.Head;
import net.runelite.api.HeadIcon; import net.runelite.api.HeadIcon;
import static net.runelite.api.HeadIcon.MAGIC; import static net.runelite.api.HeadIcon.MAGIC;
import static net.runelite.api.HeadIcon.MELEE; import static net.runelite.api.HeadIcon.MELEE;
@@ -50,6 +49,7 @@ import net.runelite.api.events.PlayerAppearanceChanged;
import net.runelite.api.events.player.headicon.OverheadPrayerChanged; import net.runelite.api.events.player.headicon.OverheadPrayerChanged;
import net.runelite.api.events.player.headicon.PlayerSkullChanged; import net.runelite.api.events.player.headicon.PlayerSkullChanged;
import net.runelite.api.mixins.Copy; import net.runelite.api.mixins.Copy;
import net.runelite.api.mixins.FieldHook;
import net.runelite.api.mixins.Inject; import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.MethodHook; import net.runelite.api.mixins.MethodHook;
import net.runelite.api.mixins.Mixin; import net.runelite.api.mixins.Mixin;
@@ -71,10 +71,10 @@ public abstract class RSPlayerMixin implements RSPlayer
private boolean friended; private boolean friended;
@Inject @Inject
private HeadIcon oldHeadIcon = null; private int oldHeadIcon = -1;
@Inject @Inject
private SkullIcon oldSkullIcon = null; private int oldSkullIcon = -1;
@Inject @Inject
@Override @Override
@@ -97,42 +97,50 @@ public abstract class RSPlayerMixin implements RSPlayer
return name.replace('\u00A0', ' '); return name.replace('\u00A0', ' ');
} }
@Inject
@FieldHook("headIconPrayer")
public void prayerChanged(int idx)
{
if (!(getRsOverheadIcon() == -1 && oldHeadIcon == -1))
{
final HeadIcon headIcon = getHeadIcon(getRsOverheadIcon());
if (getRsOverheadIcon() != oldHeadIcon)
{
client.getCallbacks().post(OverheadPrayerChanged.class,
new OverheadPrayerChanged(this, getHeadIcon(oldHeadIcon), headIcon));
}
}
oldHeadIcon = getRsOverheadIcon();
}
@Inject @Inject
@Override @Override
public HeadIcon getOverheadIcon() public HeadIcon getOverheadIcon()
{ {
final HeadIcon headIcon = getHeadIcon(getRsOverheadIcon()); return getHeadIcon(getRsOverheadIcon());
if (headIcon == null && oldHeadIcon == null) }
@Inject
@FieldHook("headIconPk")
public void skullChanged(int idx)
{
final SkullIcon skullIcon = skullFromInt(getRsSkullIcon());
if (getRsSkullIcon() != oldSkullIcon)
{ {
return null; client.getCallbacks().post(PlayerSkullChanged.class,
new PlayerSkullChanged(this, skullFromInt(getRsSkullIcon()), skullIcon));
} }
if (headIcon != oldHeadIcon) oldSkullIcon = getRsSkullIcon();
{
client.getCallbacks().post(OverheadPrayerChanged.class,
new OverheadPrayerChanged(this, oldHeadIcon, headIcon));
}
oldHeadIcon = headIcon;
return headIcon;
} }
@Inject @Inject
@Override @Override
public SkullIcon getSkullIcon() public SkullIcon getSkullIcon()
{ {
final SkullIcon skullIcon = skullFromInt(getRsSkullIcon()); return skullFromInt(getRsSkullIcon());
if (oldSkullIcon == null && skullIcon == null)
{
return null;
}
if (skullIcon != oldSkullIcon)
{
client.getCallbacks().post(PlayerSkullChanged.class,
new PlayerSkullChanged(this, oldSkullIcon, skullIcon));
}
oldSkullIcon = skullIcon;
return skullIcon;
} }
@Inject
private HeadIcon getHeadIcon(int overheadIcon) private HeadIcon getHeadIcon(int overheadIcon)
{ {
switch (overheadIcon) switch (overheadIcon)
@@ -154,6 +162,7 @@ public abstract class RSPlayerMixin implements RSPlayer
} }
} }
@Inject
private SkullIcon skullFromInt(int skull) private SkullIcon skullFromInt(int skull)
{ {
switch (skull) switch (skull)