From 215c4eda4914a64c8540a06a2053dbd844cc35fc Mon Sep 17 00:00:00 2001 From: remmintan Date: Mon, 15 Apr 2024 23:46:50 +0200 Subject: [PATCH] Markers are yellow now for pawns when in combat mode and for warriors when in build mode, to distinguish who can be controlled in which mode --- .../entity/renderer/PawnRenderer.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/minefortress/entity/renderer/PawnRenderer.java b/src/main/java/org/minefortress/entity/renderer/PawnRenderer.java index 91942a85..6089b533 100644 --- a/src/main/java/org/minefortress/entity/renderer/PawnRenderer.java +++ b/src/main/java/org/minefortress/entity/renderer/PawnRenderer.java @@ -17,7 +17,10 @@ import net.minecraft.util.hit.EntityHitResult; import net.minecraft.util.math.Box; import net.minecraft.world.GameMode; +import net.remmintan.mods.minefortress.core.FortressState; +import net.remmintan.mods.minefortress.core.interfaces.entities.pawns.IWarrior; import net.remmintan.mods.minefortress.core.utils.CoreModUtils; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.joml.AxisAngle4f; import org.joml.Quaternionf; @@ -30,6 +33,9 @@ public class PawnRenderer extends BipedEntityRenderer { + private static final Vector3f GREEN_COLOR = new Vector3f(0f, 1f, 0f); + private static final Vector3f YELLOW_COLOR = new Vector3f(1f, 1f, 0f); + private static final Identifier GUY = new Identifier("minefortress", "textures/skins/guy.png"); private static final Identifier GUY2 = new Identifier("minefortress", "textures/skins/guy2.png"); private static final Identifier GUY3 = new Identifier("minefortress", "textures/skins/guy3.png"); @@ -56,6 +62,17 @@ protected boolean hasLabel(BasePawnEntity colonist) { return colonist.hasCustomName(); } + @NotNull + private static Vector3f getColorBaseOnMode(BasePawnEntity pawn) { + final var state = CoreModUtils.getMineFortressManagersProvider().get_ClientFortressManager().getState(); + final boolean warrior = pawn instanceof IWarrior; + final var combatState = state == FortressState.COMBAT; + if (combatState && warrior || !combatState && !warrior) + return new Vector3f(GREEN_COLOR); + else + return new Vector3f(YELLOW_COLOR); + } + @Override public void render(BasePawnEntity pawn, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i) { setClothesVilibility(pawn); @@ -74,7 +91,7 @@ public void render(BasePawnEntity pawn, float f, float g, MatrixStack matrixStac if(hovering || color != null || fightSelecting) { final VertexConsumer buffer = vertexConsumerProvider.getBuffer(RenderLayer.getLines()); if(color == null) - color = new Vector3f(0.0f, 1.0f, 0.0f); + color = getColorBaseOnMode(pawn); if(!hovering) color.mul(0.7f);