diff options
5 files changed, 27 insertions, 28 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/wardrobe/CustomWardrobe.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/wardrobe/CustomWardrobe.kt index 02494184d..32f0c6d0e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/wardrobe/CustomWardrobe.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/wardrobe/CustomWardrobe.kt @@ -24,7 +24,7 @@ import at.hannibal2.skyhanni.utils.ConditionalUtils import at.hannibal2.skyhanni.utils.ConditionalUtils.transformIf import at.hannibal2.skyhanni.utils.ConfigUtils.jumpToEditor import at.hannibal2.skyhanni.utils.DelayedRun -import at.hannibal2.skyhanni.utils.EntityUtils.getFakePlayer +import at.hannibal2.skyhanni.utils.FakePlayer import at.hannibal2.skyhanni.utils.InventoryUtils import at.hannibal2.skyhanni.utils.ItemUtils.removeEnchants import at.hannibal2.skyhanni.utils.KeyboardManager.isKeyHeld @@ -267,7 +267,7 @@ object CustomWardrobe { containerHeight: Int, containerWidth: Int, ): Renderable { - val fakePlayer = getFakePlayer() + val fakePlayer = FakePlayer() var scale = playerWidth fakePlayer.inventory.armorInventory = diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/HideArmor.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/HideArmor.kt index 32365458f..edc4474cb 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/HideArmor.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/HideArmor.kt @@ -9,6 +9,7 @@ import at.hannibal2.skyhanni.utils.ConfigUtils import at.hannibal2.skyhanni.utils.EntityUtils.getArmorInventory import at.hannibal2.skyhanni.utils.EntityUtils.hasPotionEffect import at.hannibal2.skyhanni.utils.EntityUtils.isNPC +import at.hannibal2.skyhanni.utils.FakePlayer import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.compat.Effects import net.minecraft.client.entity.EntityPlayerSP @@ -26,6 +27,7 @@ object HideArmor { private fun shouldHideArmor(entity: EntityLivingBase): Boolean { if (!LorenzUtils.inSkyBlock) return false if (entity !is EntityPlayer) return false + if (entity is FakePlayer) return false if (entity.hasPotionEffect(Effects.invisibility)) return false if (entity.isNPC()) return false diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinContributorRendererEntityLiving.java b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinContributorRendererEntityLiving.java index 6fb71ccc0..b64fb9d82 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinContributorRendererEntityLiving.java +++ b/src/main/java/at/hannibal2/skyhanni/mixins/transformers/renderer/MixinContributorRendererEntityLiving.java @@ -1,6 +1,7 @@ package at.hannibal2.skyhanni.mixins.transformers.renderer; import at.hannibal2.skyhanni.mixins.hooks.RendererLivingEntityHook; +import at.hannibal2.skyhanni.utils.FakePlayer; import net.minecraft.client.renderer.entity.RendererLivingEntity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; @@ -33,8 +34,9 @@ public class MixinContributorRendererEntityLiving<T extends EntityLivingBase> { return true; } - @Inject(method = "rotateCorpse", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/EnumChatFormatting;getTextWithoutFormattingCodes(Ljava/lang/String;)Ljava/lang/String;", shift = At.Shift.AFTER)) + @Inject(method = "rotateCorpse", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/EnumChatFormatting;getTextWithoutFormattingCodes(Ljava/lang/String;)Ljava/lang/String;", shift = At.Shift.AFTER), cancellable = true) private void rotateThePlayer(T bat, float p_77043_2_, float p_77043_3_, float partialTicks, CallbackInfo ci) { + if (bat instanceof FakePlayer) ci.cancel(); if (bat instanceof EntityPlayer) { RendererLivingEntityHook.rotatePlayer((EntityPlayer) bat); } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt index c3d3d248f..5e85bb64f 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt @@ -20,16 +20,13 @@ import net.minecraft.block.state.IBlockState import net.minecraft.client.Minecraft import net.minecraft.client.entity.EntityOtherPlayerMP import net.minecraft.client.multiplayer.WorldClient -import net.minecraft.client.resources.DefaultPlayerSkin import net.minecraft.entity.Entity import net.minecraft.entity.EntityLivingBase import net.minecraft.entity.item.EntityArmorStand import net.minecraft.entity.monster.EntityEnderman import net.minecraft.entity.player.EntityPlayer -import net.minecraft.entity.player.EnumPlayerModelParts import net.minecraft.item.ItemStack import net.minecraft.potion.Potion -import net.minecraft.scoreboard.ScorePlayerTeam import net.minecraft.util.AxisAlignedBB import net.minecraftforge.client.event.RenderLivingEvent @@ -248,28 +245,6 @@ object EntityUtils { fun EntityLivingBase.isRunicAndCorrupt() = baseMaxHealth == health.toInt().derpy() * 3 * 4 fun Entity.cleanName() = this.getNameAsString().removeColor() - - /** - * @return a fake player with the same skin as the real player - */ - fun getFakePlayer(): EntityOtherPlayerMP { - val mc = Minecraft.getMinecraft() - val player = mc.thePlayer!! - return object : EntityOtherPlayerMP( - mc.theWorld, - player.gameProfile, - ) { - override fun getLocationSkin() = - player.getLocationSkin() ?: DefaultPlayerSkin.getDefaultSkin(player.uniqueID) - - override fun getTeam() = object : ScorePlayerTeam(null, null) { - override fun getNameTagVisibility() = EnumVisible.NEVER - } - - override fun isWearing(part: EnumPlayerModelParts): Boolean = - player.isWearing(part) && part != EnumPlayerModelParts.CAPE - } - } } //#if FORGE diff --git a/src/main/java/at/hannibal2/skyhanni/utils/FakePlayer.kt b/src/main/java/at/hannibal2/skyhanni/utils/FakePlayer.kt new file mode 100644 index 000000000..1cfa2f0c5 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/utils/FakePlayer.kt @@ -0,0 +1,20 @@ +package at.hannibal2.skyhanni.utils + +import net.minecraft.client.Minecraft +import net.minecraft.client.entity.EntityOtherPlayerMP +import net.minecraft.client.resources.DefaultPlayerSkin +import net.minecraft.entity.player.EnumPlayerModelParts +import net.minecraft.scoreboard.ScorePlayerTeam + +class FakePlayer : EntityOtherPlayerMP(Minecraft.getMinecraft().theWorld, Minecraft.getMinecraft().thePlayer.gameProfile) { + + override fun getLocationSkin() = + Minecraft.getMinecraft().thePlayer.locationSkin ?: DefaultPlayerSkin.getDefaultSkin(Minecraft.getMinecraft().thePlayer.uniqueID) + + override fun getTeam() = object : ScorePlayerTeam(null, null) { + override fun getNameTagVisibility() = EnumVisible.NEVER + } + + override fun isWearing(part: EnumPlayerModelParts): Boolean = + Minecraft.getMinecraft().thePlayer.isWearing(part) && part != EnumPlayerModelParts.CAPE +} |