Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
e5ac3d74c4
|
|||
|
66d63b03ea
|
|||
|
6f8b024bcc
|
|||
|
9c05791a20
|
|||
|
|
7be0ea014c | ||
|
|
0fdab6874c | ||
|
4f6bf01581
|
|||
|
ea3cd92c33
|
|||
|
|
2c88f99140 | ||
|
4b2a150a30
|
|||
|
bd205b5ae6
|
|||
|
192735d352
|
|||
|
216a498d72
|
|||
|
|
d7dbf65446 | ||
|
|
3e282612a3 |
2
.github/ISSUE_TEMPLATE/bug-report.md
vendored
2
.github/ISSUE_TEMPLATE/bug-report.md
vendored
@@ -27,7 +27,7 @@ assignees: zaze06
|
||||
|
||||
**Config**
|
||||
*If needed*
|
||||
*Use [GitHub Gist](gist.gihub.com) to upload your speedometer config, located in *
|
||||
*Use [GitHub Gist](gist.gihub.com) to upload your speedometer config, located in `<minecraft>/config/speedometer/config.json`*
|
||||
|
||||
**Logs**
|
||||
*If needed(Most of the times)*
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"description": "A different speedometer",
|
||||
"supported_formats": {
|
||||
"min_inclusive": 34,
|
||||
"max_inclusive": 57
|
||||
"max_inclusive": 80
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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 {
|
||||
|
||||
@@ -6,6 +6,7 @@ import dev.architectury.event.events.client.ClientTickEvent;
|
||||
import dev.architectury.platform.Platform;
|
||||
import dev.architectury.registry.client.keymappings.KeyMappingRegistry;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.CrashReport;
|
||||
import net.minecraft.client.DeltaTracker;
|
||||
import net.minecraft.client.KeyMapping;
|
||||
import net.minecraft.client.Minecraft;
|
||||
@@ -63,11 +64,10 @@ public class Client {
|
||||
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());
|
||||
}
|
||||
@@ -145,8 +145,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;
|
||||
|
||||
@@ -183,7 +183,8 @@ public class Client {
|
||||
}
|
||||
|
||||
if(Config.isDebug()){
|
||||
String debugData = "Velocity raw:" + "\n" +
|
||||
String debugData = "Speedometer: "+VERSION+"\n"+
|
||||
"Velocity raw:" + "\n" +
|
||||
" X: " + vec.x + "\n" +
|
||||
" Y: " + vec.y + "\n" +
|
||||
" Z: " + vec.z + "\n" +
|
||||
@@ -223,87 +224,97 @@ 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<>();
|
||||
ArrayList<String> tokens = new ArrayList<>();
|
||||
final char[] s = input.toCharArray();
|
||||
|
||||
try{
|
||||
for(int i = 0; i <s.length; i++){
|
||||
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(c == 'h' || c == 'w'){
|
||||
if(isXPosition) passerPose.add(String.valueOf(event.guiWidth() / 2));
|
||||
else passerPose.add(String.valueOf(event.guiHeight() / 2));
|
||||
}
|
||||
else if(c == 'S' || c == 's'){
|
||||
passerPose.add(String.valueOf(width));
|
||||
}
|
||||
else if(c == '+' ||
|
||||
if(c == '+' ||
|
||||
c == '-' ||
|
||||
c == '*' ||
|
||||
c == '/'){
|
||||
passerPose.add(Character.toString(c));
|
||||
tokens.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);
|
||||
if(lastIndex >= 0 && tokens.get(lastIndex).matches("^[0-9]+$")) {
|
||||
tokens.set(tokens.size() - 1, tokens.get(tokens.size() - 1) + c);
|
||||
}
|
||||
else
|
||||
{
|
||||
passerPose.add(Character.toString(c));
|
||||
tokens.add(Character.toString(c));
|
||||
}
|
||||
}
|
||||
else{
|
||||
throw new Exception();
|
||||
throw new IllegalArgumentException("Invalid character in input string: " + c);
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
passerPose.clear();
|
||||
defaultValues(event, isXPosition, passerPose);
|
||||
tokens.clear();
|
||||
defaultValues(event, isXPosition, tokens);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
int position;
|
||||
try{
|
||||
position = Integer.parseInt(passerPose.getFirst());
|
||||
position = Integer.parseInt(tokens.getFirst());
|
||||
}catch (NumberFormatException e){
|
||||
passerPose.clear();
|
||||
defaultValues(event, isXPosition, passerPose);
|
||||
position = Integer.parseInt(passerPose.getFirst());
|
||||
tokens.clear();
|
||||
defaultValues(event, isXPosition, tokens);
|
||||
position = Integer.parseInt(tokens.getFirst());
|
||||
}
|
||||
|
||||
for(int i = 1; i < passerPose.size(); i++){
|
||||
boolean first = false;
|
||||
String s1 = passerPose.get(i);
|
||||
String s2 = "";
|
||||
for(int i = 1; i < tokens.size(); i+=2){
|
||||
String operator = tokens.get(i);
|
||||
if(i + 1 >= tokens.size()) {
|
||||
LOGGER.error("Invalid expression: missing operand after operator '{}'", operator);
|
||||
break;
|
||||
}
|
||||
String operand = tokens.get(i + 1);
|
||||
int value;
|
||||
try {
|
||||
s2 = passerPose.get(i+1);
|
||||
}catch (Exception e){
|
||||
first = true;
|
||||
value = Integer.parseInt(operand);
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
LOGGER.error("Invalid operand: '{}'. Using default value. REPORT THIS! https://github.com/zaze06/Speedometer/issues/new/choose", operand);
|
||||
Minecraft.getInstance().emergencySaveAndCrash(new CrashReport("Invalid operand in speedometer position calculation. REPORT THIS! https://github.com/zaze06/Speedometer/issues/new/choose", e));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(Objects.equals(s1, "+") && !first){
|
||||
position += Integer.parseInt(s2);
|
||||
}else if(Objects.equals(s1, "-") && !first){
|
||||
position -= Integer.parseInt(s2);
|
||||
}else if(Objects.equals(s1, "*") && !first){
|
||||
position *= Integer.parseInt(s2);
|
||||
}else if(Objects.equals(s1, "/") && !first){
|
||||
position /= Integer.parseInt(s2);
|
||||
switch (operator) {
|
||||
case "+" -> position += value;
|
||||
case "-" -> position -= value;
|
||||
case "*" -> position *= value;
|
||||
case "/" -> position /= value;
|
||||
}
|
||||
}
|
||||
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: {}\n{}\n\n{}\n\n{}", speedDisplayType, splitRawSpeedPosition, position, rawSpeedPosition);
|
||||
|
||||
if (Config.isDebug() && Config.getCounter() < 2) {
|
||||
LOGGER.info("Selected speed type: {}\n{}\n\n{}\n\n{}",
|
||||
SpeedTypes.getName(Config.getSpeedType()).getString(),
|
||||
Arrays.toString(tokens.toArray()),
|
||||
position,
|
||||
isXPosition ? Config.getXPosition() : Config.getYPosition());
|
||||
Config.addCounter();
|
||||
}
|
||||
|
||||
return position;
|
||||
}
|
||||
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
@@ -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"
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
{
|
||||
"homepage": "https://modrinth.com/mod/speedometer/versions",
|
||||
"1.17.1": {
|
||||
"6.2.4": "Backport by request from issue #3"
|
||||
},
|
||||
"1.20.6": {
|
||||
"1.0": "First version",
|
||||
"2.0": "Made the speedometer text movable, added debug data display, added visual speedometer",
|
||||
@@ -104,6 +107,9 @@
|
||||
"1.20.1-recommended": "5.2",
|
||||
|
||||
"1.20-latest": "5.2",
|
||||
"1.20-recommended": "5.2"
|
||||
"1.20-recommended": "5.2",
|
||||
|
||||
"1.17.1-latest": "6.2.4",
|
||||
"1.17.1-recommended": "6.2.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
org.gradle.jvmargs=-Xmx8G
|
||||
|
||||
minecraft_version=1.21.4
|
||||
minecraft_version=1.21.6
|
||||
|
||||
archives_base_name=speedometer
|
||||
mod_version=6.2.2
|
||||
mod_version=6.3.0
|
||||
maven_group=me.zacharias
|
||||
|
||||
# https://modrinth.com/mod/architectury-api/versions
|
||||
architectury_version=15.0.1
|
||||
architectury_version=17.0.6
|
||||
|
||||
# https://modrinth.com/mod/cloth-config/versions
|
||||
cloth_config_version = 17.0.144
|
||||
cloth_config_version = 19.0.147
|
||||
|
||||
# NeoForged Only
|
||||
# https://neoforged.net/
|
||||
neoforge_version = 21.4.30-beta
|
||||
neoforge_version = 21.6.12-beta
|
||||
|
||||
# Fabric Only
|
||||
# https://fabricmc.net/develop/
|
||||
fabric_loader_version=0.16.9
|
||||
fabric_api_version=0.112.1
|
||||
fabric_loader_version=0.16.14
|
||||
fabric_api_version=0.127.1
|
||||
|
||||
# Fabric Only
|
||||
# https://modrinth.com/mod/modmenu/versions
|
||||
modmenu_version = 13.0.0-beta.1
|
||||
modmenu_version = 15.0.0-beta.3
|
||||
|
||||
# Version of the org.json json library
|
||||
json_version = 20240303
|
||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -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
|
||||
|
||||
@@ -2,6 +2,7 @@ package me.zacharias.speedometer.forge;
|
||||
|
||||
import com.mojang.datafixers.util.Unit;
|
||||
import me.zacharias.speedometer.Speedometer;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import net.minecraft.server.packs.resources.SimplePreparableReloadListener;
|
||||
import net.minecraft.util.profiling.ProfilerFiller;
|
||||
@@ -11,10 +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.event.RegisterClientReloadListenersEvent;
|
||||
import net.neoforged.neoforge.client.event.AddClientReloadListenersEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@Mod(Speedometer.MOD_ID)
|
||||
import static me.zacharias.speedometer.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
|
||||
@@ -24,7 +27,7 @@ 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
|
||||
{
|
||||
/**
|
||||
@@ -34,8 +37,8 @@ class EventHandler
|
||||
* @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 @NotNull Unit prepare(@NotNull ResourceManager arg, @NotNull ProfilerFiller arg2) {
|
||||
return Unit.INSTANCE;
|
||||
|
||||
@@ -5,10 +5,23 @@
|
||||
"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.1": "Fixed issue #3"
|
||||
"6.2.1": "Fixed issue #3",
|
||||
"6.2.2": "Fixed issue with multi digit position in the parser",
|
||||
"6.2.3": "Fixed crash issue from 6.2.2 when playing in 1.21.4",
|
||||
"6.2.4": "updated to 1.21.5",
|
||||
"6.3.0": "updated to 1.21.6, Fixed bug in tokenizer"
|
||||
},
|
||||
"promos": {
|
||||
"1.21-latest": "6.2.1",
|
||||
"1.21-recommended": "6.2.1"
|
||||
"1.21-latest": "6.2.2",
|
||||
"1.21-recommended": "6.2.2",
|
||||
|
||||
"1.21.4-latest": "6.2.3",
|
||||
"1.21.4-recommended": "6.2.3",
|
||||
|
||||
"1.21.5-latest": "6.2.4",
|
||||
"1.21.5-recommended": "6.2.4",
|
||||
|
||||
"1.21.6-latest": "6.3.0",
|
||||
"1.21.6-recommended": "6.3.0"
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,8 @@ This is a simple mod for Forge, Fabric, and NeoForged that displays your current
|
||||
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: `neoforged/build/libs`
|
||||
* NeoForge: `neoforged/build/libs`
|
||||
* Forge: `forge/build/libs`
|
||||
|
||||
## Forge Support Transition
|
||||
As of version 1.21 I chose to no longer support Forge in fevour of NeoForged
|
||||
|
||||
@@ -10,7 +10,7 @@ This feature is supported in
|
||||
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
|
||||
```json
|
||||
```jsonc
|
||||
"supported_formats": {
|
||||
"min_inclusive": 34,
|
||||
"max_inclusive": 57 // This needs to be the leatest pack_format
|
||||
@@ -71,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.
|
||||
|
||||
Reference in New Issue
Block a user