Updated to version 4
Removed the Size part from position string Combined the Visual and Text position strings (This might be reversed) Fixed bug with Text overflowing out of the screen Updated forge update checker to include version 4 TO-DO Remove old parts of the old system, pending for the next version
This commit is contained in:
@@ -115,7 +115,7 @@ public class Client {
|
|||||||
}
|
}
|
||||||
speed = speed / speeds.size();
|
speed = speed / speeds.size();
|
||||||
|
|
||||||
double speedTypeSpeed = 0D;
|
double speedTypeSpeed;
|
||||||
|
|
||||||
SpeedTypes speedType = Config.getSpeedType();
|
SpeedTypes speedType = Config.getSpeedType();
|
||||||
if (speedType == SpeedTypes.KNOT || (entity instanceof Boat && Config.getUseKnot())) {
|
if (speedType == SpeedTypes.KNOT || (entity instanceof Boat && Config.getUseKnot())) {
|
||||||
@@ -170,8 +170,8 @@ public class Client {
|
|||||||
|
|
||||||
g2d.drawLine(x3,y3,img.getWidth()/2,img.getHeight()/2);
|
g2d.drawLine(x3,y3,img.getWidth()/2,img.getHeight()/2);
|
||||||
|
|
||||||
int xPos = getPos(graphics, Config.getXPositionVisual(), 0, false, img.getWidth());
|
int xPos = getPos(graphics, Config.getXPosition(), 0, false);
|
||||||
int yPos = getPos(graphics, Config.getYPositionVisual(), 1, true, img.getHeight());
|
int yPos = getPos(graphics, Config.getYPosition(), 1, true);
|
||||||
|
|
||||||
for(int x1 = 0; x1 < img.getWidth(); x1++){
|
for(int x1 = 0; x1 < img.getWidth(); x1++){
|
||||||
for(int y1 = 0; y1 < img.getHeight(); y1++){
|
for(int y1 = 0; y1 < img.getHeight(); y1++){
|
||||||
@@ -202,11 +202,13 @@ public class Client {
|
|||||||
// j -> y
|
// j -> y
|
||||||
// k -> color RGB int
|
// k -> color RGB int
|
||||||
String speedString = format + " " + SpeedTypes.getName(speedType).getString();
|
String speedString = format + " " + SpeedTypes.getName(speedType).getString();
|
||||||
|
int width = Minecraft.getInstance().font.width(speedString);
|
||||||
|
int lineHeight = Minecraft.getInstance().font.lineHeight;
|
||||||
graphics.drawString(
|
graphics.drawString(
|
||||||
Minecraft.getInstance().font,
|
Minecraft.getInstance().font,
|
||||||
speedString,
|
speedString,
|
||||||
getPos(graphics, Config.getXPositionText(), 0, false, Minecraft.getInstance().font.width(speedString)),
|
getPos(graphics, Config.getXPosition(), 0, false) - width,
|
||||||
getPos(graphics, Config.getYPositionText(), 1, true, Minecraft.getInstance().font.lineHeight),
|
getPos(graphics, Config.getYPosition(), 1, true) - lineHeight,
|
||||||
Config.getColor().getColor()
|
Config.getColor().getColor()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -253,7 +255,7 @@ public class Client {
|
|||||||
|
|
||||||
static boolean flag = true;
|
static boolean flag = true;
|
||||||
|
|
||||||
private static int getPos(GuiGraphics event, String input, int type, boolean changeFlag, int Size) {
|
private static int getPos(GuiGraphics event, String input, int type, boolean changeFlag) {
|
||||||
ArrayList<String> passerPose = new ArrayList<>();
|
ArrayList<String> passerPose = new ArrayList<>();
|
||||||
final char[] s = input.toCharArray();
|
final char[] s = input.toCharArray();
|
||||||
try{
|
try{
|
||||||
@@ -279,8 +281,6 @@ public class Client {
|
|||||||
}catch (NumberFormatException e){
|
}catch (NumberFormatException e){
|
||||||
passerPose.add(Character.toString(s[i]));
|
passerPose.add(Character.toString(s[i]));
|
||||||
}
|
}
|
||||||
}else if(s[i] == 'S' || s[i] == 's'){
|
|
||||||
passerPose.add(String.valueOf(Size));
|
|
||||||
}else{
|
}else{
|
||||||
throw new Exception();
|
throw new Exception();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import static me.zacharias.speedometer.Speedometer.MOD_ID;
|
|||||||
|
|
||||||
public class Config {
|
public class Config {
|
||||||
private static JSONObject Config;
|
private static JSONObject Config;
|
||||||
public static final float configVersion = 2.1f;
|
public static final float configVersion = 3f;
|
||||||
|
|
||||||
public static void initialize(){
|
public static void initialize(){
|
||||||
if(Config != null) throw new RuntimeException("Already Initialized");
|
if(Config != null) throw new RuntimeException("Already Initialized");
|
||||||
@@ -76,17 +76,25 @@ public class Config {
|
|||||||
if(!Config.has("visualSpeedometer")) {
|
if(!Config.has("visualSpeedometer")) {
|
||||||
Config.put("visualSpeedometer", false);
|
Config.put("visualSpeedometer", false);
|
||||||
}
|
}
|
||||||
if(!Config.has("xPositionVisual")) {
|
|
||||||
|
/*if(!Config.has("xPositionVisual")) {
|
||||||
Config.put("xPositionVisual", "W-3");
|
Config.put("xPositionVisual", "W-3");
|
||||||
}
|
}
|
||||||
if(!Config.has("yPositionVisual")) {
|
if(!Config.has("yPositionVisual")) {
|
||||||
Config.put("yPositionVisual", "H-3");
|
Config.put("yPositionVisual", "H-3");
|
||||||
}
|
}
|
||||||
if(!Config.has("xPositionText")) {
|
if(!Config.has("xPositionText")) {
|
||||||
Config.put("xPositionText", "W-70");
|
Config.put("xPositionText", "W-3");
|
||||||
}
|
}
|
||||||
if(!Config.has("yPositionText")) {
|
if(!Config.has("yPositionText")) {
|
||||||
Config.put("yPositionText", "H-15");
|
Config.put("yPositionText", "H-3");
|
||||||
|
}*/
|
||||||
|
|
||||||
|
if(!Config.has("xPosition")) {
|
||||||
|
Config.put("xPosition", "W-3");
|
||||||
|
}
|
||||||
|
if(!Config.has("yPosition")) {
|
||||||
|
Config.put("yPosition", "H-3");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!Config.has("debug")) {
|
if(!Config.has("debug")) {
|
||||||
@@ -167,7 +175,7 @@ public class Config {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getXPositionVisual(){
|
/*public static String getXPositionVisual(){
|
||||||
if(Config.has("xPositionVisual")) {
|
if(Config.has("xPositionVisual")) {
|
||||||
return Config.getString("xPositionVisual");
|
return Config.getString("xPositionVisual");
|
||||||
}else{
|
}else{
|
||||||
@@ -196,6 +204,22 @@ public class Config {
|
|||||||
}else{
|
}else{
|
||||||
return "H-15";
|
return "H-15";
|
||||||
}
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
public static String getYPosition(){
|
||||||
|
if(Config.has("yPosition")) {
|
||||||
|
return Config.getString("yPosition");
|
||||||
|
}else{
|
||||||
|
return "H-15";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getXPosition(){
|
||||||
|
if(Config.has("xPosition")) {
|
||||||
|
return Config.getString("xPosition");
|
||||||
|
}else{
|
||||||
|
return "W-70";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getImageSize(){
|
public static int getImageSize(){
|
||||||
@@ -226,6 +250,7 @@ public class Config {
|
|||||||
Config.put("visualSpeedometer", visualSpeedometer);
|
Config.put("visualSpeedometer", visualSpeedometer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
public static void setXPositionVisual(String xPositionVisual){
|
public static void setXPositionVisual(String xPositionVisual){
|
||||||
Config.put("xPositionVisual", xPositionVisual);
|
Config.put("xPositionVisual", xPositionVisual);
|
||||||
}
|
}
|
||||||
@@ -240,6 +265,14 @@ public class Config {
|
|||||||
|
|
||||||
public static void setYPositionText(String yPositionText){
|
public static void setYPositionText(String yPositionText){
|
||||||
Config.put("yPositionText", yPositionText);
|
Config.put("yPositionText", yPositionText);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
public static void setXPosition(String xPosition){
|
||||||
|
Config.put("xPosition", xPosition);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setYPosition(String yPosition){
|
||||||
|
Config.put("yPosition", yPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setDebug(boolean debug){
|
public static void setDebug(boolean debug){
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class ConfigMenu {
|
|||||||
String yRegex = "H*h*S*s*\\+*-*\\**/*[0-9]*";
|
String yRegex = "H*h*S*s*\\+*-*\\**/*[0-9]*";
|
||||||
|
|
||||||
// Text Placement
|
// Text Placement
|
||||||
|
/*
|
||||||
category.addEntry(entryBuilder.startStringDropdownMenu(Component.translatable("speedometer.config.xPosition.text"), Config.getXPositionText())
|
category.addEntry(entryBuilder.startStringDropdownMenu(Component.translatable("speedometer.config.xPosition.text"), Config.getXPositionText())
|
||||||
.setSaveConsumer(Config::setXPositionText)
|
.setSaveConsumer(Config::setXPositionText)
|
||||||
.setErrorSupplier(xPosition -> {
|
.setErrorSupplier(xPosition -> {
|
||||||
@@ -101,6 +101,7 @@ public class ConfigMenu {
|
|||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
category.addEntry(entryBuilder.startStringDropdownMenu(Component.translatable("speedometer.config.yPosition.visual"), Config.getYPositionVisual())
|
category.addEntry(entryBuilder.startStringDropdownMenu(Component.translatable("speedometer.config.yPosition.visual"), Config.getYPositionVisual())
|
||||||
.setSaveConsumer(Config::setYPositionVisual)
|
.setSaveConsumer(Config::setYPositionVisual)
|
||||||
.setErrorSupplier(yPosition -> {
|
.setErrorSupplier(yPosition -> {
|
||||||
@@ -116,6 +117,39 @@ public class ConfigMenu {
|
|||||||
Component.translatable("speedometer.config.tooltip.yPosition.line3")
|
Component.translatable("speedometer.config.tooltip.yPosition.line3")
|
||||||
)
|
)
|
||||||
.build()
|
.build()
|
||||||
|
);*/
|
||||||
|
|
||||||
|
category.addEntry(entryBuilder.startStringDropdownMenu(Component.translatable("speedometer.config.xPosition"), Config.getXPosition())
|
||||||
|
.setSaveConsumer(Config::setXPosition)
|
||||||
|
.setErrorSupplier(xPosition -> {
|
||||||
|
if(xPosition.matches(xRegex)){
|
||||||
|
return Optional.empty();
|
||||||
|
}else{
|
||||||
|
return Optional.of(Component.translatable("speedometer.invalid"));
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setTooltip(
|
||||||
|
Component.translatable("speedometer.config.tooltip.xPosition.line1"),
|
||||||
|
Component.translatable("speedometer.config.tooltip.xPosition.line2")
|
||||||
|
)
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
category.addEntry(entryBuilder.startStringDropdownMenu(Component.translatable("speedometer.config.yPosition"), Config.getYPosition())
|
||||||
|
.setSaveConsumer(Config::setYPosition)
|
||||||
|
.setErrorSupplier(yPosition -> {
|
||||||
|
if(yPosition.matches(yRegex)){
|
||||||
|
return Optional.empty();
|
||||||
|
}else{
|
||||||
|
return Optional.of(Component.translatable("speedometer.invalid"));
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setTooltip(
|
||||||
|
Component.translatable("speedometer.config.tooltip.yPosition.line1"),
|
||||||
|
Component.translatable("speedometer.config.tooltip.yPosition.line2")
|
||||||
|
)
|
||||||
|
.build()
|
||||||
);
|
);
|
||||||
|
|
||||||
// Size of visual image
|
// Size of visual image
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
"speedometer.config.yPosition.visual": "Y Position for Visual Meter",
|
"speedometer.config.yPosition.visual": "Y Position for Visual Meter",
|
||||||
"speedometer.config.xPosition.text": "X Position for Text Meter",
|
"speedometer.config.xPosition.text": "X Position for Text Meter",
|
||||||
"speedometer.config.yPosition.text": "Y Position for Text Meter",
|
"speedometer.config.yPosition.text": "Y Position for Text Meter",
|
||||||
|
"speedometer.config.xPosition": "X Position for Meters",
|
||||||
|
"speedometer.config.yPosition": "Y Position for Meters",
|
||||||
"speedometer.config.debug": "Debug",
|
"speedometer.config.debug": "Debug",
|
||||||
"speedometer.config.imageSize": "Image Size",
|
"speedometer.config.imageSize": "Image Size",
|
||||||
|
|
||||||
|
|||||||
@@ -5,20 +5,22 @@
|
|||||||
"2.0": "Made the speedometer text movable, added debug data display, added visual speedometer",
|
"2.0": "Made the speedometer text movable, added debug data display, added visual speedometer",
|
||||||
"3.0": "Added size setting for visual speedometer, changed how the visual speedometer location is set",
|
"3.0": "Added size setting for visual speedometer, changed how the visual speedometer location is set",
|
||||||
"3.1": "Fixed error in language file",
|
"3.1": "Fixed error in language file",
|
||||||
"3.2": "Correct checker for Client or Server environment, updated dependencies, added dependency check in mod data file, added a renamer to rename the mod file if it's on a server"
|
"3.2": "Correct checker for Client or Server environment, updated dependencies, added dependency check in mod data file, added a renamer to rename the mod file if it's on a server",
|
||||||
|
"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"
|
||||||
},
|
},
|
||||||
"1.20": {
|
"1.20": {
|
||||||
"1.0": "First version",
|
"1.0": "First version",
|
||||||
"2.0": "Made the speedometer text movable, added debug data display, added visual speedometer",
|
"2.0": "Made the speedometer text movable, added debug data display, added visual speedometer",
|
||||||
"3.0": "Added size setting for visual speedometer, changed how the visual speedometer location is set",
|
"3.0": "Added size setting for visual speedometer, changed how the visual speedometer location is set",
|
||||||
"3.1": "Fixed error in language file",
|
"3.1": "Fixed error in language file",
|
||||||
"3.2": "Correct checker for Client or Server environment, updated dependencies, added dependency check in mod data file, added a renamer to rename the mod file if it's on a server"
|
"3.2": "Correct checker for Client or Server environment, updated dependencies, added dependency check in mod data file, added a renamer to rename the mod file if it's on a server",
|
||||||
|
"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"
|
||||||
},
|
},
|
||||||
"promos": {
|
"promos": {
|
||||||
"1.20.1-latest": "3.2",
|
"1.20.1-latest": "4.0",
|
||||||
"1.20.1-recommended": "3.2",
|
"1.20.1-recommended": "4.0",
|
||||||
|
|
||||||
"1.20-latest": "3.2",
|
"1.20-latest": "4.0",
|
||||||
"1.20-recommended": "3.2"
|
"1.20-recommended": "4.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,7 @@ org.gradle.jvmargs=-Xmx8G
|
|||||||
minecraft_version=1.20.1
|
minecraft_version=1.20.1
|
||||||
|
|
||||||
archives_base_name=speedometer
|
archives_base_name=speedometer
|
||||||
mod_version=3.2
|
mod_version=4
|
||||||
maven_group=me.zacharias
|
maven_group=me.zacharias
|
||||||
|
|
||||||
architectury_version=9.1.10
|
architectury_version=9.1.10
|
||||||
|
|||||||
Reference in New Issue
Block a user