diff --git a/src/main/java/net/silentclient/client/emotes/EmoteControllerManager.java b/src/main/java/net/silentclient/client/emotes/EmoteControllerManager.java index 88d423b..f80a987 100644 --- a/src/main/java/net/silentclient/client/emotes/EmoteControllerManager.java +++ b/src/main/java/net/silentclient/client/emotes/EmoteControllerManager.java @@ -1,9 +1,7 @@ package net.silentclient.client.emotes; -import net.minecraft.entity.Entity; - import java.util.HashMap; public class EmoteControllerManager { - public static final HashMap controllers = new HashMap(); + public static final HashMap controllers = new HashMap(); } diff --git a/src/main/java/net/silentclient/client/emotes/EmoteManager.java b/src/main/java/net/silentclient/client/emotes/EmoteManager.java index 0bb954e..50234ad 100644 --- a/src/main/java/net/silentclient/client/emotes/EmoteManager.java +++ b/src/main/java/net/silentclient/client/emotes/EmoteManager.java @@ -2,6 +2,8 @@ package net.silentclient.client.emotes; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.World; +import net.silentclient.client.Client; import net.silentclient.client.emotes.emoticons.Emote; public class EmoteManager { @@ -12,24 +14,45 @@ public class EmoteManager { public static void play(String name, int i) { if (Minecraft.getMinecraft().theWorld != null) { String s = PlayerModelManager.get().map.get(i); - EntityPlayer entityPlayer = Minecraft.getMinecraft().theWorld.getPlayerEntityByName(name); + EntityPlayer entityPlayer = EmoteManager.getPlayerEntityByName(Minecraft.getMinecraft().theWorld, name); if (entityPlayer != null && s != null) { Emote emote = PlayerModelManager.get().registry.get(s); - if (EmoteControllerManager.controllers.get(entityPlayer) != null) { - EmoteControllerManager.controllers.get(entityPlayer).setEmote(entityPlayer, emote); + if (EmoteControllerManager.controllers.get(entityPlayer.getName()) != null) { + EmoteControllerManager.controllers.get(entityPlayer.getName()).setEmote(entityPlayer, emote); + } else { + Client.logger.info("emote player controller is null"); } + } else { + Client.logger.info("entity player or emote is null"); } } } public static void stop(String name) { if (Minecraft.getMinecraft().theWorld != null) { - EntityPlayer entityPlayer = Minecraft.getMinecraft().theWorld.getPlayerEntityByName(name); + EntityPlayer entityPlayer = EmoteManager.getPlayerEntityByName(Minecraft.getMinecraft().theWorld, name); if (entityPlayer != null) { - if (EmoteControllerManager.controllers.get(entityPlayer) != null) { - EmoteControllerManager.controllers.get(entityPlayer).resetEmote(); + if (EmoteControllerManager.controllers.get(entityPlayer.getName()) != null) { + EmoteControllerManager.controllers.get(entityPlayer.getName()).resetEmote(); } } } } + + public static EntityPlayer getPlayerEntityByName(World world, String name) + { + for (int i = 0; i < world.playerEntities.size(); ++i) + { + EntityPlayer entityplayer = (EntityPlayer)world.playerEntities.get(i); + + Client.logger.info(entityplayer.getName()); + + if (name.equalsIgnoreCase(entityplayer.getName())) + { + return entityplayer; + } + } + + return null; + } } diff --git a/src/main/java/net/silentclient/client/mixin/mixins/emotes/EntityPlayerMixin.java b/src/main/java/net/silentclient/client/mixin/mixins/emotes/EntityPlayerMixin.java index d883e01..a0d8c33 100644 --- a/src/main/java/net/silentclient/client/mixin/mixins/emotes/EntityPlayerMixin.java +++ b/src/main/java/net/silentclient/client/mixin/mixins/emotes/EntityPlayerMixin.java @@ -7,6 +7,7 @@ import net.silentclient.client.emotes.EmotesMod; import net.silentclient.client.emotes.PlayerModelManager; import net.minecraft.entity.player.EntityPlayer; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -16,17 +17,16 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; * @author refactoring */ @Mixin(EntityPlayer.class) -public class EntityPlayerMixin { +public abstract class EntityPlayerMixin { + @Shadow public abstract String getName(); + @Unique public AnimatorController controller; @Inject(method = "", at = @At("RETURN")) public void ae$init(CallbackInfo ci) { - if(!Client.getInstance().getSettingsManager().getSettingByClass(EmotesMod.class, "Emotes").getValBoolean()) { - return; - } controller = new AnimatorController(PlayerModelManager.get().steve, PlayerModelManager.get().steveConfig); - EmoteControllerManager.controllers.put((EntityPlayer) (Object) this, controller); + EmoteControllerManager.controllers.put(this.getName(), controller); } @Inject(method = "onUpdate", at = @At("RETURN")) diff --git a/src/main/java/net/silentclient/client/mixin/mixins/emotes/RenderPlayerMixin.java b/src/main/java/net/silentclient/client/mixin/mixins/emotes/RenderPlayerMixin.java index 8ed0707..5ccfef2 100644 --- a/src/main/java/net/silentclient/client/mixin/mixins/emotes/RenderPlayerMixin.java +++ b/src/main/java/net/silentclient/client/mixin/mixins/emotes/RenderPlayerMixin.java @@ -31,8 +31,8 @@ public abstract class RenderPlayerMixin extends RendererLivingEntity