mirror of
https://github.com/refactorinqq/SLC-1.8.9.git
synced 2024-11-10 07:31:32 +01:00
(fix) nametag rendering
This commit is contained in:
parent
dc8601c83d
commit
cfa15dcd85
@ -4,14 +4,9 @@ import com.google.common.collect.Maps;
|
|||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||||
import net.minecraft.client.gui.FontRenderer;
|
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
import net.minecraft.client.renderer.Tessellator;
|
|
||||||
import net.minecraft.client.renderer.WorldRenderer;
|
|
||||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
|
||||||
import net.minecraft.client.renderer.entity.RenderManager;
|
|
||||||
import net.minecraft.client.renderer.entity.RenderPlayer;
|
import net.minecraft.client.renderer.entity.RenderPlayer;
|
||||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
@ -30,6 +25,7 @@ import net.silentclient.client.emotes.bobj.BOBJArmature;
|
|||||||
import net.silentclient.client.emotes.bobj.BOBJBone;
|
import net.silentclient.client.emotes.bobj.BOBJBone;
|
||||||
import net.silentclient.client.emotes.emoticons.Emote;
|
import net.silentclient.client.emotes.emoticons.Emote;
|
||||||
import net.silentclient.client.emotes.socket.EmoteSocket;
|
import net.silentclient.client.emotes.socket.EmoteSocket;
|
||||||
|
import net.silentclient.client.hooks.NameTagRenderingHooks;
|
||||||
import org.joml.Matrix4f;
|
import org.joml.Matrix4f;
|
||||||
import org.joml.Vector4f;
|
import org.joml.Vector4f;
|
||||||
import org.lwjgl.BufferUtils;
|
import org.lwjgl.BufferUtils;
|
||||||
@ -153,50 +149,9 @@ public class AnimatorController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void renderNameTag(AbstractClientPlayer abstractclientplayer, double d0, double d1, double d2, BOBJArmature var8) {
|
public void renderNameTag(AbstractClientPlayer abstractclientplayer, double d0, double d1, double d2, BOBJArmature var8) {
|
||||||
RenderManager rendermanager = this.mc.getRenderManager();
|
|
||||||
double d3 = abstractclientplayer.getDistanceSqToEntity(rendermanager.livingPlayer);
|
|
||||||
double d4 = 64.0;
|
double d4 = 64.0;
|
||||||
String s = abstractclientplayer.getDisplayName().getFormattedText();
|
String s = abstractclientplayer.getDisplayName().getFormattedText();
|
||||||
if (d3 <= d4 * d4) {
|
NameTagRenderingHooks.renderNametag(abstractclientplayer, s, d0, d1, d2, (int) d4, true);
|
||||||
FontRenderer fontrenderer = rendermanager.getFontRenderer();
|
|
||||||
float f = 1.6F;
|
|
||||||
float f1 = 0.016666668F * f;
|
|
||||||
GlStateManager.pushMatrix();
|
|
||||||
GlStateManager.translate((float) d0 + 0.0F, (float) d1 + abstractclientplayer.height + 0.5F, (float) d2);
|
|
||||||
GL11.glNormal3f(0.0F, 1.0F, 0.0F);
|
|
||||||
GlStateManager.rotate(-Minecraft.getMinecraft().getRenderManager().playerViewY, 0.0F, 1.0F, 0.0F);
|
|
||||||
GlStateManager.rotate(Minecraft.getMinecraft().getRenderManager().playerViewX, 1.0F, 0.0F, 0.0F);
|
|
||||||
GlStateManager.scale(-f1, -f1, f1);
|
|
||||||
GlStateManager.disableLighting();
|
|
||||||
GlStateManager.depthMask(false);
|
|
||||||
GlStateManager.disableDepth();
|
|
||||||
GlStateManager.enableBlend();
|
|
||||||
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
|
|
||||||
Tessellator tessellator = Tessellator.getInstance();
|
|
||||||
WorldRenderer worldrenderer = tessellator.getWorldRenderer();
|
|
||||||
byte b0 = 0;
|
|
||||||
if (s.equals("deadmau5")) {
|
|
||||||
b0 = -10;
|
|
||||||
}
|
|
||||||
|
|
||||||
int i = fontrenderer.getStringWidth(s) / 2;
|
|
||||||
GlStateManager.disableTexture2D();
|
|
||||||
worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR);
|
|
||||||
worldrenderer.pos(-i - 1, -1 + b0, 0.0).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
|
|
||||||
worldrenderer.pos(-i - 1, 8 + b0, 0.0).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
|
|
||||||
worldrenderer.pos(i + 1, 8 + b0, 0.0).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
|
|
||||||
worldrenderer.pos(i + 1, -1 + b0, 0.0).color(0.0F, 0.0F, 0.0F, 0.25F).endVertex();
|
|
||||||
tessellator.draw();
|
|
||||||
GlStateManager.enableTexture2D();
|
|
||||||
fontrenderer.drawString(s, -fontrenderer.getStringWidth(s) / 2, b0, 553648127);
|
|
||||||
GlStateManager.enableDepth();
|
|
||||||
GlStateManager.depthMask(true);
|
|
||||||
fontrenderer.drawString(s, -fontrenderer.getStringWidth(s) / 2, b0, -1);
|
|
||||||
GlStateManager.enableLighting();
|
|
||||||
GlStateManager.disableBlend();
|
|
||||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
|
||||||
GlStateManager.popMatrix();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void render(AbstractClientPlayer player, BOBJArmature armature, double d0, double d1, double d2, float f) {
|
public void render(AbstractClientPlayer player, BOBJArmature armature, double d0, double d1, double d2, float f) {
|
||||||
|
@ -2,11 +2,11 @@ package net.silentclient.client.hooks;
|
|||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||||
|
import net.minecraft.client.gui.FontRenderer;
|
||||||
import net.minecraft.client.gui.Gui;
|
import net.minecraft.client.gui.Gui;
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
import net.minecraft.client.renderer.Tessellator;
|
import net.minecraft.client.renderer.Tessellator;
|
||||||
import net.minecraft.client.renderer.WorldRenderer;
|
import net.minecraft.client.renderer.WorldRenderer;
|
||||||
import net.minecraft.client.renderer.entity.Render;
|
|
||||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.silentclient.client.Client;
|
import net.silentclient.client.Client;
|
||||||
@ -18,8 +18,6 @@ import net.silentclient.client.utils.Players;
|
|||||||
import net.silentclient.client.utils.RenderTransformer;
|
import net.silentclient.client.utils.RenderTransformer;
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
import net.minecraft.client.gui.FontRenderer;
|
|
||||||
|
|
||||||
public class NameTagRenderingHooks {
|
public class NameTagRenderingHooks {
|
||||||
public static int drawNametagText(FontRenderer fontRenderer, String text, int x, int y, int color, boolean shadow) {
|
public static int drawNametagText(FontRenderer fontRenderer, String text, int x, int y, int color, boolean shadow) {
|
||||||
int render;
|
int render;
|
||||||
@ -41,24 +39,24 @@ public class NameTagRenderingHooks {
|
|||||||
return render;
|
return render;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void renderNametag(Entity entityIn, String str, double x, double y, double z, int maxDistance, boolean isMainNametag, Render render) {
|
public static void renderNametag(Entity entityIn, String str, double x, double y, double z, int maxDistance, boolean isMainNametag) {
|
||||||
String username = "";
|
String username = "";
|
||||||
double d0 = entityIn.getDistanceSqToEntity(render.getRenderManager().livingPlayer);
|
double d0 = entityIn.getDistanceSqToEntity(Minecraft.getMinecraft().getRenderManager().livingPlayer);
|
||||||
|
|
||||||
if (d0 <= (double)(maxDistance * maxDistance))
|
if (d0 <= (double)(maxDistance * maxDistance))
|
||||||
{
|
{
|
||||||
boolean fontShadow = Client.getInstance().getModInstances().getModByClass(NametagsMod.class).isEnabled() && Client.getInstance().getSettingsManager().getSettingByClass(NametagsMod.class, "Font Shadow").getValBoolean();
|
boolean fontShadow = Client.getInstance().getModInstances().getModByClass(NametagsMod.class).isEnabled() && Client.getInstance().getSettingsManager().getSettingByClass(NametagsMod.class, "Font Shadow").getValBoolean();
|
||||||
boolean icons = !Client.getInstance().getModInstances().getModByClass(NametagsMod.class).isEnabled() || Client.getInstance().getSettingsManager().getSettingByClass(NametagsMod.class, "Show Nametag Icons").getValBoolean();
|
boolean icons = !Client.getInstance().getModInstances().getModByClass(NametagsMod.class).isEnabled() || Client.getInstance().getSettingsManager().getSettingByClass(NametagsMod.class, "Show Nametag Icons").getValBoolean();
|
||||||
boolean background = !Client.getInstance().getModInstances().getModByClass(NametagsMod.class).isEnabled() || Client.getInstance().getModInstances().getModByClass(NametagsMod.class).isEnabled() && Client.getInstance().getSettingsManager().getSettingByClass(NametagsMod.class, "Background").getValBoolean();
|
boolean background = !Client.getInstance().getModInstances().getModByClass(NametagsMod.class).isEnabled() || Client.getInstance().getModInstances().getModByClass(NametagsMod.class).isEnabled() && Client.getInstance().getSettingsManager().getSettingByClass(NametagsMod.class, "Background").getValBoolean();
|
||||||
FontRenderer fontrenderer = render.getFontRendererFromRenderManager();
|
FontRenderer fontrenderer = Minecraft.getMinecraft().fontRendererObj;
|
||||||
float f = 1.6F;
|
float f = 1.6F;
|
||||||
float f1 = 0.016666668F * f;
|
float f1 = 0.016666668F * f;
|
||||||
|
|
||||||
GlStateManager.pushMatrix();
|
GlStateManager.pushMatrix();
|
||||||
GlStateManager.translate((float)x + 0.0F, (float)y + entityIn.height + 0.5F, (float)z);
|
GlStateManager.translate((float)x + 0.0F, (float)y + entityIn.height + 0.5F, (float)z);
|
||||||
GL11.glNormal3f(0.0F, 1.0F, 0.0F);
|
GL11.glNormal3f(0.0F, 1.0F, 0.0F);
|
||||||
float viewY = render.getRenderManager().playerViewY;
|
float viewY = Minecraft.getMinecraft().getRenderManager().playerViewY;
|
||||||
float viewX = render.getRenderManager().playerViewX;
|
float viewX = Minecraft.getMinecraft().getRenderManager().playerViewX;
|
||||||
if(Client.getInstance().getModInstances().getSnaplookMod().isActive()) {
|
if(Client.getInstance().getModInstances().getSnaplookMod().isActive()) {
|
||||||
viewY = Client.getInstance().getModInstances().getSnaplookMod().getYaw();
|
viewY = Client.getInstance().getModInstances().getSnaplookMod().getYaw();
|
||||||
viewX = Client.getInstance().getModInstances().getSnaplookMod().getPitch();
|
viewX = Client.getInstance().getModInstances().getSnaplookMod().getPitch();
|
||||||
|
@ -14,7 +14,7 @@ public abstract class RenderMixin<T extends Entity> {
|
|||||||
*/
|
*/
|
||||||
@Overwrite
|
@Overwrite
|
||||||
protected void renderLivingLabel(T entityIn, String str, double x, double y, double z, int maxDistance) {
|
protected void renderLivingLabel(T entityIn, String str, double x, double y, double z, int maxDistance) {
|
||||||
NameTagRenderingHooks.renderNametag(entityIn, str, x, y, z, maxDistance, false, ((Render) (Object) this));
|
NameTagRenderingHooks.renderNametag(entityIn, str, x, y, z, maxDistance, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -24,6 +24,6 @@ public abstract class RenderMixin<T extends Entity> {
|
|||||||
@Overwrite
|
@Overwrite
|
||||||
protected void renderOffsetLivingLabel(T entityIn, double x, double y, double z, String str, float p_177069_9_, double p_177069_10_)
|
protected void renderOffsetLivingLabel(T entityIn, double x, double y, double z, String str, float p_177069_9_, double p_177069_10_)
|
||||||
{
|
{
|
||||||
NameTagRenderingHooks.renderNametag(entityIn, str, x, y, z, 64, true, ((Render) (Object) this));
|
NameTagRenderingHooks.renderNametag(entityIn, str, x, y, z, 64, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user