Skip to content

Commit

Permalink
Markers are yellow now for pawns when in combat mode and for warriors…
Browse files Browse the repository at this point in the history
… when in build mode, to distinguish who can be controlled in which mode
  • Loading branch information
remmintan committed Apr 15, 2024
1 parent d83c5d1 commit 215c4ed
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/main/java/org/minefortress/entity/renderer/PawnRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -30,6 +33,9 @@

public class PawnRenderer extends BipedEntityRenderer<BasePawnEntity, PawnModel> {

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");
Expand All @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 215c4ed

Please sign in to comment.