Add horse

This commit is contained in:
lukasabbe
2026-02-21 17:03:21 +01:00
parent 9a8147eab0
commit 5870414653
8 changed files with 222 additions and 10 deletions
+16
View File
@@ -1,6 +1,7 @@
plugins { plugins {
id 'fabric-loom' version '1.15-SNAPSHOT' id 'fabric-loom' version '1.15-SNAPSHOT'
id 'maven-publish' id 'maven-publish'
id "com.modrinth.minotaur" version "2.+"
} }
version = project.mod_version version = project.mod_version
@@ -69,3 +70,18 @@ jar {
rename { "${it}_${project.archives_base_name}" } rename { "${it}_${project.archives_base_name}" }
} }
} }
modrinth {
token = System.getenv("MODRINTH_TOKEN")
projectId = "5iOVOX8K" //https://modrinth.com/mod/simple-transport-hud
version = project.version
versionType = project.versionType
uploadFile = jar
gameVersions = [project.minecraft_version]
loaders = ["fabric"]
dependencies {
required.project "fabric-api"
required.project "yacl"
required.project "modmenu"
}
}
+2 -1
View File
@@ -5,7 +5,8 @@ org.gradle.jvmargs=-Xmx1G
minecraft_version=1.21.11 minecraft_version=1.21.11
loader_version=0.18.4 loader_version=0.18.4
# Mod Properties # Mod Properties
mod_version=1.0+1.21.11 mod_version=0.2+1.21.11
versionType=beta
maven_group=com.lukasabbe maven_group=com.lukasabbe
archives_base_name=SimpleTransportHud archives_base_name=SimpleTransportHud
# Dependencies # Dependencies
@@ -13,6 +13,7 @@ public class Constants {
public final static Identifier ElytraHudIdentifier = Identifier.fromNamespaceAndPath(MOD_ID, "elytra_hud"); public final static Identifier ElytraHudIdentifier = Identifier.fromNamespaceAndPath(MOD_ID, "elytra_hud");
public final static Identifier BoatHudIdentifier = Identifier.fromNamespaceAndPath(MOD_ID, "boat_hud"); public final static Identifier BoatHudIdentifier = Identifier.fromNamespaceAndPath(MOD_ID, "boat_hud");
public final static Identifier MinecartHudIdentifier = Identifier.fromNamespaceAndPath(MOD_ID, "minecart_hud"); public final static Identifier MinecartHudIdentifier = Identifier.fromNamespaceAndPath(MOD_ID, "minecart_hud");
public final static Identifier HorseHudIdentifier = Identifier.fromNamespaceAndPath(MOD_ID, "horse_hud");
public final static List<Identifier> HudIdentifiers = Arrays.asList(ElytraHudIdentifier, BoatHudIdentifier, MinecartHudIdentifier); public final static List<Identifier> HudIdentifiers = Arrays.asList(ElytraHudIdentifier, BoatHudIdentifier, MinecartHudIdentifier, HorseHudIdentifier);
} }
@@ -1,10 +1,7 @@
package com.lukasabbe.simpletransporthud; package com.lukasabbe.simpletransporthud;
import com.lukasabbe.simpletransporthud.config.Config; import com.lukasabbe.simpletransporthud.config.Config;
import com.lukasabbe.simpletransporthud.huds.BoatHud; import com.lukasabbe.simpletransporthud.huds.*;
import com.lukasabbe.simpletransporthud.huds.ElytraHud;
import com.lukasabbe.simpletransporthud.huds.MinecartHud;
import com.lukasabbe.simpletransporthud.huds.SimpleHud;
import com.lukasabbe.simpletransporthud.tools.ElytraTools; import com.lukasabbe.simpletransporthud.tools.ElytraTools;
import com.lukasabbe.simpletransporthud.tools.EntityTools; import com.lukasabbe.simpletransporthud.tools.EntityTools;
import net.fabricmc.api.ClientModInitializer; import net.fabricmc.api.ClientModInitializer;
@@ -21,7 +18,8 @@ public class SimpleTransportHudMod implements ClientModInitializer {
public static List<SimpleHud> HUD_LIST = Arrays.asList( public static List<SimpleHud> HUD_LIST = Arrays.asList(
new ElytraHud(), new ElytraHud(),
new BoatHud(), new BoatHud(),
new MinecartHud() new MinecartHud(),
new HorseHud()
); );
@Override @Override
@@ -37,6 +37,8 @@ public class Config {
public HudPosition hudPositionBoat = HudPosition.CENTER; public HudPosition hudPositionBoat = HudPosition.CENTER;
@SerialEntry @SerialEntry
public HudPosition hudPositionMinecart = HudPosition.CENTER; public HudPosition hudPositionMinecart = HudPosition.CENTER;
@SerialEntry
public HudPosition hudPositionHorse = HudPosition.CENTER;
//Hud speed unit //Hud speed unit
@@ -46,6 +48,8 @@ public class Config {
public SpeedEnum speedEnumBoat = SpeedEnum.kmh; public SpeedEnum speedEnumBoat = SpeedEnum.kmh;
@SerialEntry @SerialEntry
public SpeedEnum speedEnumMinecart = SpeedEnum.kmh; public SpeedEnum speedEnumMinecart = SpeedEnum.kmh;
@SerialEntry
public SpeedEnum speedEnumHorse = SpeedEnum.kmh;
//Display speed //Display speed
@SerialEntry @SerialEntry
@@ -54,6 +58,8 @@ public class Config {
public int boatHudDelay = 0; public int boatHudDelay = 0;
@SerialEntry @SerialEntry
public int minecartHudDelay = 0; public int minecartHudDelay = 0;
@SerialEntry
public int horseHudDelay = 0;
private Map<String, Boolean> getActiveHuds() { private Map<String, Boolean> getActiveHuds() {
Map<String, Boolean> activatedHuds = new IdentityHashMap<>(); Map<String, Boolean> activatedHuds = new IdentityHashMap<>();
@@ -1,16 +1,29 @@
package com.lukasabbe.simpletransporthud.huds; package com.lukasabbe.simpletransporthud.huds;
import com.lukasabbe.simpletransporthud.Constants;
import com.lukasabbe.simpletransporthud.config.Config;
import com.lukasabbe.simpletransporthud.config.HudPosition; import com.lukasabbe.simpletransporthud.config.HudPosition;
import com.lukasabbe.simpletransporthud.tools.EntityTools;
import net.minecraft.client.DeltaTracker;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.resources.Identifier; import net.minecraft.resources.Identifier;
import net.minecraft.world.entity.animal.equine.AbstractHorse;
public class HorseHud extends RideableHud { public class HorseHud extends RideableHud {
@Override
public void render(GuiGraphics graphics, DeltaTracker tracker) {
if(!EntityTools.isRidingEntity(AbstractHorse.class)) return;
super.render(graphics, tracker);
}
@Override @Override
public Identifier getIdentifier() { public Identifier getIdentifier() {
return null; return Constants.HorseHudIdentifier;
} }
@Override @Override
public HudPosition getHudPosition() { public HudPosition getHudPosition() {
return null; return Config.HANDLER.instance().hudPositionHorse;
} }
} }
@@ -1,11 +1,188 @@
package com.lukasabbe.simpletransporthud.huds; package com.lukasabbe.simpletransporthud.huds;
import com.lukasabbe.simpletransporthud.config.Config;
import com.lukasabbe.simpletransporthud.tools.EntityTools;
import net.minecraft.client.DeltaTracker; import net.minecraft.client.DeltaTracker;
import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.renderer.RenderPipelines;
import net.minecraft.util.Mth;
public abstract class RideableHud implements SimpleHud { public abstract class RideableHud implements SimpleHud {
@Override @Override
public void render(GuiGraphics graphics, DeltaTracker tracker) { public void render(GuiGraphics graphics, DeltaTracker tracker) {
if(!isHudActivated()) return;
if(client.noRender) return;
if(client.player == null) return;
if(EntityTools.getTime() < Config.HANDLER.instance().boatHudDelay) return;
int[] pos = getCornerPos();
int x = pos[0];
int y = pos[1];
renderBackPlate(graphics);
int textX = 5;
float textScale = 0.6f;
int whiteColor = 0xFFFFFFFF;
//Draw speed
int speedTextY = 5;
renderCenteredScaledText(graphics, getSpeed(Config.HANDLER.instance().speedEnumBoat), x + textX, y + speedTextY, whiteColor, textScale);
//Draw coordinates
int coordinatesTextY = 15;
int maxAvailableWidth = 40;
String coordinatesText = String.format("%.0f:%.0f:%.0f", client.player.getX(), client.player.getY(), client.player.getZ());
int textWidth = client.font.width(coordinatesText);
float maxScale = (float) maxAvailableWidth / textWidth;
float finalScale = Math.min(textScale, maxScale);
renderCenteredScaledText(graphics, coordinatesText, x + textX, y + coordinatesTextY, whiteColor, finalScale);
int textureCornerX = 0;
int textureCornerY = 0;
int verticalArrowWidth = 8;
int verticalArrowHeight = 6;
int leftGreenArrowX = x + 40;
int rightRedArrowX = x + 50;
int verticalArrowY = y + 5;
if(client.options.keyLeft.isDown()){
graphics.blit(
RenderPipelines.GUI_TEXTURED,
left_green_arrow,
leftGreenArrowX, verticalArrowY,
textureCornerX, textureCornerY,
verticalArrowWidth, verticalArrowHeight,
verticalArrowWidth, verticalArrowHeight
);
graphics.blit(
RenderPipelines.GUI_TEXTURED,
right_off_red_arrow,
rightRedArrowX, verticalArrowY,
textureCornerX, textureCornerY,
verticalArrowWidth, verticalArrowHeight,
verticalArrowWidth, verticalArrowHeight
);
} else if (client.options.keyRight.isDown()) {
graphics.blit(
RenderPipelines.GUI_TEXTURED,
left_off_green_arrow,
leftGreenArrowX, verticalArrowY,
textureCornerX, textureCornerY,
verticalArrowWidth, verticalArrowHeight,
verticalArrowWidth, verticalArrowHeight
);
graphics.blit(
RenderPipelines.GUI_TEXTURED,
right_red_arrow,
rightRedArrowX, verticalArrowY,
textureCornerX, textureCornerY,
verticalArrowWidth, verticalArrowHeight,
verticalArrowWidth, verticalArrowHeight
);
} else {
graphics.blit(
RenderPipelines.GUI_TEXTURED,
left_off_green_arrow,
leftGreenArrowX, verticalArrowY,
textureCornerX, textureCornerY,
verticalArrowWidth, verticalArrowHeight,
verticalArrowWidth, verticalArrowHeight
);
graphics.blit(
RenderPipelines.GUI_TEXTURED,
right_off_red_arrow,
rightRedArrowX, verticalArrowY,
textureCornerX, textureCornerY,
verticalArrowWidth, verticalArrowHeight,
verticalArrowWidth, verticalArrowHeight
);
}
int arrowWidth = 6;
int arrowHeight = 8;
int greenAndRedArrowX = x + 46;
int greenArrowY = y + 13;
int redArrowY = y + 23;
if(client.options.keyUp.isDown()){
graphics.blit(
RenderPipelines.GUI_TEXTURED,
green_arrow,
greenAndRedArrowX, greenArrowY,
textureCornerX, textureCornerY,
arrowWidth, arrowHeight,
arrowWidth, arrowHeight
);
graphics.blit(
RenderPipelines.GUI_TEXTURED,
off_red_arrow,
greenAndRedArrowX, redArrowY,
textureCornerX, textureCornerY,
arrowWidth, arrowHeight,
arrowWidth, arrowHeight
);
} else if(client.options.keyDown.isDown()) {
graphics.blit(
RenderPipelines.GUI_TEXTURED,
off_green_arrow,
greenAndRedArrowX, greenArrowY,
textureCornerX, textureCornerY,
arrowWidth, arrowHeight,
arrowWidth, arrowHeight
);
graphics.blit(
RenderPipelines.GUI_TEXTURED,
red_arrow,
greenAndRedArrowX, redArrowY,
textureCornerX, textureCornerY,
arrowWidth, arrowHeight,
arrowWidth, arrowHeight
);
} else {
graphics.blit(
RenderPipelines.GUI_TEXTURED,
off_green_arrow,
greenAndRedArrowX, greenArrowY,
textureCornerX, textureCornerY,
arrowWidth, arrowHeight,
arrowWidth, arrowHeight
);
graphics.blit(
RenderPipelines.GUI_TEXTURED,
off_red_arrow,
greenAndRedArrowX, redArrowY,
textureCornerX, textureCornerY,
arrowWidth, arrowHeight,
arrowWidth, arrowHeight
);
}
//Compas background
int compassWidth = 29;
int compassHeight = 29;
int compassX = x + 67;
int compassY = y + 3;
graphics.blit(
RenderPipelines.GUI_TEXTURED,
compass,
compassX, compassY,
textureCornerX, textureCornerY,
compassWidth, compassHeight,
compassWidth, compassHeight
);
double radians = EntityTools.getRadians(tracker.getGameTimeDeltaPartialTick(true));
double radius = 5;
float centerX = compassX + 14;
float centerY = compassY + 14;
float endX = Math.round(centerX + (radius * -Mth.sin(radians)));
float endY = Math.round(centerY + (radius * Mth.cos(radians)));
drawLine(graphics, centerX, centerY, endX, endY, (int) radius, compass_pointer);
} }
} }
+1 -1
View File
@@ -3,7 +3,7 @@
"id": "simpletransporthud", "id": "simpletransporthud",
"version": "${version}", "version": "${version}",
"name": "Simple Transport HUD", "name": "Simple Transport HUD",
"description": "A Hud mod for different transports in Minecraft ", "description": "A Hud mod for different transports in Minecraft",
"authors": ["Lukasabbe"], "authors": ["Lukasabbe"],
"contact": { "contact": {
"homepage": "", "homepage": "",