mirror of
https://github.com/lukasabbe/SimpleTransportHud.git
synced 2026-04-30 10:50:53 +00:00
Add Minecart support & templates
This commit is contained in:
@@ -12,6 +12,7 @@ public class Constants {
|
|||||||
//Hud:s
|
//Hud:s
|
||||||
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 List<Identifier> HudIdentifiers = Arrays.asList(ElytraHudIdentifier, BoatHudIdentifier);
|
public final static List<Identifier> HudIdentifiers = Arrays.asList(ElytraHudIdentifier, BoatHudIdentifier, MinecartHudIdentifier);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,11 +3,14 @@ package com.lukasabbe.simplehud;
|
|||||||
import com.lukasabbe.simplehud.config.Config;
|
import com.lukasabbe.simplehud.config.Config;
|
||||||
import com.lukasabbe.simplehud.huds.BoatHud;
|
import com.lukasabbe.simplehud.huds.BoatHud;
|
||||||
import com.lukasabbe.simplehud.huds.ElytraHud;
|
import com.lukasabbe.simplehud.huds.ElytraHud;
|
||||||
|
import com.lukasabbe.simplehud.huds.MinecartHud;
|
||||||
import com.lukasabbe.simplehud.huds.SimpleHud;
|
import com.lukasabbe.simplehud.huds.SimpleHud;
|
||||||
import com.lukasabbe.simplehud.tools.ElytraTools;
|
import com.lukasabbe.simplehud.tools.ElytraTools;
|
||||||
import net.fabricmc.api.ClientModInitializer;
|
import net.fabricmc.api.ClientModInitializer;
|
||||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||||
import net.fabricmc.fabric.api.client.rendering.v1.hud.HudElementRegistry;
|
import net.fabricmc.fabric.api.client.rendering.v1.hud.HudElementRegistry;
|
||||||
|
import net.minecraft.client.DeltaTracker;
|
||||||
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -16,14 +19,31 @@ public class SimpleHudMod 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()
|
||||||
);
|
);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitializeClient() {
|
public void onInitializeClient() {
|
||||||
Config.HANDLER.load();
|
Config.HANDLER.load();
|
||||||
Config.HANDLER.load();
|
Config.HANDLER.load();
|
||||||
HUD_LIST.forEach(simpleHud -> HudElementRegistry.addFirst(simpleHud.getIdentifier(), simpleHud::render));
|
HUD_LIST.forEach(simpleHud -> HudElementRegistry.addFirst(
|
||||||
|
simpleHud.getIdentifier(),
|
||||||
|
(guiGraphics, deltaTracker) -> renderScaled(guiGraphics, deltaTracker, simpleHud))
|
||||||
|
);
|
||||||
ClientTickEvents.END_CLIENT_TICK.register(client -> ElytraTools.tickElytraTools());
|
ClientTickEvents.END_CLIENT_TICK.register(client -> ElytraTools.tickElytraTools());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void renderScaled(GuiGraphics graphics, DeltaTracker tracker, SimpleHud simpleHud){
|
||||||
|
var stack = graphics.pose();
|
||||||
|
final float scale = (float) Config.HANDLER.instance().hudScale / 10;
|
||||||
|
int width = graphics.guiWidth();
|
||||||
|
int height = graphics.guiHeight();
|
||||||
|
stack.pushMatrix();
|
||||||
|
stack.translate(width / 2f, height / 2f);
|
||||||
|
stack.scale(scale, scale);
|
||||||
|
stack.translate(-width / 2f, -height / 2f);
|
||||||
|
simpleHud.render(graphics, tracker);
|
||||||
|
stack.popMatrix();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,20 +19,33 @@ public class Config {
|
|||||||
.build())
|
.build())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
//Global
|
||||||
|
|
||||||
@SerialEntry
|
@SerialEntry
|
||||||
public Map<String, Boolean> HudActivatedList = getActiveHuds();
|
public Map<String, Boolean> HudActivatedList = getActiveHuds();
|
||||||
|
|
||||||
@SerialEntry
|
@SerialEntry
|
||||||
public HudPosition hudPositionElytra = HudPosition.CENTER;
|
public boolean ignoreSafeArea = false;
|
||||||
|
|
||||||
|
@SerialEntry
|
||||||
|
public int hudScale = 10;
|
||||||
|
|
||||||
|
//Hud positions
|
||||||
|
@SerialEntry
|
||||||
|
public HudPosition hudPositionElytra = HudPosition.CENTER;
|
||||||
|
@SerialEntry
|
||||||
|
public HudPosition hudPositionBoat = HudPosition.CENTER;
|
||||||
|
@SerialEntry
|
||||||
|
public HudPosition hudPositionMinecart = HudPosition.CENTER;
|
||||||
|
|
||||||
|
|
||||||
|
//Hud speed unit
|
||||||
@SerialEntry
|
@SerialEntry
|
||||||
public SpeedEnum speedEnumElytra = SpeedEnum.kmh;
|
public SpeedEnum speedEnumElytra = SpeedEnum.kmh;
|
||||||
|
|
||||||
@SerialEntry
|
@SerialEntry
|
||||||
public SpeedEnum speedEnumBoat = SpeedEnum.kmh;
|
public SpeedEnum speedEnumBoat = SpeedEnum.kmh;
|
||||||
|
|
||||||
@SerialEntry
|
@SerialEntry
|
||||||
public boolean ignoreSafeArea = false;
|
public SpeedEnum speedEnumMinecart = SpeedEnum.kmh;
|
||||||
|
|
||||||
private Map<String, Boolean> getActiveHuds() {
|
private Map<String, Boolean> getActiveHuds() {
|
||||||
Map<String, Boolean> activatedHuds = new IdentityHashMap<>();
|
Map<String, Boolean> activatedHuds = new IdentityHashMap<>();
|
||||||
|
|||||||
@@ -3,9 +3,10 @@ package com.lukasabbe.simplehud.config;
|
|||||||
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
|
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
|
||||||
import com.terraformersmc.modmenu.api.ModMenuApi;
|
import com.terraformersmc.modmenu.api.ModMenuApi;
|
||||||
import dev.isxander.yacl3.api.*;
|
import dev.isxander.yacl3.api.*;
|
||||||
|
import dev.isxander.yacl3.api.controller.IntegerSliderControllerBuilder;
|
||||||
import dev.isxander.yacl3.api.controller.TickBoxControllerBuilder;
|
import dev.isxander.yacl3.api.controller.TickBoxControllerBuilder;
|
||||||
import dev.isxander.yacl3.gui.controllers.TickBoxController;
|
|
||||||
import dev.isxander.yacl3.gui.controllers.cycling.EnumController;
|
import dev.isxander.yacl3.gui.controllers.cycling.EnumController;
|
||||||
|
import dev.isxander.yacl3.gui.controllers.slider.IntegerSliderController;
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
|
||||||
@@ -26,6 +27,12 @@ public class ModMenu implements ModMenuApi {
|
|||||||
.name(Component.translatable("simple_hud.config.category.general.name"))
|
.name(Component.translatable("simple_hud.config.category.general.name"))
|
||||||
.tooltip(Component.translatable("simple_hud.config.category.general.tooltip"))
|
.tooltip(Component.translatable("simple_hud.config.category.general.tooltip"))
|
||||||
.group(toggleOptions())
|
.group(toggleOptions())
|
||||||
|
.option(Option.<Integer>createBuilder()
|
||||||
|
.name(Component.translatable("simple_hud.config.category.general.option.scale.name"))
|
||||||
|
.description(OptionDescription.of(Component.translatable("simple_hud.config.category.general.option.scale.description")))
|
||||||
|
.binding(10, () -> instance.hudScale, newVal -> instance.hudScale = newVal)
|
||||||
|
.controller(opt -> IntegerSliderControllerBuilder.create(opt).range(0,20).step(1))
|
||||||
|
.build())
|
||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
.category(ConfigCategory
|
.category(ConfigCategory
|
||||||
|
|||||||
@@ -2,31 +2,21 @@ package com.lukasabbe.simplehud.huds;
|
|||||||
|
|
||||||
import com.lukasabbe.simplehud.Constants;
|
import com.lukasabbe.simplehud.Constants;
|
||||||
import com.lukasabbe.simplehud.config.Config;
|
import com.lukasabbe.simplehud.config.Config;
|
||||||
import com.lukasabbe.simplehud.tools.BoatTools;
|
import com.lukasabbe.simplehud.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.client.renderer.RenderPipelines;
|
||||||
import net.minecraft.resources.Identifier;
|
import net.minecraft.resources.Identifier;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
|
import net.minecraft.world.entity.vehicle.boat.Boat;
|
||||||
|
|
||||||
public class BoatHud implements SimpleHud {
|
public class BoatHud implements SimpleHud {
|
||||||
|
|
||||||
Identifier compass = Identifier.fromNamespaceAndPath(Constants.MOD_ID, "textures/compass.png");
|
|
||||||
Identifier compass_pointer = Identifier.fromNamespaceAndPath(Constants.MOD_ID, "textures/compass_pointer.png");
|
|
||||||
Identifier left_green_arrow = Identifier.fromNamespaceAndPath(Constants.MOD_ID, "textures/left_green_arrow.png");
|
|
||||||
Identifier right_red_arrow = Identifier.fromNamespaceAndPath(Constants.MOD_ID, "textures/right_red_arrow.png");
|
|
||||||
Identifier left_off_green_arrow = Identifier.fromNamespaceAndPath(Constants.MOD_ID, "textures/off_left_green_arrow.png");
|
|
||||||
Identifier right_off_red_arrow = Identifier.fromNamespaceAndPath(Constants.MOD_ID, "textures/off_left_red_arrow.png");
|
|
||||||
Identifier green_arrow = Identifier.fromNamespaceAndPath(Constants.MOD_ID, "textures/green_arrow.png");
|
|
||||||
Identifier red_arrow = Identifier.fromNamespaceAndPath(Constants.MOD_ID, "textures/red_arrow.png");
|
|
||||||
Identifier off_green_arrow = Identifier.fromNamespaceAndPath(Constants.MOD_ID, "textures/off_green_arrow.png");
|
|
||||||
Identifier off_red_arrow = Identifier.fromNamespaceAndPath(Constants.MOD_ID, "textures/off_red_arrow.png");
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(GuiGraphics graphics, DeltaTracker tracker) {
|
public void render(GuiGraphics graphics, DeltaTracker tracker) {
|
||||||
if(!isHudActivated()) return;
|
if(!isHudActivated()) return;
|
||||||
if(client.noRender) return;
|
if(client.noRender) return;
|
||||||
if(!BoatTools.isRidingBoat()) return;
|
if(!EntityTools.isRidingEntity(Boat.class)) return;
|
||||||
if(client.player == null) return;
|
if(client.player == null) return;
|
||||||
|
|
||||||
int[] pos = getCornerPos();
|
int[] pos = getCornerPos();
|
||||||
@@ -41,7 +31,7 @@ public class BoatHud implements SimpleHud {
|
|||||||
|
|
||||||
//Draw boat angle
|
//Draw boat angle
|
||||||
int pitchTextY = 5;
|
int pitchTextY = 5;
|
||||||
double angle = BoatTools.getAngle();
|
double angle = EntityTools.getAngle();
|
||||||
renderCenteredScaledText(graphics, String.format("%3.0f °", angle), x + textX, y + pitchTextY, whiteColor, textScale);
|
renderCenteredScaledText(graphics, String.format("%3.0f °", angle), x + textX, y + pitchTextY, whiteColor, textScale);
|
||||||
|
|
||||||
//Draw speed
|
//Draw speed
|
||||||
@@ -195,7 +185,7 @@ public class BoatHud implements SimpleHud {
|
|||||||
compassWidth, compassHeight
|
compassWidth, compassHeight
|
||||||
);
|
);
|
||||||
|
|
||||||
double radians = BoatTools.getRadians(tracker.getGameTimeDeltaPartialTick(true));
|
double radians = EntityTools.getRadians(tracker.getGameTimeDeltaPartialTick(true));
|
||||||
|
|
||||||
double radius = 5;
|
double radius = 5;
|
||||||
float centerX = compassX + 14;
|
float centerX = compassX + 14;
|
||||||
|
|||||||
@@ -13,13 +13,6 @@ import net.minecraft.world.item.Items;
|
|||||||
|
|
||||||
public class ElytraHud implements SimpleHud {
|
public class ElytraHud implements SimpleHud {
|
||||||
|
|
||||||
Identifier compass = Identifier.fromNamespaceAndPath(Constants.MOD_ID, "textures/compass.png");
|
|
||||||
Identifier compass_pointer = Identifier.fromNamespaceAndPath(Constants.MOD_ID, "textures/compass_pointer.png");
|
|
||||||
Identifier green_arrow = Identifier.fromNamespaceAndPath(Constants.MOD_ID, "textures/green_arrow.png");
|
|
||||||
Identifier red_arrow = Identifier.fromNamespaceAndPath(Constants.MOD_ID, "textures/red_arrow.png");
|
|
||||||
Identifier off_green_arrow = Identifier.fromNamespaceAndPath(Constants.MOD_ID, "textures/off_green_arrow.png");
|
|
||||||
Identifier off_red_arrow = Identifier.fromNamespaceAndPath(Constants.MOD_ID, "textures/off_red_arrow.png");
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(GuiGraphics graphics, DeltaTracker tracker) {
|
public void render(GuiGraphics graphics, DeltaTracker tracker) {
|
||||||
if(!isHudActivated()) return;
|
if(!isHudActivated()) return;
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.lukasabbe.simplehud.huds;
|
||||||
|
|
||||||
|
import net.minecraft.resources.Identifier;
|
||||||
|
|
||||||
|
public class HappyGhastHud extends RideableHud{
|
||||||
|
@Override
|
||||||
|
public Identifier getIdentifier() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.lukasabbe.simplehud.huds;
|
||||||
|
|
||||||
|
import net.minecraft.resources.Identifier;
|
||||||
|
|
||||||
|
public class HorseHud extends RideableHud {
|
||||||
|
@Override
|
||||||
|
public Identifier getIdentifier() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,137 @@
|
|||||||
|
package com.lukasabbe.simplehud.huds;
|
||||||
|
|
||||||
|
import com.lukasabbe.simplehud.Constants;
|
||||||
|
import com.lukasabbe.simplehud.config.Config;
|
||||||
|
import com.lukasabbe.simplehud.tools.EntityTools;
|
||||||
|
import net.minecraft.client.DeltaTracker;
|
||||||
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
|
import net.minecraft.client.renderer.RenderPipelines;
|
||||||
|
import net.minecraft.resources.Identifier;
|
||||||
|
import net.minecraft.util.Mth;
|
||||||
|
import net.minecraft.world.entity.vehicle.minecart.Minecart;
|
||||||
|
|
||||||
|
public class MinecartHud implements SimpleHud {
|
||||||
|
@Override
|
||||||
|
public void render(GuiGraphics graphics, DeltaTracker tracker) {
|
||||||
|
if(!isHudActivated()) return;
|
||||||
|
if(client.noRender) return;
|
||||||
|
if(!EntityTools.isRidingEntity(Minecart.class)) return;
|
||||||
|
if(client.player == null) 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 = 10;
|
||||||
|
renderCenteredScaledText(graphics, getSpeed(Config.HANDLER.instance().speedEnumBoat), x + textX, y + speedTextY, whiteColor, textScale);
|
||||||
|
|
||||||
|
//Draw coordinates
|
||||||
|
int coordinatesTextY = 20;
|
||||||
|
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 arrowWidth = 6;
|
||||||
|
int arrowHeight = 8;
|
||||||
|
|
||||||
|
int greenAndRedArrowX = x + 46;
|
||||||
|
int greenArrowY = y + 8;
|
||||||
|
int redArrowY = y + 18;
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Identifier getIdentifier() {
|
||||||
|
return Constants.MinecartHudIdentifier;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.lukasabbe.simplehud.huds;
|
||||||
|
|
||||||
|
import net.minecraft.resources.Identifier;
|
||||||
|
|
||||||
|
public class NautilusHud extends RideableHud {
|
||||||
|
@Override
|
||||||
|
public Identifier getIdentifier() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package com.lukasabbe.simplehud.huds;
|
||||||
|
|
||||||
|
import net.minecraft.client.DeltaTracker;
|
||||||
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
|
|
||||||
|
public abstract class RideableHud implements SimpleHud {
|
||||||
|
@Override
|
||||||
|
public void render(GuiGraphics graphics, DeltaTracker tracker) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,6 +17,16 @@ import net.minecraft.world.item.Item;
|
|||||||
public interface SimpleHud {
|
public interface SimpleHud {
|
||||||
Minecraft client = Minecraft.getInstance();
|
Minecraft client = Minecraft.getInstance();
|
||||||
Identifier backPlateAsset = Identifier.fromNamespaceAndPath(Constants.MOD_ID, "textures/backplate.png");
|
Identifier backPlateAsset = Identifier.fromNamespaceAndPath(Constants.MOD_ID, "textures/backplate.png");
|
||||||
|
Identifier compass = Identifier.fromNamespaceAndPath(Constants.MOD_ID, "textures/compass.png");
|
||||||
|
Identifier compass_pointer = Identifier.fromNamespaceAndPath(Constants.MOD_ID, "textures/compass_pointer.png");
|
||||||
|
Identifier left_green_arrow = Identifier.fromNamespaceAndPath(Constants.MOD_ID, "textures/left_green_arrow.png");
|
||||||
|
Identifier right_red_arrow = Identifier.fromNamespaceAndPath(Constants.MOD_ID, "textures/right_red_arrow.png");
|
||||||
|
Identifier left_off_green_arrow = Identifier.fromNamespaceAndPath(Constants.MOD_ID, "textures/off_left_green_arrow.png");
|
||||||
|
Identifier right_off_red_arrow = Identifier.fromNamespaceAndPath(Constants.MOD_ID, "textures/off_left_red_arrow.png");
|
||||||
|
Identifier green_arrow = Identifier.fromNamespaceAndPath(Constants.MOD_ID, "textures/green_arrow.png");
|
||||||
|
Identifier red_arrow = Identifier.fromNamespaceAndPath(Constants.MOD_ID, "textures/red_arrow.png");
|
||||||
|
Identifier off_green_arrow = Identifier.fromNamespaceAndPath(Constants.MOD_ID, "textures/off_green_arrow.png");
|
||||||
|
Identifier off_red_arrow = Identifier.fromNamespaceAndPath(Constants.MOD_ID, "textures/off_red_arrow.png");
|
||||||
|
|
||||||
void render(GuiGraphics graphics, DeltaTracker tracker);
|
void render(GuiGraphics graphics, DeltaTracker tracker);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.lukasabbe.simplehud.huds;
|
||||||
|
|
||||||
|
import net.minecraft.resources.Identifier;
|
||||||
|
|
||||||
|
public class StriderHud extends RideableHud{
|
||||||
|
@Override
|
||||||
|
public Identifier getIdentifier() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
+9
-4
@@ -5,8 +5,13 @@ import net.minecraft.client.player.LocalPlayer;
|
|||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import org.jspecify.annotations.Nullable;
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
public class BoatTools {
|
public class EntityTools {
|
||||||
public static boolean isRidingBoat(){
|
public static boolean isRidingEntity(Class<?> entityType){
|
||||||
|
var player = getLocalPlayer();
|
||||||
|
if(player == null) return false;
|
||||||
|
return getLocalPlayer().getVehicle() != null && entityType.isInstance(getLocalPlayer().getVehicle());
|
||||||
|
}
|
||||||
|
public static boolean isRidingEntity(){
|
||||||
var player = getLocalPlayer();
|
var player = getLocalPlayer();
|
||||||
if(player == null) return false;
|
if(player == null) return false;
|
||||||
return getLocalPlayer().getVehicle() != null;
|
return getLocalPlayer().getVehicle() != null;
|
||||||
@@ -15,7 +20,7 @@ public class BoatTools {
|
|||||||
public static double getAngle(){
|
public static double getAngle(){
|
||||||
var player = getLocalPlayer();
|
var player = getLocalPlayer();
|
||||||
if(player == null) return 0;
|
if(player == null) return 0;
|
||||||
if(!isRidingBoat()) return 0;
|
if(!isRidingEntity()) return 0;
|
||||||
|
|
||||||
var vehicle = player.getVehicle();
|
var vehicle = player.getVehicle();
|
||||||
var velocity = vehicle.getDeltaMovement().multiply(1, 0, 1);
|
var velocity = vehicle.getDeltaMovement().multiply(1, 0, 1);
|
||||||
@@ -30,7 +35,7 @@ public class BoatTools {
|
|||||||
public static double getRadians(float partialTick){
|
public static double getRadians(float partialTick){
|
||||||
var player = getLocalPlayer();
|
var player = getLocalPlayer();
|
||||||
if(player == null) return 0;
|
if(player == null) return 0;
|
||||||
if(!isRidingBoat()) return 0;
|
if(!isRidingEntity()) return 0;
|
||||||
float rawYaw = Mth.lerp(partialTick, player.getVehicle().yRotO, player.getVehicle().getYRot());
|
float rawYaw = Mth.lerp(partialTick, player.getVehicle().yRotO, player.getVehicle().getYRot());
|
||||||
|
|
||||||
float normalizedYaw = (rawYaw % 360);
|
float normalizedYaw = (rawYaw % 360);
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
"simple_hud.config.category.general.group.activated_huds.name": "Toggle HUD:s",
|
"simple_hud.config.category.general.group.activated_huds.name": "Toggle HUD:s",
|
||||||
"simple_hud.config.category.general.group.activated_huds.description": "Toggle menu for all transport HUD:s",
|
"simple_hud.config.category.general.group.activated_huds.description": "Toggle menu for all transport HUD:s",
|
||||||
"simple_hud.config.category.general.group.activated_huds.option.elytra_hud.name": "Elytra HUD",
|
"simple_hud.config.category.general.group.activated_huds.option.elytra_hud.name": "Elytra HUD",
|
||||||
"simple_hud.config.category.general.group.activated_huds.option.elytra_hud.description": "Elytra Hud toggle, if you don't want to see the an HUD when you fly.",
|
"simple_hud.config.category.general.group.activated_huds.option.elytra_hud.description": "Elytra Hud toggle",
|
||||||
"simple_hud.config.category.elytra_options.name": "Elytra HUD options",
|
"simple_hud.config.category.elytra_options.name": "Elytra HUD options",
|
||||||
"simple_hud.config.category.elytra_options.option.speed_enum.name": "Speed unit",
|
"simple_hud.config.category.elytra_options.option.speed_enum.name": "Speed unit",
|
||||||
"simple_hud.config.category.elytra_options.option.speed_enum.description": "You can change the speed unit to what you are used to",
|
"simple_hud.config.category.elytra_options.option.speed_enum.description": "You can change the speed unit to what you are used to",
|
||||||
@@ -14,5 +14,9 @@
|
|||||||
"simple_hud.config.speed_enum.ms": "m/s",
|
"simple_hud.config.speed_enum.ms": "m/s",
|
||||||
"simple_hud.config.category.boat_hud.name": "Boat HUD options",
|
"simple_hud.config.category.boat_hud.name": "Boat HUD options",
|
||||||
"simple_hud.config.category.general.group.activated_huds.option.boat_hud.name": "Boat HUD",
|
"simple_hud.config.category.general.group.activated_huds.option.boat_hud.name": "Boat HUD",
|
||||||
"simple_hud.config.category.general.group.activated_huds.option.boat_hud.description": "Boat Hud toggle, if you don't want to see the an HUD when you boat around."
|
"simple_hud.config.category.general.group.activated_huds.option.boat_hud.description": "Boat Hud toggle",
|
||||||
|
"simple_hud.config.category.general.option.scale.description": "Change the scale of the HUD",
|
||||||
|
"simple_hud.config.category.general.option.scale.name": "Scale",
|
||||||
|
"simple_hud.config.category.general.group.activated_huds.option.minecart_hud.name": "Minecart HUD",
|
||||||
|
"simple_hud.config.category.general.group.activated_huds.option.minecart_hud.description": "Minecart Hud toggle"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user