Merge branch 'master' into testing/no-hard-org-json
# Conflicts: # gradle.properties
This commit is contained in:
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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
@@ -182,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" +
|
||||
@@ -239,86 +241,80 @@ public class Client {
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
org.gradle.jvmargs=-Xmx8G
|
||||
|
||||
minecraft_version=1.21.5
|
||||
minecraft_version=1.21.6
|
||||
|
||||
archives_base_name=speedometer
|
||||
mod_version=6.3.0-no-hard-org-json
|
||||
mod_version=6.3.0
|
||||
maven_group=me.zacharias
|
||||
|
||||
# https://modrinth.com/mod/architectury-api/versions
|
||||
architectury_version=16.0.3
|
||||
architectury_version=17.0.6
|
||||
|
||||
# https://modrinth.com/mod/cloth-config/versions
|
||||
cloth_config_version = 18.0.145
|
||||
cloth_config_version = 19.0.147
|
||||
|
||||
# NeoForged Only
|
||||
# https://neoforged.net/
|
||||
neoforge_version = 21.5.14-beta
|
||||
neoforge_version = 21.6.12-beta
|
||||
|
||||
# Fabric Only
|
||||
# https://fabricmc.net/develop/
|
||||
fabric_loader_version=0.16.10
|
||||
fabric_api_version=0.119.6
|
||||
fabric_loader_version=0.16.14
|
||||
fabric_api_version=0.127.1
|
||||
|
||||
# Fabric Only
|
||||
# https://modrinth.com/mod/modmenu/versions
|
||||
modmenu_version = 14.0.0-rc.2
|
||||
modmenu_version = 15.0.0-beta.3
|
||||
|
||||
# Version of the org.json json library
|
||||
json_version = 20250517
|
||||
json_version = 20240303
|
||||
@@ -27,7 +27,7 @@ public class SpeedometerNeoForge {
|
||||
}
|
||||
}
|
||||
|
||||
@EventBusSubscriber(modid = MOD_ID, bus = EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
|
||||
@EventBusSubscriber(modid = MOD_ID,/* bus = EventBusSubscriber.Bus.MOD, */value = Dist.CLIENT)
|
||||
class EventHandler
|
||||
{
|
||||
/**
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
"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.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.2",
|
||||
@@ -18,6 +19,9 @@
|
||||
"1.21.4-recommended": "6.2.3",
|
||||
|
||||
"1.21.5-latest": "6.2.4",
|
||||
"1.21.5-recommended": "6.2.4"
|
||||
"1.21.5-recommended": "6.2.4",
|
||||
|
||||
"1.21.6-latest": "6.3.0",
|
||||
"1.21.6-recommended": "6.3.0"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user