Updated to version 5.1
Added second new visual speed type display Renamed Config.Config to Config.config (Private variable) Renamed Config.config to Config.ConfigFile (Local variable) Added red triangle to the discouraged visual speed type display Cleaned up some code Added credits to org.json to readme.md
This commit is contained in:
@@ -15,10 +15,8 @@ import net.minecraft.world.entity.vehicle.Boat;
|
|||||||
import net.minecraft.world.entity.vehicle.Minecart;
|
import net.minecraft.world.entity.vehicle.Minecart;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@@ -133,6 +131,11 @@ public class Client {
|
|||||||
}/100;
|
}/100;
|
||||||
double i = (v *(316-45))+45;
|
double i = (v *(316-45))+45;
|
||||||
|
|
||||||
|
int yPos = getPos(graphics, Config.getYPosition(), 1);
|
||||||
|
int xPos = getPos(graphics, Config.getXPosition(), 0);
|
||||||
|
|
||||||
|
int lineHeight = Minecraft.getInstance().font.lineHeight;
|
||||||
|
|
||||||
if(Config.getVisualSpeedometer() && !speedometerVisualDisplayFailed){
|
if(Config.getVisualSpeedometer() && !speedometerVisualDisplayFailed){
|
||||||
|
|
||||||
//double v = speedTypeSpeed / speedType.gatMaxVisual();
|
//double v = speedTypeSpeed / speedType.gatMaxVisual();
|
||||||
@@ -147,6 +150,11 @@ public class Client {
|
|||||||
if(Config.getShowVisualSpeedType()) {
|
if(Config.getShowVisualSpeedType()) {
|
||||||
g2d.drawString(SpeedTypes.getName(speedType).getString(), img.getWidth() / 2 - 27, img.getHeight() / 2 + 25);
|
g2d.drawString(SpeedTypes.getName(speedType).getString(), img.getWidth() / 2 - 27, img.getHeight() / 2 + 25);
|
||||||
}
|
}
|
||||||
|
if(Config.getShowSpeedType()){
|
||||||
|
String speedString = SpeedTypes.getName(speedType).getString();
|
||||||
|
int width = Minecraft.getInstance().font.width(speedString);
|
||||||
|
drawString(graphics, xPos - width, yPos - Config.getImageSize() - lineHeight - 1, speedString, Config.getColor().getColor());
|
||||||
|
}
|
||||||
|
|
||||||
BufferedImage img = ImageHandler.scale(Client.img, Config.getImageSize(), Config.getImageSize());
|
BufferedImage img = ImageHandler.scale(Client.img, Config.getImageSize(), Config.getImageSize());
|
||||||
|
|
||||||
@@ -163,9 +171,6 @@ 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.getXPosition(), 0);
|
|
||||||
int yPos = getPos(graphics, Config.getYPosition(), 1);
|
|
||||||
|
|
||||||
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++){
|
||||||
int x2 = x1 + xPos - img.getWidth();
|
int x2 = x1 + xPos - img.getWidth();
|
||||||
@@ -196,12 +201,11 @@ public class Client {
|
|||||||
// 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 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.getXPosition(), 0) - width,
|
xPos - width,
|
||||||
getPos(graphics, Config.getYPosition(), 1) - lineHeight,
|
yPos - lineHeight,
|
||||||
Config.getColor().getColor()
|
Config.getColor().getColor()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,47 +10,47 @@ import me.shedaniel.math.Color;
|
|||||||
import static me.zacharias.speedometer.Speedometer.MOD_ID;
|
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 = 3f;
|
public static final float configVersion = 3f;
|
||||||
private static int counter = 0;
|
private static int counter = 0;
|
||||||
|
|
||||||
public static void initialize(){
|
public static void initialize(){
|
||||||
if(Config != null) throw new RuntimeException("Already Initialized");
|
if(config != null) throw new RuntimeException("Already Initialized");
|
||||||
File config = new File(Platform.getConfigFolder().toString()+"/"+MOD_ID+"/config.json");
|
File configFile = new File(Platform.getConfigFolder().toString()+"/"+MOD_ID+"/config.json");
|
||||||
if(!config.exists()){
|
if(!configFile.exists()){
|
||||||
try {
|
try {
|
||||||
config.getParentFile().mkdir();
|
configFile.getParentFile().mkdir();
|
||||||
config.createNewFile();
|
configFile.createNewFile();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
Config = new JSONObject();
|
config = new JSONObject();
|
||||||
|
|
||||||
defualt();
|
defualt();
|
||||||
}else {
|
}else {
|
||||||
try {
|
try {
|
||||||
BufferedReader in = new BufferedReader(new FileReader(config));
|
BufferedReader in = new BufferedReader(new FileReader(configFile));
|
||||||
String tmp;
|
String tmp;
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
while((tmp = in.readLine()) != null){
|
while((tmp = in.readLine()) != null){
|
||||||
builder.append(tmp);
|
builder.append(tmp);
|
||||||
}
|
}
|
||||||
Config = new JSONObject(builder.toString());
|
config = new JSONObject(builder.toString());
|
||||||
if(Config.has("version")){
|
if(config.has("version")){
|
||||||
if(Config.getFloat("version")!=configVersion){
|
if(config.getFloat("version")!=configVersion){
|
||||||
if(Config.getFloat("version") > configVersion){
|
if(config.getFloat("version") > configVersion){
|
||||||
defualt();
|
defualt();
|
||||||
|
|
||||||
save();
|
save();
|
||||||
}else if(Config.getFloat("version") < configVersion){
|
}else if(config.getFloat("version") < configVersion){
|
||||||
Config = new JSONObject();
|
config = new JSONObject();
|
||||||
|
|
||||||
defualt();
|
defualt();
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
Config = new JSONObject();
|
config = new JSONObject();
|
||||||
defualt();
|
defualt();
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
@@ -61,57 +61,48 @@ public class Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void defualt() {
|
private static void defualt() {
|
||||||
if(!Config.has("speed")) {
|
if(!config.has("speed")) {
|
||||||
Config.put("speed", SpeedTypes.BlockPS);
|
config.put("speed", SpeedTypes.BlockPS);
|
||||||
}
|
}
|
||||||
if(!Config.has("useKnot")) {
|
if(!config.has("useKnot")) {
|
||||||
Config.put("useKnot", false);
|
config.put("useKnot", false);
|
||||||
}
|
}
|
||||||
if(!Config.has("color")) {
|
if(!config.has("color")) {
|
||||||
Config.put("color", new JSONObject()
|
config.put("color", new JSONObject()
|
||||||
.put("r", 16)
|
.put("r", 16)
|
||||||
.put("g", 146)
|
.put("g", 146)
|
||||||
.put("b", 158)
|
.put("b", 158)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if(!Config.has("visualSpeedometer")) {
|
if(!config.has("visualSpeedometer")) {
|
||||||
Config.put("visualSpeedometer", false);
|
config.put("visualSpeedometer", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*if(!Config.has("xPositionVisual")) {
|
if(!config.has("xPosition")) {
|
||||||
Config.put("xPositionVisual", "W-3");
|
config.put("xPosition", "W-3");
|
||||||
}
|
}
|
||||||
if(!Config.has("yPositionVisual")) {
|
if(!config.has("yPosition")) {
|
||||||
Config.put("yPositionVisual", "H-3");
|
config.put("yPosition", "H-3");
|
||||||
}
|
|
||||||
if(!Config.has("xPositionText")) {
|
|
||||||
Config.put("xPositionText", "W-3");
|
|
||||||
}
|
|
||||||
if(!Config.has("yPositionText")) {
|
|
||||||
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")) {
|
||||||
Config.put("debug", false);
|
config.put("debug", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!Config.has("imagSize")) {
|
if(!config.has("imagSize")) {
|
||||||
Config.put("imageSize", 19);
|
config.put("imageSize", 19);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!Config.has("version")) {
|
if(!config.has("version")) {
|
||||||
Config.put("version", configVersion);
|
config.put("version", configVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!Config.has("showVisualSpeedType")){
|
if(!config.has("showVisualSpeedType")){
|
||||||
Config.put("showVisualSpeedType", false);
|
config.put("showVisualSpeedType", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!config.has("showSpeedType")){
|
||||||
|
config.put("showSpeedType", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,7 +118,7 @@ public class Config {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
BufferedWriter out = new BufferedWriter(new FileWriter(config));
|
BufferedWriter out = new BufferedWriter(new FileWriter(config));
|
||||||
out.write(Config.toString(4));
|
out.write(Config.config.toString(4));
|
||||||
out.flush();
|
out.flush();
|
||||||
out.close();
|
out.close();
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
@@ -137,24 +128,24 @@ public class Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static SpeedTypes getSpeedType(){
|
public static SpeedTypes getSpeedType(){
|
||||||
if(Config.has("speed")){
|
if(config.has("speed")){
|
||||||
return Config.getEnum(SpeedTypes.class, "speed");
|
return config.getEnum(SpeedTypes.class, "speed");
|
||||||
}else{
|
}else{
|
||||||
return SpeedTypes.BlockPS;
|
return SpeedTypes.BlockPS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean getUseKnot() {
|
public static boolean getUseKnot() {
|
||||||
if(Config.has("useKnot")){
|
if(config.has("useKnot")){
|
||||||
return Config.getBoolean("useKnot");
|
return config.getBoolean("useKnot");
|
||||||
}else{
|
}else{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Color getColor(){
|
public static Color getColor(){
|
||||||
if(Config.has("color")){
|
if(config.has("color")){
|
||||||
JSONObject color = Config.getJSONObject("color");
|
JSONObject color = config.getJSONObject("color");
|
||||||
return Color.ofRGB(
|
return Color.ofRGB(
|
||||||
color.getInt("r"),
|
color.getInt("r"),
|
||||||
color.getInt("g"),
|
color.getInt("g"),
|
||||||
@@ -166,16 +157,16 @@ public class Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isDebug() {
|
public static boolean isDebug() {
|
||||||
if(Config.has("debug")){
|
if(config.has("debug")){
|
||||||
return Config.getBoolean("debug");
|
return config.getBoolean("debug");
|
||||||
}else{
|
}else{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean getVisualSpeedometer(){
|
public static boolean getVisualSpeedometer(){
|
||||||
if(Config.has("visualSpeedometer")){
|
if(config.has("visualSpeedometer")){
|
||||||
return Config.getBoolean("visualSpeedometer");
|
return config.getBoolean("visualSpeedometer");
|
||||||
}else {
|
}else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -188,71 +179,48 @@ public class Config {
|
|||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public static String getXPositionVisual(){
|
|
||||||
if(Config.has("xPositionVisual")) {
|
|
||||||
return Config.getString("xPositionVisual");
|
|
||||||
}else{
|
|
||||||
return "W-23";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getYPositionVisual() {
|
|
||||||
if (Config.has("yPositionVisual")) {
|
|
||||||
return Config.getString("yPositionVisual");
|
|
||||||
} else {
|
|
||||||
return "H-23";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public static String getXPositionText(){
|
|
||||||
if(Config.has("xPositionText")) {
|
|
||||||
return Config.getString("xPositionText");
|
|
||||||
}else{
|
|
||||||
return "W-70";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getYPositionText(){
|
|
||||||
if(Config.has("yPositionText")) {
|
|
||||||
return Config.getString("yPositionText");
|
|
||||||
}else{
|
|
||||||
return "H-15";
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
public static String getYPosition(){
|
public static String getYPosition(){
|
||||||
if(Config.has("yPosition")) {
|
if(config.has("yPosition")) {
|
||||||
return Config.getString("yPosition");
|
return config.getString("yPosition");
|
||||||
}else{
|
}else{
|
||||||
return "H-3";
|
return "H-3";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getXPosition(){
|
public static String getXPosition(){
|
||||||
if(Config.has("xPosition")) {
|
if(config.has("xPosition")) {
|
||||||
return Config.getString("xPosition");
|
return config.getString("xPosition");
|
||||||
}else{
|
}else{
|
||||||
return "W-3";
|
return "W-3";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getImageSize(){
|
public static int getImageSize(){
|
||||||
if(Config.has("imageSize")){
|
if(config.has("imageSize")){
|
||||||
return Config.getInt("imageSize");
|
return config.getInt("imageSize");
|
||||||
}else {
|
}else {
|
||||||
return 19;
|
return 19;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean getShowVisualSpeedType() {
|
public static boolean getShowVisualSpeedType() {
|
||||||
if(Config.has("showVisualSpeedType")){
|
if(config.has("showVisualSpeedType")){
|
||||||
return Config.getBoolean("showVisualSpeedType");
|
return config.getBoolean("showVisualSpeedType");
|
||||||
}else{
|
}else{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean getShowSpeedType(){
|
||||||
|
if(config.has("getShowSpeedType")){
|
||||||
|
return config.getBoolean("showSpeedType");
|
||||||
|
}else{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void setColor(Color color){
|
public static void setColor(Color color){
|
||||||
Config.put("color", new JSONObject()
|
config.put("color", new JSONObject()
|
||||||
.put("r", color.getRed())
|
.put("r", color.getRed())
|
||||||
.put("g", color.getGreen())
|
.put("g", color.getGreen())
|
||||||
.put("b", color.getBlue())
|
.put("b", color.getBlue())
|
||||||
@@ -260,51 +228,38 @@ public class Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void setUseKnot(boolean useKnot){
|
public static void setUseKnot(boolean useKnot){
|
||||||
Config.put("useKnot", useKnot);
|
config.put("useKnot", useKnot);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setSpeedType(SpeedTypes speedType) {
|
public static void setSpeedType(SpeedTypes speedType) {
|
||||||
Config.put("speed", speedType);
|
config.put("speed", speedType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setVisualSpeedometer(boolean visualSpeedometer){
|
public static void setVisualSpeedometer(boolean visualSpeedometer){
|
||||||
Config.put("visualSpeedometer", visualSpeedometer);
|
config.put("visualSpeedometer", visualSpeedometer);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
public static void setXPositionVisual(String xPositionVisual){
|
|
||||||
Config.put("xPositionVisual", xPositionVisual);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setYPositionVisual(String yPositionVisual){
|
|
||||||
Config.put("yPositionVisual", yPositionVisual);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setXPositionText(String xPositionText){
|
|
||||||
Config.put("xPositionText", xPositionText);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setYPositionText(String yPositionText){
|
|
||||||
Config.put("yPositionText", yPositionText);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
public static void setXPosition(String xPosition){
|
public static void setXPosition(String xPosition){
|
||||||
Config.put("xPosition", xPosition);
|
config.put("xPosition", xPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setYPosition(String yPosition){
|
public static void setYPosition(String yPosition){
|
||||||
Config.put("yPosition", yPosition);
|
config.put("yPosition", yPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setDebug(boolean debug){
|
public static void setDebug(boolean debug){
|
||||||
Config.put("debug", debug);
|
config.put("debug", debug);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setImageSize(int imageSize){
|
public static void setImageSize(int imageSize){
|
||||||
Config.put("imageSize", imageSize);
|
config.put("imageSize", imageSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setShowVisualSpeedType(boolean showVisualSpeedType){
|
public static void setShowVisualSpeedType(boolean showVisualSpeedType){
|
||||||
Config.put("showVisualSpeedType", showVisualSpeedType);
|
config.put("showVisualSpeedType", showVisualSpeedType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setShowSpeedType(boolean showSpeedType){
|
||||||
|
config.put("showSpeedType", showSpeedType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package me.zacharias.speedometer;
|
|||||||
import me.shedaniel.clothconfig2.api.ConfigBuilder;
|
import me.shedaniel.clothconfig2.api.ConfigBuilder;
|
||||||
import me.shedaniel.clothconfig2.api.ConfigCategory;
|
import me.shedaniel.clothconfig2.api.ConfigCategory;
|
||||||
import me.shedaniel.clothconfig2.api.ConfigEntryBuilder;
|
import me.shedaniel.clothconfig2.api.ConfigEntryBuilder;
|
||||||
|
import net.minecraft.ChatFormatting;
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
|
||||||
@@ -46,79 +47,6 @@ public class ConfigMenu {
|
|||||||
String xRegex = "W*w*S*s*\\+*-*\\**/*[0-9]*";
|
String xRegex = "W*w*S*s*\\+*-*\\**/*[0-9]*";
|
||||||
String yRegex = "H*h*S*s*\\+*-*\\**/*[0-9]*";
|
String yRegex = "H*h*S*s*\\+*-*\\**/*[0-9]*";
|
||||||
|
|
||||||
// Text Placement
|
|
||||||
/*
|
|
||||||
category.addEntry(entryBuilder.startStringDropdownMenu(Component.translatable("speedometer.config.xPosition.text"), Config.getXPositionText())
|
|
||||||
.setSaveConsumer(Config::setXPositionText)
|
|
||||||
.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"),
|
|
||||||
Component.translatable("speedometer.config.tooltip.xPosition.line3")
|
|
||||||
)
|
|
||||||
.build()
|
|
||||||
);
|
|
||||||
|
|
||||||
category.addEntry(entryBuilder.startStringDropdownMenu(Component.translatable("speedometer.config.yPosition.text"), Config.getYPositionText())
|
|
||||||
.setSaveConsumer(Config::setYPositionText)
|
|
||||||
.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"),
|
|
||||||
Component.translatable("speedometer.config.tooltip.yPosition.line3")
|
|
||||||
)
|
|
||||||
.build()
|
|
||||||
);
|
|
||||||
|
|
||||||
// Visual location
|
|
||||||
|
|
||||||
category.addEntry(entryBuilder.startStringDropdownMenu(Component.translatable("speedometer.config.xPosition.visual"), Config.getXPositionVisual())
|
|
||||||
.setSaveConsumer(Config::setXPositionVisual)
|
|
||||||
.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"),
|
|
||||||
Component.translatable("speedometer.config.tooltip.xPosition.line3")
|
|
||||||
)
|
|
||||||
.build()
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
category.addEntry(entryBuilder.startStringDropdownMenu(Component.translatable("speedometer.config.yPosition.visual"), Config.getYPositionVisual())
|
|
||||||
.setSaveConsumer(Config::setYPositionVisual)
|
|
||||||
.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"),
|
|
||||||
Component.translatable("speedometer.config.tooltip.yPosition.line3")
|
|
||||||
)
|
|
||||||
.build()
|
|
||||||
);*/
|
|
||||||
|
|
||||||
category.addEntry(entryBuilder.startStringDropdownMenu(Component.translatable("speedometer.config.xPosition"), Config.getXPosition())
|
category.addEntry(entryBuilder.startStringDropdownMenu(Component.translatable("speedometer.config.xPosition"), Config.getXPosition())
|
||||||
.setSaveConsumer(Config::setXPosition)
|
.setSaveConsumer(Config::setXPosition)
|
||||||
.setErrorSupplier(xPosition -> {
|
.setErrorSupplier(xPosition -> {
|
||||||
@@ -160,6 +88,25 @@ public class ConfigMenu {
|
|||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Show visual speed type
|
||||||
|
|
||||||
|
category.addEntry(entryBuilder.startBooleanToggle(Component.translatable("speedometer.config.showSpeedType"), Config.getShowSpeedType())
|
||||||
|
.setSaveConsumer(Config::setShowSpeedType)
|
||||||
|
.setYesNoTextSupplier(showSpeedType -> Component.translatable("speedometer."+(showSpeedType?"show":"hide")))
|
||||||
|
.setTooltip(Component.translatable("speedometer.config.tooltip.showSpeedType.line1"))
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
|
||||||
|
category.addEntry(entryBuilder.startBooleanToggle(Component.translatable("speedometer.config.showVisualSpeedType"), Config.getShowVisualSpeedType())
|
||||||
|
.setSaveConsumer(Config::setShowVisualSpeedType)
|
||||||
|
.setYesNoTextSupplier(showVisualSpeedType -> Component.translatable("speedometer."+(showVisualSpeedType?"show":"hide")).withStyle(ChatFormatting.DARK_RED))
|
||||||
|
.setTooltip(Component.translatable("speedometer.config.tooltip.showVisualSpeedType.line1"),
|
||||||
|
Component.translatable("speedometer.config.tooltip.showVisualSpeedType.line2"))
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
category.addEntry(entryBuilder.startBooleanToggle(Component.translatable("speedometer.config.debug"),Config.isDebug())
|
category.addEntry(entryBuilder.startBooleanToggle(Component.translatable("speedometer.config.debug"),Config.isDebug())
|
||||||
.setSaveConsumer(Config::setDebug)
|
.setSaveConsumer(Config::setDebug)
|
||||||
.setYesNoTextSupplier(isDebug -> Component.translatable("speedometer.debug."+isDebug))
|
.setYesNoTextSupplier(isDebug -> Component.translatable("speedometer.debug."+isDebug))
|
||||||
@@ -167,16 +114,6 @@ public class ConfigMenu {
|
|||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
|
|
||||||
// Show visual speed type
|
|
||||||
|
|
||||||
category.addEntry(entryBuilder.startBooleanToggle(Component.translatable("speedometer.config.showVisualSpeedType"), Config.getShowVisualSpeedType())
|
|
||||||
.setSaveConsumer(Config::setShowVisualSpeedType)
|
|
||||||
.setYesNoTextSupplier(showVisualSpeedType -> Component.translatable("speedometer."+(Config.getShowVisualSpeedType()?"show":"hide")))
|
|
||||||
.setTooltip(Component.translatable("speedometer.config.tooltip.showVisualSpeedType.line1"),
|
|
||||||
Component.translatable("speedometer.config.tooltip.showVisualSpeedType.line2"))
|
|
||||||
.build()
|
|
||||||
);
|
|
||||||
|
|
||||||
builder.setSavingRunnable(me.zacharias.speedometer.Config::save);
|
builder.setSavingRunnable(me.zacharias.speedometer.Config::save);
|
||||||
|
|
||||||
return builder;
|
return builder;
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public class Speedometer
|
|||||||
|
|
||||||
|
|
||||||
if(Platform.getEnvironment() != Env.CLIENT) {
|
if(Platform.getEnvironment() != Env.CLIENT) {
|
||||||
LOGGER.error("You're running speedometer on somthing other then a client, this is not supported");
|
LOGGER.error("You're running speedometer on something other then a client, this is not supported");
|
||||||
try {
|
try {
|
||||||
for (File f : Objects.requireNonNull(Platform.getModsFolder().toFile().listFiles())) {
|
for (File f : Objects.requireNonNull(Platform.getModsFolder().toFile().listFiles())) {
|
||||||
if (f.getName().startsWith("speedometer")) {
|
if (f.getName().startsWith("speedometer")) {
|
||||||
|
|||||||
@@ -13,7 +13,8 @@
|
|||||||
"speedometer.config.yPosition": "Y 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",
|
||||||
"speedometer.config.showVisualSpeedType": "Show Visual Speed Type",
|
"speedometer.config.showVisualSpeedType": "\u00A74⨻\u00A7rShow Visual Speed Type",
|
||||||
|
"speedometer.config.showSpeedType": "Show Visual Speed Type",
|
||||||
|
|
||||||
"speedometer.key.configKey": "Config Key",
|
"speedometer.key.configKey": "Config Key",
|
||||||
"speedometer.key.debugKey": "Debug Key",
|
"speedometer.key.debugKey": "Debug Key",
|
||||||
@@ -57,5 +58,7 @@
|
|||||||
"speedometer.config.tooltip.showVisualSpeedType.line1": "This setting doesn't work fully.",
|
"speedometer.config.tooltip.showVisualSpeedType.line1": "This setting doesn't work fully.",
|
||||||
"speedometer.config.tooltip.showVisualSpeedType.line2": "I(the developer) discourages the use of this setting since it doesn't work on smaller sises and the fps breaks at larger",
|
"speedometer.config.tooltip.showVisualSpeedType.line2": "I(the developer) discourages the use of this setting since it doesn't work on smaller sises and the fps breaks at larger",
|
||||||
|
|
||||||
|
"speedometer.config.tooltip.showSpeedType.line1": "This setting shows the speed type above the visual meter which is better then within the visual meter",
|
||||||
|
|
||||||
"speedometer.invalid": "Invalid String"
|
"speedometer.invalid": "Invalid String"
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,8 @@
|
|||||||
"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",
|
"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.0": "Visual speed display has been added",
|
||||||
|
"5.1": "Added second speed display"
|
||||||
},
|
},
|
||||||
"1.20": {
|
"1.20": {
|
||||||
"1.0": "First version",
|
"1.0": "First version",
|
||||||
@@ -16,13 +17,14 @@
|
|||||||
"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",
|
"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.0": "Visual speed display has been added",
|
||||||
|
"5.1": "Added second speed display"
|
||||||
},
|
},
|
||||||
"promos": {
|
"promos": {
|
||||||
"1.20.1-latest": "5.0",
|
"1.20.1-latest": "5.1",
|
||||||
"1.20.1-recommended": "5.0",
|
"1.20.1-recommended": "5.1",
|
||||||
|
|
||||||
"1.20-latest": "5.0",
|
"1.20-latest": "5.1",
|
||||||
"1.20-recommended": "5.0"
|
"1.20-recommended": "5.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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=5
|
mod_version=5.1
|
||||||
maven_group=me.zacharias
|
maven_group=me.zacharias
|
||||||
|
|
||||||
architectury_version=9.1.10
|
architectury_version=9.1.10
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
# Speedometer
|
# Speedometer
|
||||||
This is a simple mod for forge and fabric that displays your current speed
|
This is a simple mod for forge and fabric that displays your current speed
|
||||||
|
|
||||||
|
## Credits to
|
||||||
|
[org.json](https://www.json.org/json-en.html) *Included due to problems whit ForgeGradle*
|
||||||
|
|
||||||
## Compile your own version?
|
## Compile your own version?
|
||||||
1. Download source code
|
1. Download source code
|
||||||
* Run `git clone https://github.com/zaze06/Speedometer`
|
* Run `git clone https://github.com/zaze06/Speedometer`
|
||||||
|
|||||||
Reference in New Issue
Block a user