-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name tags get redder the more an entity is hurt
- Loading branch information
1 parent
7b4c9ff
commit 43145ed
Showing
3 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
src/main/java/net/arbee/addola/mixins/EntityRendererMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package net.arbee.addola.mixins; | ||
|
||
import net.minecraft.client.render.VertexConsumerProvider; | ||
import net.minecraft.client.render.entity.EntityRenderer; | ||
import net.minecraft.client.util.math.MatrixStack; | ||
import net.minecraft.entity.Entity; | ||
import net.minecraft.entity.LivingEntity; | ||
import net.minecraft.text.Text; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.ModifyArgs; | ||
import org.spongepowered.asm.mixin.injection.invoke.arg.Args; | ||
|
||
import java.awt.*; | ||
|
||
@Mixin(EntityRenderer.class) | ||
public abstract class EntityRendererMixin<T extends Entity> { | ||
@ModifyArgs(method = "renderLabelIfPresent", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/TextRenderer;draw(Lnet/minecraft/text/Text;FFIZLnet/minecraft/util/math/Matrix4f;Lnet/minecraft/client/render/VertexConsumerProvider;ZII)I", ordinal = 1)) | ||
public void draw (Args args, T entity, Text text, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light) { | ||
float healthPercent = ((LivingEntity)entity).getHealth() / ((LivingEntity)entity).getMaxHealth(); | ||
args.set(3, getCol(healthPercent)); | ||
} | ||
|
||
public int getCol(float percent) { | ||
int p = (int)(255 * percent); | ||
return new Color(255, p, p).hashCode(); | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/net/arbee/addola/mixins/LivingEntityRendererMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package net.arbee.addola.mixins; | ||
|
||
import net.minecraft.client.render.entity.EntityRenderDispatcher; | ||
import net.minecraft.client.render.entity.EntityRenderer; | ||
import net.minecraft.client.render.entity.LivingEntityRenderer; | ||
import net.minecraft.client.render.entity.PlayerModelPart; | ||
import net.minecraft.client.render.entity.feature.FeatureRendererContext; | ||
import net.minecraft.client.render.entity.model.EntityModel; | ||
import net.minecraft.client.util.math.MatrixStack; | ||
import net.minecraft.client.util.math.Vector3f; | ||
import net.minecraft.entity.LivingEntity; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.util.Formatting; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(LivingEntityRenderer.class) | ||
public abstract class LivingEntityRendererMixin<T extends LivingEntity, M extends EntityModel<T>> extends EntityRenderer<T> implements FeatureRendererContext<T, M> { | ||
protected LivingEntityRendererMixin(EntityRenderDispatcher dispatcher) { | ||
super(dispatcher); | ||
} | ||
|
||
@Inject(method = "setupTransforms", at = @At(value = "TAIL")) | ||
protected void setupTransforms(T entity, MatrixStack matrices, float animationProgress, float bodyYaw, float tickDelta, CallbackInfo ci) { | ||
if (entity.hasCustomName() || entity instanceof PlayerEntity) { | ||
String string = Formatting.strip(entity.getName().getString()); | ||
if ("guendahr".equals(string) && (!(entity instanceof PlayerEntity) || ((PlayerEntity)entity).isPartVisible(PlayerModelPart.CAPE))) { | ||
matrices.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(180.0F)); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43145ed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This implements the feature described in #3