Jump to content

Cospaia

Members
  • Posts

    9
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Cospaia's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. We got it working by using \u2764 instead of a literal heart in the code. Strange, but whatever works, works.
  2. Did I say the mod works? Well, it has a terrible flaw right now. When it is built as a jar package and used in the regular launcher, the heart is not rendered as it should, but instead as four strange looking characters. (Looks like a Unicode issue.) So, it works in the dev server, but not in the real one. Anyone have any clue what that could be about?
  3. Now I have gotten the mod to do what I want. But I'm not sure I am doing it right. So posting some code here for feedback. This is the event handler: @SubscribeEvent public void render(RenderLivingEvent.Pre event) { EntityLivingBase entity = event.getEntity(); RenderLivingBase baseRenderer = event.getRenderer(); if (entity instanceof EntityPlayer) { if (this.renderer == null) { this.renderer = new RenderPlayerHealthDisplay(baseRenderer.getRenderManager(), baseRenderer.getMainModel(), 1.0F); } String health = String.format("%.1f", event.getEntity().getHealth()) + " §c❤"; this.renderer.renderHealthDisplay((AbstractClientPlayer) entity, event.getX(), event.getY(), event.getZ(), health); } } Which uses this subclass of RenderLivingBase: @SideOnly(Side.CLIENT) public class RenderPlayerHealthDisplay extends RenderLivingBase<AbstractClientPlayer> { public RenderPlayerHealthDisplay(RenderManager renderManagerIn, ModelBase modelBaseIn, float shadowSizeIn) { super(renderManagerIn, modelBaseIn, shadowSizeIn); } public void renderHealthDisplay(AbstractClientPlayer entity, double x, double y, double z, String s) { double distanceSq = entity.getDistanceSq(this.renderManager.renderViewEntity); y += (double)((float)this.getFontRendererFromRenderManager().FONT_HEIGHT * 1.15F * 0.025F); if (distanceSq < 100.0D) { Scoreboard scoreboard = entity.getWorldScoreboard(); ScoreObjective scoreobjective = scoreboard.getObjectiveInDisplaySlot(2); if (scoreobjective != null) { y += (double)((float)this.getFontRendererFromRenderManager().FONT_HEIGHT * 1.15F * 0.025F); } } this.renderLivingLabel(entity, s, x, y, z, 64); } @Nullable @Override protected ResourceLocation getEntityTexture(AbstractClientPlayer entity) { return entity.getLocationSkin(); } } (The scoreboard handling is how it is done in RenderPlayer.) This displays the health above player's nametags. But should I be instantiating a full new renderer like this? It seems it would be more efficient to replace the render class being sent to the event. Don't know if that makes sense, but anyway.
  4. Thanks. but I couldn't figure out how to import EnumChatFormatting.
  5. Thanks. I am not sure I follow along, but I have this handler right now (before I posted this question, that is): @SubscribeEvent public void render(RenderLivingEvent.Pre event) { float health = event.getEntity().getHealth(); String name = event.getEntity().getDisplayName().getFormattedText(); //System.out.println(name + ", " + health); event.getEntity().setCustomNameTag("" + health + "§c❤"); event.getEntity().setAlwaysRenderNameTag(true); return; } Which adds a health display for living entities, except for players. The event has a RenderLivingEntity instance, according to : http://takahikokawasaki.github.io/minecraft-resources/javadoc/forge/1.7.10-10.13.2.1291/index.html?net/minecraft/util/package-summary.html I want the health display to render like a below name objective in vanilla, which seems to require that I somehow can modify the behaviour of this renderer. Am I taking the wrong approach thinking like this?
  6. I want to render some data below the name tag on player entities. Searching this forum I get that I need to create a custom renderer for doing this. But, I'm new to modding and don't know how to go about it. Is there a particular tutorial I could look at or could someone give some pointers? Thanks in advance!
  7. Thanks, both of you. I'm out for tweaking all glint. But I want the player to be able to adjust it in-game. There was a mod for 1.8.9 that did this, Glint Colorizer, which you can see in action here: It would have been cool to make one for 1.12.2 as well, but it might be a bit too large of a bite for me. =)
  8. I want to change the glint color of enchanted items (like if the sword is enchanted, I want to render the glint in a different color). I'm new to minecraft modding and have a hard time figuring out where to begin looking. Is there an event I should hook into when the item is setup or maybe when it is rendered? Any hints would be appreciated. Thanks!
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.