Skip to content

Commit

Permalink
fix gui nametag rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
ImToggle committed May 6, 2024
1 parent 30f9c3f commit dc8741d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiInventory;
import net.minecraft.entity.EntityLivingBase;
import org.polyfrost.polynametag.PolyNametag;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
Expand All @@ -14,11 +13,6 @@ public class GuiInventoryMixin {
@Inject(method = "drawEntityOnScreen", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/RenderManager;renderEntityWithPosYaw(Lnet/minecraft/entity/Entity;DDDFF)Z"))
private static void start(int posX, int posY, int scale, float mouseX, float mouseY, EntityLivingBase ent, CallbackInfo ci) {
Minecraft.getMinecraft().getRenderManager().playerViewX = 0f;
PolyNametag.INSTANCE.setDrawingInGUI(true);
}

@Inject(method = "drawEntityOnScreen", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/entity/RenderManager;renderEntityWithPosYaw(Lnet/minecraft/entity/Entity;DDDFF)Z", shift = At.Shift.AFTER))
private static void end(int posX, int posY, int scale, float mouseX, float mouseY, EntityLivingBase ent, CallbackInfo ci) {
PolyNametag.INSTANCE.setDrawingInGUI(false);
}
}
7 changes: 7 additions & 0 deletions src/main/kotlin/org/polyfrost/polynametag/PolyNametag.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import net.minecraft.client.renderer.entity.Render
import net.minecraft.client.renderer.entity.RendererLivingEntity
import net.minecraft.entity.Entity
import net.minecraft.entity.EntityLivingBase
import net.minecraftforge.client.event.RenderWorldEvent
import net.minecraftforge.client.event.RenderWorldLastEvent
import net.minecraftforge.common.MinecraftForge
import net.minecraftforge.fml.common.Loader
Expand Down Expand Up @@ -49,8 +50,14 @@ object PolyNametag {
var drawingInGUI = false
var drawEssential = false

@SubscribeEvent
fun startWorld(event: RenderWorldEvent.Pre) {
drawingInGUI = false
}

@SubscribeEvent
fun onRender(event: RenderWorldLastEvent) {
drawingInGUI = true
if (!ModConfig.enabled) return
if (names.isEmpty() && labels.isEmpty()) return
GlStateManager.pushMatrix()
Expand Down

0 comments on commit dc8741d

Please sign in to comment.