|
| 1 | +package org.polyfrost.polynametag.mixin.client; |
| 2 | + |
| 3 | +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; |
| 4 | +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; |
| 5 | +import com.llamalad7.mixinextras.sugar.Local; |
| 6 | +import dev.deftu.omnicore.api.client.OmniClient; |
| 7 | +import dev.deftu.omnicore.api.client.screen.OmniScreens; |
| 8 | +import net.minecraft.client.gui.screens.inventory.EffectsInInventory; |
| 9 | +import net.minecraft.client.gui.screens.inventory.InventoryScreen; |
| 10 | +import net.minecraft.client.renderer.entity.EntityRenderer; |
| 11 | +import net.minecraft.client.renderer.entity.state.EntityRenderState; |
| 12 | +import net.minecraft.client.renderer.entity.state.HumanoidRenderState; |
| 13 | +import net.minecraft.client.renderer.entity.state.LivingEntityRenderState; |
| 14 | +import net.minecraft.client.renderer.entity.state.PlayerRenderState; |
| 15 | +import net.minecraft.world.entity.Entity; |
| 16 | +import net.minecraft.world.phys.Vec3; |
| 17 | +import org.polyfrost.polynametag.client.PolyNametagConfig; |
| 18 | +import org.spongepowered.asm.mixin.Mixin; |
| 19 | +import org.spongepowered.asm.mixin.injection.At; |
| 20 | + |
| 21 | +@Mixin(EntityRenderer.class) |
| 22 | +public abstract class Mixin_ShowInInventory<T extends Entity, S extends EntityRenderState> { |
| 23 | + @WrapOperation(method = "renderNameTag", at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/entity/state/EntityRenderState;nameTagAttachment:Lnet/minecraft/world/phys/Vec3;")) |
| 24 | + private Vec3 polynametag$hideNametagInInventory(EntityRenderState instance, Operation<Vec3> original, @Local(argsOnly = true) S arg) { |
| 25 | + if (PolyNametagConfig.isEnabled() && |
| 26 | + !PolyNametagConfig.isShowInInventory() && |
| 27 | + OmniScreens.getCurrentScreen() instanceof InventoryScreen && |
| 28 | + arg instanceof PlayerRenderState playerRenderState && |
| 29 | + playerRenderState.id == OmniClient.getPlayer().getId()) { |
| 30 | + return null; |
| 31 | + } else { |
| 32 | + return original.call(instance); |
| 33 | + } |
| 34 | + } |
| 35 | +} |
0 commit comments