12 Commits
6.2 ... 6.2.4

Author SHA1 Message Date
4b2a150a30 Added translation key speedometer.config.error.missing_cloth.open_config
- Added Swedish and English translations
2025-04-01 02:21:17 +02:00
bd205b5ae6 Updated to 2.6.4
Changed the ClickEvent constructor for the missing cloth error with the new ClickEvent#OpenFile
2025-04-01 02:03:05 +02:00
192735d352 Merge remote-tracking branch 'origin/master' 2025-04-01 01:19:58 +02:00
216a498d72 Updated Gradle version to 8.13
Updated Architectury.loom to 1.10
Added Client#getPosImp to get some pre-processing of the position
\ Planes to replace the Client#getPos method

Updated to 6.2.3
This version is mostly needed for NeoForged due to changes of how the ClientReloadListenerEvent is added see changes in SpeedometerNeoForge.EventHandler#onResourceReload

version 6.2.2 is no longer marked as 1.21.4 compatible
2025-04-01 01:19:15 +02:00
Zacharias
d7dbf65446 Update resourcepack.md
Fixed the spesification of a comented json object from JSON to JSONC
2025-03-26 11:08:20 +01:00
Zacharias
3e282612a3 Update resourcepack.md
Fixed an î to an i
2024-12-20 21:19:55 +01:00
1a59e3dc2a fabric.mod.json:
neoforge.mods.toml:
> Updated minumum version of mods and load order

*.java:
> cleaned up some code

Updated to version 6.2.2
Fixed bug in Client.java for the position parser
2024-12-18 14:12:47 +01:00
1fc71a34a9 pack.mcmeta:
- Added `supported_formats` to make minecraft show it as compatible for newer versions

ReadMe.txt:
- A file added to optional resource pack root since interested people might check out the optional resource pack

resourcepack.md:
- Added lines to clarify the use of the schema
- Added lines to suggest the use of `supported_formats`
2024-12-11 20:38:10 +01:00
Zacharias
d1e5ef63ee Added a Feature request template 2024-12-11 20:02:23 +01:00
Zacharias
32b6198f71 Removed recomended and latest for forge since it's not planed to be supported 2024-11-05 16:41:52 +01:00
Zacharias
5c95f394a8 Update readme.md 2024-11-05 16:34:16 +01:00
38f96cb1e9 Fixed bug described in issue #3
> Now the speedometer (and debug screen) is hidden when f1(no gui) is toggled
2024-11-05 16:10:37 +01:00
24 changed files with 184 additions and 218 deletions

View File

