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**
|
**Config**
|
||||||
*If needed*
|
*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**
|
**Logs**
|
||||||
*If needed(Most of the times)*
|
*If needed(Most of the times)*
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
"description": "A different speedometer",
|
"description": "A different speedometer",
|
||||||
"supported_formats": {
|
"supported_formats": {
|
||||||
"min_inclusive": 34,
|
"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.platform.Platform;
|
||||||
import dev.architectury.registry.client.keymappings.KeyMappingRegistry;
|
import dev.architectury.registry.client.keymappings.KeyMappingRegistry;
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
|
import net.minecraft.CrashReport;
|
||||||
import net.minecraft.client.DeltaTracker;
|
import net.minecraft.client.DeltaTracker;
|
||||||
import net.minecraft.client.KeyMapping;
|
import net.minecraft.client.KeyMapping;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
@@ -182,7 +183,8 @@ public class Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(Config.isDebug()){
|
if(Config.isDebug()){
|
||||||
String debugData = "Velocity raw:" + "\n" +
|
String debugData = "Speedometer: "+VERSION+"\n"+
|
||||||
|
"Velocity raw:" + "\n" +
|
||||||
" X: " + vec.x + "\n" +
|
" X: " + vec.x + "\n" +
|
||||||
" Y: " + vec.y + "\n" +
|
" Y: " + vec.y + "\n" +
|
||||||
" Z: " + vec.z + "\n" +
|
" Z: " + vec.z + "\n" +
|
||||||
@@ -239,86 +241,80 @@ public class Client {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static int getPos(GuiGraphics event, int width, String input, boolean 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();
|
final char[] s = input.toCharArray();
|
||||||
|
|
||||||
try{
|
try{
|
||||||
for(int i = 0; i <s.length; i++){
|
for(int i = 0; i <s.length; i++){
|
||||||
char c = s[i];
|
char c = s[i];
|
||||||
if(c == 'W' || c == 'H'){
|
if(c == '+' ||
|
||||||
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 == '+' ||
|
|
||||||
c == '-' ||
|
c == '-' ||
|
||||||
c == '*' ||
|
c == '*' ||
|
||||||
c == '/'){
|
c == '/'){
|
||||||
passerPose.add(Character.toString(c));
|
tokens.add(Character.toString(c));
|
||||||
}
|
}
|
||||||
else if(Character.isDigit(c)){
|
else if(Character.isDigit(c)){
|
||||||
int lastIndex = i - 1;
|
int lastIndex = i - 1;
|
||||||
if(lastIndex > 0 && passerPose.get(lastIndex).matches("^[0-9]+$")) {
|
if(lastIndex >= 0 && tokens.get(lastIndex).matches("^[0-9]+$")) {
|
||||||
passerPose.add(passerPose.removeLast() + c);
|
tokens.set(tokens.size() - 1, tokens.get(tokens.size() - 1) + c);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
passerPose.add(Character.toString(c));
|
tokens.add(Character.toString(c));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
throw new Exception();
|
throw new IllegalArgumentException("Invalid character in input string: " + c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
passerPose.clear();
|
tokens.clear();
|
||||||
defaultValues(event, isXPosition, passerPose);
|
defaultValues(event, isXPosition, tokens);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
|
|
||||||
int position;
|
int position;
|
||||||
try{
|
try{
|
||||||
position = Integer.parseInt(passerPose.getFirst());
|
position = Integer.parseInt(tokens.getFirst());
|
||||||
}catch (NumberFormatException e){
|
}catch (NumberFormatException e){
|
||||||
passerPose.clear();
|
tokens.clear();
|
||||||
defaultValues(event, isXPosition, passerPose);
|
defaultValues(event, isXPosition, tokens);
|
||||||
position = Integer.parseInt(passerPose.getFirst());
|
position = Integer.parseInt(tokens.getFirst());
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 1; i < passerPose.size(); i++){
|
for(int i = 1; i < tokens.size(); i+=2){
|
||||||
boolean first = false;
|
String operator = tokens.get(i);
|
||||||
String s1 = passerPose.get(i);
|
if(i + 1 >= tokens.size()) {
|
||||||
String s2 = "";
|
LOGGER.error("Invalid expression: missing operand after operator '{}'", operator);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
String operand = tokens.get(i + 1);
|
||||||
|
int value;
|
||||||
try {
|
try {
|
||||||
s2 = passerPose.get(i+1);
|
value = Integer.parseInt(operand);
|
||||||
}catch (Exception e){
|
}
|
||||||
first = true;
|
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){
|
switch (operator) {
|
||||||
position += Integer.parseInt(s2);
|
case "+" -> position += value;
|
||||||
}else if(Objects.equals(s1, "-") && !first){
|
case "-" -> position -= value;
|
||||||
position -= Integer.parseInt(s2);
|
case "*" -> position *= value;
|
||||||
}else if(Objects.equals(s1, "*") && !first){
|
case "/" -> position /= value;
|
||||||
position *= Integer.parseInt(s2);
|
|
||||||
}else if(Objects.equals(s1, "/") && !first){
|
|
||||||
position /= Integer.parseInt(s2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if((Config.isDebug()) && Config.getCounter() < 2) {
|
|
||||||
String speedDisplayType = SpeedTypes.getName(Config.getSpeedType()).getString();
|
if (Config.isDebug() && Config.getCounter() < 2) {
|
||||||
String splitRawSpeedPosition = Arrays.toString(passerPose.toArray());
|
LOGGER.info("Selected speed type: {}\n{}\n\n{}\n\n{}",
|
||||||
String rawSpeedPosition = isXPosition ? Config.getXPosition() : Config.getYPosition();
|
SpeedTypes.getName(Config.getSpeedType()).getString(),
|
||||||
LOGGER.info("Selected speed type: {}\n{}\n\n{}\n\n{}", speedDisplayType, splitRawSpeedPosition, position, rawSpeedPosition);
|
Arrays.toString(tokens.toArray()),
|
||||||
|
position,
|
||||||
|
isXPosition ? Config.getXPosition() : Config.getYPosition());
|
||||||
Config.addCounter();
|
Config.addCounter();
|
||||||
}
|
}
|
||||||
|
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,29 +1,29 @@
|
|||||||
org.gradle.jvmargs=-Xmx8G
|
org.gradle.jvmargs=-Xmx8G
|
||||||
|
|
||||||
minecraft_version=1.21.5
|
minecraft_version=1.21.6
|
||||||
|
|
||||||
archives_base_name=speedometer
|
archives_base_name=speedometer
|
||||||
mod_version=6.3.0-no-hard-org-json
|
mod_version=6.3.0
|
||||||
maven_group=me.zacharias
|
maven_group=me.zacharias
|
||||||
|
|
||||||
# https://modrinth.com/mod/architectury-api/versions
|
# https://modrinth.com/mod/architectury-api/versions
|
||||||
architectury_version=16.0.3
|
architectury_version=17.0.6
|
||||||
|
|
||||||
# https://modrinth.com/mod/cloth-config/versions
|
# https://modrinth.com/mod/cloth-config/versions
|
||||||
cloth_config_version = 18.0.145
|
cloth_config_version = 19.0.147
|
||||||
|
|
||||||
# NeoForged Only
|
# NeoForged Only
|
||||||
# https://neoforged.net/
|
# https://neoforged.net/
|
||||||
neoforge_version = 21.5.14-beta
|
neoforge_version = 21.6.12-beta
|
||||||
|
|
||||||
# Fabric Only
|
# Fabric Only
|
||||||
# https://fabricmc.net/develop/
|
# https://fabricmc.net/develop/
|
||||||
fabric_loader_version=0.16.10
|
fabric_loader_version=0.16.14
|
||||||
fabric_api_version=0.119.6
|
fabric_api_version=0.127.1
|
||||||
|
|
||||||
# Fabric Only
|
# Fabric Only
|
||||||
# https://modrinth.com/mod/modmenu/versions
|
# 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
|
# 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
|
class EventHandler
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -8,7 +8,8 @@
|
|||||||
"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.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.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": {
|
"promos": {
|
||||||
"1.21-latest": "6.2.2",
|
"1.21-latest": "6.2.2",
|
||||||
@@ -18,6 +19,9 @@
|
|||||||
"1.21.4-recommended": "6.2.3",
|
"1.21.4-recommended": "6.2.3",
|
||||||
|
|
||||||
"1.21.5-latest": "6.2.4",
|
"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