Skip to content

Commit

Permalink
Fix: Armor Hider in Custom Wardrobe (hannibal002#2449)
Browse files Browse the repository at this point in the history
Co-authored-by: ItsEmpa <[email protected]>
  • Loading branch information
ItsEmpa and ItsEmpa authored Sep 3, 2024
1 parent c6fd094 commit 2b92f20
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -267,7 +267,7 @@ object CustomWardrobe {
containerHeight: Int,
containerWidth: Int,
): Renderable {
val fakePlayer = getFakePlayer()
val fakePlayer = FakePlayer()
var scale = playerWidth

fakePlayer.inventory.armorInventory =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -33,8 +34,9 @@ private boolean alwaysMarkAsHavingCape(EntityPlayer instance, EnumPlayerModelPar
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);
}
Expand Down
25 changes: 0 additions & 25 deletions src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/at/hannibal2/skyhanni/utils/FakePlayer.kt
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 2b92f20

Please sign in to comment.