@@ -0,0 +1,22 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''
---
Make sure your feature havent ben requested at [Feature Requests](https://github.com/zaze06/Speedometer/issues?q=label%3A%22Feature+Request%22)
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

View File

@@ -0,0 +1,6 @@
Hello there!
If you're reading this I assume you might be interested in making your own!
You're in luck, I have provided a guide. Over on GitHub on how to do it!
Please check out https://github.com/zaze06/Speedometer/blob/master/resourcepack.md for a guide to get started

View File

@@ -1,6 +1,10 @@
{
"pack": {
"pack_format": 34,
"description": "A different speedometer"
"description": "A different speedometer",
"supported_formats": {
"min_inclusive": 34,
"max_inclusive": 57
}
}
}

View File

@@ -1,6 +1,6 @@
plugins {
id "architectury-plugin" version "3.4-SNAPSHOT"
id "dev.architectury.loom" version "1.7-SNAPSHOT" apply false
id "dev.architectury.loom" version "1.10-SNAPSHOT" apply false
}
architectury {

View File

@@ -37,7 +37,7 @@ public class Client {
);
private static final ArrayList<Double> speeds = new ArrayList<>();
private static boolean speedometerVisualDisplayFailed = false;
public static void init(){
@@ -59,16 +59,15 @@ public class Client {
}
else if(Minecraft.getInstance().player != null)
{
Minecraft.getInstance().player.sendSystemMessage(
Minecraft.getInstance().player.displayClientMessage(
Component
.translatable("speedometer.error.missing_cloth")
.withColor(new Color(190, 0, 0).getRGB())
.append(" ")
.append(Component
.literal("Open Config")
.translatable("speedometer.error.missing_cloth.open_config")
.withStyle(ChatFormatting.UNDERLINE)
.withStyle((style) -> style.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, Config.getConfigPath())))
));
.withStyle((style) -> style.withClickEvent(new ClickEvent.OpenFile(Config.getConfigPath())))
), false);
LOGGER.warn(Component.translatable("speedometer.error.missing_cloth").getString());
}
else
@@ -91,43 +90,11 @@ public class Client {
ClientGuiEvent.RENDER_HUD.register(Client::render);
LOGGER.info("Finished loading speedometer");
/*((IPackRepository) Minecraft.getInstance().getResourcePackRepository()).addSource(new RepositorySource() {
@Override
public void loadPacks(Consumer<Pack> consumer) {
consumer.accept(new Pack(new PackLocationInfo(
"quarter_circle_speedometer",
Component.translatable("resourcepack.speedometer.quarter_circle_speedometer"),
new PackSource() {
@Override
public Component decorate(Component component) {
return component;
}
@Override
public boolean shouldAddAutomatically() {
return false;
}
},
Optional.empty()
),
new Pack.ResourcesSupplier() {
@Override
public PackResources openPrimary(PackLocationInfo packLocationInfo) {
return packLocationInfo.;
}
@Override
public PackResources openFull(PackLocationInfo packLocationInfo, Pack.Metadata metadata) {
return null;
}
}));
}
});*/
}
private static void render(GuiGraphics graphics, DeltaTracker deltaTracker) {
if(Minecraft.getInstance().player == null) return;
if(Minecraft.getInstance().options.hideGui) return;
Entity entity = Minecraft.getInstance().player.getRootVehicle();
Vec3 vec = new Vec3(
@@ -177,8 +144,8 @@ public class Client {
default -> 0;
};
int yPos = getPos(graphics, width, Config.getYPosition(), false);
int xPos = getPos(graphics, width, Config.getXPosition(), true);
int yPos = getPosImp(graphics, width, Config.getYPosition(), false);
int xPos = getPosImp(graphics, width, Config.getXPosition(), true);
int lineHeight = Minecraft.getInstance().font.lineHeight;
@@ -188,42 +155,6 @@ public class Client {
BufferedImage img = ImageHandler.scale(ICON.getSpeedometerIcon(speedTypeSpeed), Config.getImageSize(), Config.getImageSize());
/*int radius = img.getWidth()/2-4;
int x3 = (int) Math.round(radius*Math.cos(Math.toRadians(i+90)))+(img.getWidth()/2);
int y3 = (int) Math.round(radius*Math.sin(Math.toRadians(i+90)))+(img.getHeight()/2);
Graphics2D g2d = img.createGraphics();
g2d.setColor(new Color(138, 0, 0));
g2d.setStroke(new BasicStroke(2));
g2d.drawLine(x3,y3,img.getWidth()/2,img.getHeight()/2);
for(int x1 = 0; x1 < img.getWidth(); x1++){
for(int y1 = 0; y1 < img.getHeight(); y1++){
int x2 = x1 + xPos - img.getWidth();
int y2 = y1 + yPos - img.getHeight();
int rgb = img.getRGB(x1, y1);
if(new Color(rgb).equals(Color.black)) continue;
graphics.fill(x2, y2, x2+1, y2+1, rgb);
}
}
if(i >= 360+45){
String string = "x" + (int)Math.floor(i/(365+45));
graphics.drawString(
Minecraft.getInstance().font,
string,
xPos-Minecraft.getInstance().font.width(string),
(int)(yPos-4.5-((double) Config.getImageSize() /2)),
new Color(138, 0, 0).getRGB()
);
}*/
for(int x1 = 0; x1 < img.getWidth(); x1++){
for(int y1 = 0; y1 < img.getHeight(); y1++){
int x2 = x1 + xPos - img.getWidth();
@@ -267,8 +198,8 @@ public class Client {
" Total: " + lSpeed + "\n" +
"Velocity total average: " + speed + "\n" +
"Velocity total in " + speedType.name() + ": " + speedTypeSpeed + "\n" +
"Endpoint position: (" + Debuger.x + ", " + Debuger.y + ")\n" +
"Percentage point of visual speedometer: " + Debuger.angle + "\n" +
"Endpoint position: (" + Debugger.x + ", " + Debugger.y + ")\n" +
"Percentage point of visual speedometer: " + Debugger.angle + "\n" +
(Config.getVisualSpeedometer()?"Visual Size: "+Config.getImageSize():"Textual display");
Color color = new Color(255, 255, 255);
@@ -291,42 +222,57 @@ public class Client {
);
}
private static int getPosImp(GuiGraphics event, int width, String input, boolean isXPosition){
input = input.trim();
input = input
.replaceAll("(W+)|(H+)", String.valueOf(isXPosition?event.guiWidth():event.guiHeight()))
.replaceAll("(w+)|(h+)", String.valueOf(isXPosition?event.guiWidth()/2:event.guiHeight()/2))
.replaceAll("(S+)|(s+)", String.valueOf(width));
if((Config.isDebug()) && Config.getCounter() < 2) {
//String speedDisplayType = SpeedTypes.getName(Config.getSpeedType()).getString();
//String splitRawSpeedPosition = Arrays.toString(passerPose.toArray());
//String rawSpeedPosition = isXPosition ? Config.getXPosition() : Config.getYPosition();
LOGGER.info("Selected speed type(DEBUG): {}\n{}\n\n\n", isXPosition, input);
Config.addCounter();
}
return getPos(event, width, input, isXPosition);
}
private static int getPos(GuiGraphics event, int width, String input, boolean isXPosition) {
ArrayList<String> passerPose = new ArrayList<>();
final char[] s = input.toCharArray();
try{
for(int i = 0; i <s.length; i++){
if(s[i] == 'W' || s[i] == 'H'){
char c = s[i];
if(c == 'W' || c == 'H'){
if(isXPosition) passerPose.add(String.valueOf(event.guiWidth()));
else passerPose.add(String.valueOf(event.guiHeight()));
}else if(s[i] == 'h' || s[i] == 'w'){
}
else if(c == 'h' || c == 'w'){
if(isXPosition) passerPose.add(String.valueOf(event.guiWidth() / 2));
else passerPose.add(String.valueOf(event.guiHeight() / 2));
}else if(s[i] == 'S' || s[i] == 's'){
}
else if(c == 'S' || c == 's'){
passerPose.add(String.valueOf(width));
}else if(s[i] == '+'){
passerPose.add("+");
}else if(s[i] == '-'){
passerPose.add("-");
}else if(s[i] == '*'){
passerPose.add("/");
}else if(s[i] == '/'){
passerPose.add("/");
}else if(Character.isDigit(s[i])){
try{
if(i-1 > 0 && passerPose.get(i - 1).matches("^[0-9]+$")) {
Integer.parseInt(passerPose.get(i - 1));
passerPose.add(i - 1, passerPose.get(i - 1) + s[i]);
}
else if(c == '+' ||
c == '-' ||
c == '*' ||
c == '/'){
passerPose.add(Character.toString(c));
}
else if(Character.isDigit(c)){
int lastIndex = i - 1;
if(lastIndex > 0 && passerPose.get(lastIndex).matches("^[0-9]+$")) {
passerPose.add(passerPose.removeLast() + c);
}
else
{
passerPose.add(Character.toString(s[i]));
passerPose.add(Character.toString(c));
}
}catch (NumberFormatException e){
passerPose.add(Character.toString(s[i]));
}
}else{
else{
throw new Exception();
}
}
@@ -341,6 +287,7 @@ public class Client {
try{
position = Integer.parseInt(passerPose.getFirst());
}catch (NumberFormatException e){
passerPose.clear();
defaultValues(event, isXPosition, passerPose);
position = Integer.parseInt(passerPose.getFirst());
}

View File

@@ -1,7 +1,6 @@
package me.zacharias.speedometer;
import dev.architectury.platform.Platform;
import net.minecraft.client.Minecraft;
import org.json.JSONException;
import org.json.JSONObject;
@@ -32,7 +31,7 @@ public class Config {
}
config = new JSONObject();
defualt();
defaultValues();
}else {
try {
BufferedReader in = new BufferedReader(new FileReader(configFile));
@@ -62,7 +61,7 @@ public class Config {
}
config = new JSONObject();
defualt();
defaultValues();
return;
}
@@ -72,20 +71,20 @@ public class Config {
if(config.getFloat("version")!=configVersion){
if(config.getFloat("version") > configVersion){
LOGGER.warn("Config version is too new, resting");
defualt();
defaultValues();
save();
}else if(config.getFloat("version") < configVersion){
config = new JSONObject();
LOGGER.warn("Config version is outdated, resting");
defualt();
defaultValues();
save();
}
}
}else{
config = new JSONObject();
defualt();
defaultValues();
save();
}
} catch (IOException e) {
@@ -94,7 +93,7 @@ public class Config {
}
}
private static void defualt() {
private static void defaultValues() {
if(!config.has("speed")) {
config.put("speed", SpeedTypes.BlockPS);
}

View File

@@ -23,9 +23,7 @@ public class ConfigMenu {
);
category.addEntry(entryBuilder.startColorField(Component.translatable("speedometer.config.color"), me.zacharias.speedometer.Config.getColorRGB())
.setSaveConsumer2(color -> {
me.zacharias.speedometer.Config.setColor(color.getRed(), color.getGreen(), color.getBlue());
})
.setSaveConsumer2(color -> Config.setColor(color.getRed(), color.getGreen(), color.getBlue()))
.build()
);

View File

@@ -1,6 +1,6 @@
package me.zacharias.speedometer;
public class Debuger {
public class Debugger {
public static double angle;
public static double x;
public static double y;

View File

@@ -3,17 +3,11 @@ package me.zacharias.speedometer;
import net.minecraft.network.chat.Component;
public enum SpeedTypes {
MPH(20),
KMPH(200),
MPS(10),
BlockPS(10),
KNOT(20);
private final int maxVisual;
SpeedTypes(int maxVisual){
this.maxVisual = maxVisual;
}
MPH,
KMPH,
MPS,
BlockPS,
KNOT;
public static Component getName(Enum anEnum) {
if(anEnum instanceof SpeedTypes speedType) {
@@ -28,8 +22,4 @@ public enum SpeedTypes {
return Component.translatable("speedometer.speed.error");
}
}
public int gatMaxVisual() {
return maxVisual;
}
}

View File

@@ -3,7 +3,6 @@ package me.zacharias.speedometer;
import dev.architectury.platform.Platform;
import dev.architectury.utils.Env;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.Resource;
import net.minecraft.server.packs.resources.ResourceManager;
@@ -64,8 +63,7 @@ public class Speedometer
return;
}
try {
BufferedReader stream = resource.get().openAsReader();
try(BufferedReader stream = resource.get().openAsReader()) {
String tmp;
StringBuilder builder = new StringBuilder();
while ((tmp = stream.readLine()) != null) {

View File

@@ -10,14 +10,11 @@ import org.json.JSONObject;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Objects;
import java.util.Optional;
import static me.zacharias.speedometer.Speedometer.MOD_ID;
public class SpeedometerIcon {
private BufferedImage speedometerIcon;
private Pointer pointer;
@@ -169,7 +166,7 @@ class Pointer
}
double angle = ((speed/max) * end)+start;
if(angle > end && !overflow) angle = end;
Debuger.angle = angle;
Debugger.angle = angle;
if(Objects.nonNull(image))
{
@@ -183,8 +180,8 @@ class Pointer
double angleRads = Math.toRadians(180+angle);
int endX = (int) (Math.cos(angleRads) * length + this.start.x);
int endY = (int) (Math.sin(angleRads) * length + this.start.y);
Debuger.x = endX;
Debuger.y = endY;
Debugger.x = endX;
Debugger.y = endY;
g2d.setColor(c);
g2d.setStroke(new BasicStroke(3, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));

View File

@@ -68,7 +68,8 @@
"speedometer.config.error.size_outofbounds": "The size is out of bounds 10<=size<=300",
"speedometer.error.missing_cloth": "Missing Cloth Config API for Config Screen",
"speedometer.error.missing_cloth": "Missing Cloth Config API for Config Screen, ",
"speedometer.error.missing_cloth.open_config": "Open Config",
"resourcepack.speedometer.quarter_circle_speedometer": "Quarter circle Speedometer"
}

View File

@@ -68,7 +68,8 @@
"speedometer.config.error.size_outofbounds": "Stolekten är felakting 10<=stolek<=300",
"speedometer.error.missing_cloth": "Saknar Cloth Config API för konfigurationsskärmen",
"speedometer.error.missing_cloth": "Saknar Cloth Config API för konfigurationsskärmen, ",
"speedometer.error.missing_cloth.open_config": "Öppna Config",
"resourcepack.speedometer.quarter_circle_speedometer": "Quarter circle Speedometer"
}

View File

@@ -23,12 +23,12 @@ repositories {
dependencies {
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}"
modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}+${rootProject.minecraft_version}"
// Remove the next line if you don't want to depend on the API
modApi "dev.architectury:architectury-fabric:${rootProject.architectury_version}"
modApi "me.shedaniel.cloth:cloth-config-fabric:${rootProject.cloth_config_version}"
modApi "com.terraformersmc:modmenu:11.0.0"
modApi "com.terraformersmc:modmenu:${rootProject.modmenu_version}"
modApi "eu.pb4:placeholder-api:2.4.0-pre.2+1.21"
common(project(path: ":common", configuration: "namedElements")) { transitive false }

View File

@@ -3,23 +3,11 @@ package me.zacharias.speedometer.fabric;
import me.zacharias.speedometer.Speedometer;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
import net.fabricmc.fabric.api.resource.ResourcePackActivationType;
import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.ModContainer;
import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.PackType;
import net.minecraft.server.packs.repository.RepositorySource;
import net.minecraft.server.packs.resources.ResourceManager;
import java.util.HashSet;
import java.util.Set;
import static me.zacharias.speedometer.Speedometer.LOGGER;
import static me.zacharias.speedometer.Speedometer.MOD_ID;
public class SpeedometerFabric implements ModInitializer {
@Override
public void onInitialize() {

View File

@@ -21,9 +21,9 @@
"depends": {
"fabricloader": ">=0.15.11",
"minecraft": ">=1.21",
"architectury": ">=13.0.1"
"architectury": ">=13.0.5"
},
"suggests": {
"cloth-config1": ">=15.0.127"
"cloth-config1": ">=15.0.140"
}
}

View File

@@ -9,7 +9,8 @@
"4.0": "Removed the Size part of the position string, combined the visual and text location strings, updated config version to 3, fixed bug where the text would start to drift of screen if you where too fast",
"5.0": "Visual speed display has been added",
"5.1": "Added second speed display",
"5.2": "Fixed issue #1"
"5.2": "Fixed issue #1",
"5.2.1": "Fixed issue #3"
},
"1.20.5": {
"1.0": "First version",
@@ -20,7 +21,8 @@
"4.0": "Removed the Size part of the position string, combined the visual and text location strings, updated config version to 3, fixed bug where the text would start to drift of screen if you where too fast",
"5.0": "Visual speed display has been added",
"5.1": "Added second speed display",
"5.2": "Fixed issue #1"
"5.2": "Fixed issue #1",
"5.2.1": "Fixed issue #3"
},
"1.20.4": {
"1.0": "First version",
@@ -31,7 +33,8 @@
"4.0": "Removed the Size part of the position string, combined the visual and text location strings, updated config version to 3, fixed bug where the text would start to drift of screen if you where too fast",
"5.0": "Visual speed display has been added",
"5.1": "Added second speed display",
"5.2": "Fixed issue #1"
"5.2": "Fixed issue #1",
"5.2.1": "Fixed issue #3"
},
"1.20.3": {
"1.0": "First version",
@@ -42,7 +45,8 @@
"4.0": "Removed the Size part of the position string, combined the visual and text location strings, updated config version to 3, fixed bug where the text would start to drift of screen if you where too fast",
"5.0": "Visual speed display has been added",
"5.1": "Added second speed display",
"5.2": "Fixed issue #1"
"5.2": "Fixed issue #1",
"5.2.1": "Fixed issue #3"
},
"1.20.2": {
"1.0": "First version",
@@ -53,7 +57,8 @@
"4.0": "Removed the Size part of the position string, combined the visual and text location strings, updated config version to 3, fixed bug where the text would start to drift of screen if you where too fast",
"5.0": "Visual speed display has been added",
"5.1": "Added second speed display",
"5.2": "Fixed issue #1"
"5.2": "Fixed issue #1",
"5.2.1": "Fixed issue #3"
},
"1.20.1": {
"1.0": "First version",
@@ -64,7 +69,8 @@
"4.0": "Removed the Size part of the position string, combined the visual and text location strings, updated config version to 3, fixed bug where the text would start to drift of screen if you where too fast",
"5.0": "Visual speed display has been added",
"5.1": "Added second speed display",
"5.2": "Fixed issue #1"
"5.2": "Fixed issue #1",
"5.2.1": "Fixed issue #3"
},
"1.20": {
"1.0": "First version",
@@ -75,7 +81,8 @@
"4.0": "Removed the Size part of the position string, combined the visual and text location strings, updated config version to 3, fixed bug where the text would start to drift of screen if you where too fast",
"5.0": "Visual speed display has been added",
"5.1": "Added second speed display",
"5.2": "Fixed issue #1"
"5.2": "Fixed issue #1",
"5.2.1": "Fixed issue #3"
},
"promos": {
"1.20.6-latest": "5.2",

View File

@@ -1,19 +1,29 @@
org.gradle.jvmargs=-Xmx8G
minecraft_version=1.21.1
minecraft_version=1.21.5
archives_base_name=speedometer
mod_version=6.2
mod_version=6.2.4
maven_group=me.zacharias
architectury_version=13.0.8
# https://modrinth.com/mod/architectury-api/versions
architectury_version=16.0.3
fabric_loader_version=0.16.5
fabric_api_version=0.105.0+1.21.1
# https://modrinth.com/mod/cloth-config/versions
cloth_config_version = 18.0.145
neoforge_version = 21.1.66
# NeoForged Only
# https://neoforged.net/
neoforge_version = 21.5.14-beta
cloth_config_version = 15.0.140
# Fabric Only
# https://fabricmc.net/develop/
fabric_loader_version=0.16.10
fabric_api_version=0.119.6
# Fabric Only
# https://modrinth.com/mod/modmenu/versions
modmenu_version = 14.0.0-rc.2
# Version of the org.json json library
json_version = 20240303

View File

@@ -1,6 +1,6 @@
#Fri Jun 21 10:45:53 CEST 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@@ -2,18 +2,7 @@ package me.zacharias.speedometer.forge;
import com.mojang.datafixers.util.Unit;
import me.zacharias.speedometer.Speedometer;
import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.AbstractPackResources;
import net.minecraft.server.packs.PackLocationInfo;
import net.minecraft.server.packs.PackResources;
import net.minecraft.server.packs.PackType;
import net.minecraft.server.packs.repository.KnownPack;
import net.minecraft.server.packs.repository.Pack;
import net.minecraft.server.packs.repository.PackSource;
import net.minecraft.server.packs.resources.IoSupplier;
import net.minecraft.server.packs.resources.PreparableReloadListener;
import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.server.packs.resources.SimplePreparableReloadListener;
import net.minecraft.util.profiling.ProfilerFiller;
@@ -23,21 +12,12 @@ import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
import net.neoforged.neoforge.client.ClientNeoForgeMod;
import net.neoforged.neoforge.client.event.RegisterClientReloadListenersEvent;
import net.neoforged.neoforge.common.NeoForge;
import net.neoforged.neoforge.resource.ResourcePackLoader;
import org.jetbrains.annotations.Nullable;
import net.neoforged.neoforge.client.event.AddClientReloadListenersEvent;
import org.jetbrains.annotations.NotNull;
import java.io.InputStream;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import static me.zacharias.speedometer.Speedometer.MOD_ID;
import static me.zacharias.speedometer.Speedometer.*;
@Mod(Speedometer.MOD_ID)
@Mod(MOD_ID)
public class SpeedometerNeoForge {
public SpeedometerNeoForge(IEventBus eventBus) {
// Submit our event bus to let architectury register our content on the right time
@@ -47,25 +27,25 @@ public class SpeedometerNeoForge {
}
}
@EventBusSubscriber(modid = Speedometer.MOD_ID, bus = EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
@EventBusSubscriber(modid = MOD_ID, bus = EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
class EventHandler
{
/**
* Register the reload listener for the speedometers
* This is required since i havent found how to put this in the Architecture Abstraction layer(Common module)
* This is required since i haven't found how to put this in the Architecture Abstraction layer(Common module)
* TODO: Find a way to put this in the Abstraction layer
* @param event The event that is fired when the client reloads resources
*/
@SubscribeEvent
private static void onResourceReload(RegisterClientReloadListenersEvent event) {
event.registerReloadListener(new SimplePreparableReloadListener<Unit>() {
private static void onResourceReload(AddClientReloadListenersEvent event) {
event.addListener(ResourceLocation.fromNamespaceAndPath(MOD_ID, "reload_listener"), new SimplePreparableReloadListener<Unit>() {
@Override
protected Unit prepare(ResourceManager arg, ProfilerFiller arg2) {
protected @NotNull Unit prepare(@NotNull ResourceManager arg, @NotNull ProfilerFiller arg2) {
return Unit.INSTANCE;
}
@Override
protected void apply(Unit object, ResourceManager resourceManager, ProfilerFiller arg2) {
protected void apply(@NotNull Unit object, @NotNull ResourceManager resourceManager, @NotNull ProfilerFiller arg2) {
Speedometer.loadSpeedometers(resourceManager);
}
});

View File

@@ -82,12 +82,12 @@ Just displaying your speed
[[dependencies.speedometer]]
modId="architectury"
mandatory=true
versionRange="[13.0.1,)"
ordering="NONE"
versionRange="[13.0.5,)"
ordering="BEFORE"
side="CLIENT"
[[dependencies.speedometer]]
modId="cloth_config"
mandatory=false
versionRange="[15.0.127,)"
ordering="NONE"
type="optional"
versionRange="[15.0.140,)"
ordering="BEFORE"
side="CLIENT"

View File

@@ -4,10 +4,11 @@
"6.0": "Lost support for Forge and gain NeoForge support",
"6.0.1": "Small bug fix in Parser",
"6.1": "Small bug fix in Parser",
"6.2": "Making speedometer and pointer resource pack based"
"6.2": "Making speedometer and pointer resource pack based",
"6.2.1": "Fixed issue #3"
},
"promos": {
"1.21-latest": "6.1",
"1.21-recommended": "6.1"
"1.21-latest": "6.2.1",
"1.21-recommended": "6.2.1"
}
}

View File

@@ -1,8 +1,8 @@
# Speedometer
This is a simple mod for forge and fabric that displays your current speed
This is a simple mod for Forge, Fabric, and NeoForged that displays your current speed
## Credits to
[org.json](https://www.json.org/json-en.html) *Included due to problems whit ForgeGradle*
[org.json](https://www.json.org/json-en.html) *Included due to problems whit Gradle and building*
## Compile your own version?
1. Download source code
@@ -13,7 +13,10 @@ This is a simple mod for forge and fabric that displays your current speed
3. Run `gradlew build`(Windows cmd) or `./gradlew build`(Linux, MacOS, Windows powershell)
4. the compiled version will be in
* Fabic: `fabric/build/libs`
* Forge: `forge/build/libs`
* Forge: `neoforged/build/libs`
## Forge Support Transition
As of version 1.21 I chose to no longer support Forge in fevour of NeoForged
# This mod is a newer version of [speedometer-forge](https://github.com/zaze06/speedometer-forge)

View File

@@ -9,6 +9,13 @@ This feature is supported in
## `pack.mcmeta`
The mcmeta file has no differences just make sure it's a valid pack_format for the version
- 1.21.x: `"pack_format": 34`
- I recommend adding this, so that you don't need to update the format since the only real requirement is using version 6.2 or newer of this mod
```jsonc
"supported_formats": {
"min_inclusive": 34,
"max_inclusive": 57 // This needs to be the leatest pack_format
}
```
## File Locations
So the speedometer is built upon 2 main things
@@ -33,7 +40,7 @@ base
```
## `speedometer.json` example *Standard speedometer.json file*
```
```json
{
"background": "speedometer:meter/speedometer.png",
"start": -45,
@@ -64,7 +71,7 @@ base
This boolean is false if the pointer locks at the `end` angle when the speed exceeds `maxSpeed`.
- pointer
This defines properties of the pointer.
- color *not required, but if not present then `ìmage` most be*
- color *not required, but if not present then `image` most be*
The color value should be a hexadecimal RGB code, e.g., #b00219, where # is followed by six characters representing red, green, and blue values (00-FF for each component).
- length *not required if `image` is not defined*
The length in picture based on the original size of the background.
@@ -78,3 +85,10 @@ base
The scale of how to modify the speed as a power, this is the speed that `maxSpeed` is based of. the way the speed passed to `maxSpeed` is calculated is `baseSpeed^scale`.
- name
A string that is the name of this speedometer. *This is just used to send a log message about the speedometer*
## JSON formating help
I have created a JSON schema for this that is available at [speedometer_config_schema.json](https://github.com/zaze06/Speedometer/blob/master/schemas/speedometer_config_schema.json), please refer to your Advanced Text Editor on how to add a schema, if your editor supports the `$schema` feature then add
```json
"$schema": "https://raw.githubusercontent.com/zaze06/Speedometer/refs/heads/master/schemas/speedometer_config_schema.json",
```
in the root object, and the schema should apply, else if your editor supports it you can add the schema to all `speedometer.json` files