Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c644671eaf | |||
| b09ffb4639 | |||
| 481993b2e2 | |||
|
|
965a3ea62d | ||
|
|
a36058459f | ||
|
|
962c2f5f2b | ||
| cda526d41d |
8
.gitignore
vendored
8
.gitignore
vendored
@@ -114,5 +114,13 @@ gradle-app.setting
|
|||||||
# Common working directory
|
# Common working directory
|
||||||
run/
|
run/
|
||||||
|
|
||||||
|
neoforge/run/
|
||||||
|
fabric/run/
|
||||||
|
|
||||||
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
|
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
|
||||||
!gradle-wrapper.jar
|
!gradle-wrapper.jar
|
||||||
|
|
||||||
|
# Gradle files
|
||||||
|
gradlew
|
||||||
|
gradlew.bat
|
||||||
|
gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id "architectury-plugin" version "3.4-SNAPSHOT"
|
id "architectury-plugin" version "3.4-SNAPSHOT"
|
||||||
id "dev.architectury.loom" version "1.1-SNAPSHOT" apply false
|
id "dev.architectury.loom" version "1.6-SNAPSHOT" apply false
|
||||||
}
|
}
|
||||||
|
|
||||||
architectury {
|
architectury {
|
||||||
@@ -32,17 +32,22 @@ allprojects {
|
|||||||
version = rootProject.mod_version
|
version = rootProject.mod_version
|
||||||
group = rootProject.maven_group
|
group = rootProject.maven_group
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation ("net.kyori:adventure-text-minimessage:4.17.0")
|
||||||
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
// Add repositories to retrieve artifacts from in here.
|
// Add repositories to retrieve artifacts from in here.
|
||||||
// You should only use this when depending on other mods because
|
// You should only use this when depending on other mods because
|
||||||
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
|
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
|
||||||
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
|
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
|
||||||
// for more information about repositories.
|
// for more information about repositories.
|
||||||
|
mavenCentral();
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType(JavaCompile) {
|
tasks.withType(JavaCompile) {
|
||||||
options.encoding = "UTF-8"
|
options.encoding = "UTF-8"
|
||||||
options.release = 17
|
options.release = 21
|
||||||
}
|
}
|
||||||
|
|
||||||
java {
|
java {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ dependencies {
|
|||||||
}
|
}
|
||||||
|
|
||||||
architectury {
|
architectury {
|
||||||
common()
|
common("fabric", "neoforge")
|
||||||
}
|
}
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
|
|||||||
@@ -5,20 +5,22 @@ import dev.architectury.event.events.client.ClientGuiEvent;
|
|||||||
import dev.architectury.event.events.client.ClientTickEvent;
|
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.client.DeltaTracker;
|
||||||
import net.minecraft.client.KeyMapping;
|
import net.minecraft.client.KeyMapping;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
|
import net.minecraft.network.chat.ClickEvent;
|
||||||
import net.minecraft.world.entity.Entity;
|
import net.minecraft.world.entity.Entity;
|
||||||
import net.minecraft.world.entity.animal.Pig;
|
import net.minecraft.world.entity.animal.Pig;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.entity.vehicle.Boat;
|
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 net.minecraft.network.chat.Component;
|
||||||
|
|
||||||
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;
|
||||||
@@ -40,25 +42,46 @@ public class Client {
|
|||||||
"speedometer.key.category"
|
"speedometer.key.category"
|
||||||
);
|
);
|
||||||
|
|
||||||
public static final KeyMapping SPEED_KEY = new KeyMapping(
|
|
||||||
"speedometer.key.speedKey",
|
|
||||||
InputConstants.Type.KEYSYM,
|
|
||||||
InputConstants.KEY_UP,
|
|
||||||
"speedometer.key.category"
|
|
||||||
);
|
|
||||||
|
|
||||||
private static final ArrayList<Double> speeds = new ArrayList<>();
|
private static final ArrayList<Double> speeds = new ArrayList<>();
|
||||||
private static boolean speedometerVisualDisplayFailed = false;
|
private static boolean speedometerVisualDisplayFailed = false;
|
||||||
public static BufferedImage img = null;
|
public static BufferedImage img = null;
|
||||||
|
|
||||||
public static void init(){
|
public static void init(){
|
||||||
|
|
||||||
Platform.getMod(MOD_ID).registerConfigurationScreen(parent -> ConfigMenu.getConfig(parent).build());
|
final boolean isClothLoaded = false;//Platform.isModLoaded("cloth_config") || Platform.isModLoaded("cloth-config");
|
||||||
|
|
||||||
|
if(isClothLoaded) {
|
||||||
|
Platform.getMod(MOD_ID).registerConfigurationScreen(parent -> ConfigMenu.getConfig(parent).build());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOGGER.warn("Missing Cloth Config API, In game config menu will not be available");
|
||||||
|
}
|
||||||
|
|
||||||
KeyMappingRegistry.register(CONFIG_KEY);
|
KeyMappingRegistry.register(CONFIG_KEY);
|
||||||
ClientTickEvent.CLIENT_POST.register(minecraft -> {
|
ClientTickEvent.CLIENT_POST.register(minecraft -> {
|
||||||
if(CONFIG_KEY.consumeClick()){
|
if(CONFIG_KEY.consumeClick()){
|
||||||
Minecraft.getInstance().setScreen(ConfigMenu.getConfig(Minecraft.getInstance().screen).build());
|
if(isClothLoaded) {
|
||||||
|
Minecraft.getInstance().setScreen(ConfigMenu.getConfig(Minecraft.getInstance().screen).build());
|
||||||
|
}
|
||||||
|
else if(Minecraft.getInstance().player != null)
|
||||||
|
{
|
||||||
|
Minecraft.getInstance().player.sendSystemMessage(
|
||||||
|
Component
|
||||||
|
.translatable("speedometer.error.missing_cloth")
|
||||||
|
.withColor(new Color(190, 0, 0).getRGB())
|
||||||
|
.append(" ")
|
||||||
|
.append(Component
|
||||||
|
.literal("Open Config")
|
||||||
|
.withStyle(ChatFormatting.UNDERLINE)
|
||||||
|
.withStyle((style) -> style.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, Config.getConfigPath())))
|
||||||
|
));
|
||||||
|
LOGGER.warn(Component.translatable("speedometer.error.missing_cloth").getString());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOGGER.warn(Component.translatable("speedometer.error.missing_cloth").getString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -69,15 +92,6 @@ public class Client {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//KeyMappingRegistry.register(SPEED_KEY);
|
|
||||||
ClientTickEvent.CLIENT_POST.register(minecraft -> {
|
|
||||||
if(SPEED_KEY.consumeClick()){
|
|
||||||
if(minecraft.player != null) {
|
|
||||||
minecraft.player.addDeltaMovement(new Vec3(1, 0, 0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Config.initialize();
|
Config.initialize();
|
||||||
Config.save();
|
Config.save();
|
||||||
|
|
||||||
@@ -91,7 +105,7 @@ public class Client {
|
|||||||
LOGGER.info("Finished loading speedometer");
|
LOGGER.info("Finished loading speedometer");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void render(GuiGraphics graphics, float tick) {
|
private static void render(GuiGraphics graphics, DeltaTracker deltaTracker) {
|
||||||
if(Minecraft.getInstance().player == null) return;
|
if(Minecraft.getInstance().player == null) return;
|
||||||
Entity entity = Minecraft.getInstance().player.getRootVehicle();
|
Entity entity = Minecraft.getInstance().player.getRootVehicle();
|
||||||
|
|
||||||
@@ -147,7 +161,21 @@ public class Client {
|
|||||||
case MPH -> speedTypeSpeed;
|
case MPH -> speedTypeSpeed;
|
||||||
case KNOT -> Math.pow(speedTypeSpeed,1.05);
|
case KNOT -> Math.pow(speedTypeSpeed,1.05);
|
||||||
}/100;
|
}/100;
|
||||||
|
|
||||||
double i = (v *(316-45))+45;
|
double i = (v *(316-45))+45;
|
||||||
|
|
||||||
|
String speedString = format + " " + SpeedTypes.getName(speedType).getString();
|
||||||
|
|
||||||
|
int width = switch ((Config.getVisualSpeedometer() && !speedometerVisualDisplayFailed) ? 1 : 0){
|
||||||
|
case 1 -> Config.getImageSize();
|
||||||
|
case 0 -> Minecraft.getInstance().font.width(speedString);
|
||||||
|
default -> 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
int yPos = getPos(graphics, width, Config.getYPosition(), 1);
|
||||||
|
int xPos = getPos(graphics, width, Config.getXPosition(), 0);
|
||||||
|
|
||||||
|
int lineHeight = Minecraft.getInstance().font.lineHeight;
|
||||||
|
|
||||||
if(Config.getVisualSpeedometer() && !speedometerVisualDisplayFailed){
|
if(Config.getVisualSpeedometer() && !speedometerVisualDisplayFailed){
|
||||||
|
|
||||||
@@ -159,7 +187,11 @@ public class Client {
|
|||||||
|
|
||||||
g2d.setColor(new Color(138, 0, 0));
|
g2d.setColor(new Color(138, 0, 0));
|
||||||
g2d.setFont(new Font(g2d.getFont().getName(), Font.PLAIN, 15));
|
g2d.setFont(new Font(g2d.getFont().getName(), Font.PLAIN, 15));
|
||||||
g2d.drawString(SpeedTypes.getName(speedType).getString(), img.getWidth()/2-27,img.getHeight()/2+25);
|
|
||||||
|
if(Config.getShowSpeedType()){
|
||||||
|
speedString = SpeedTypes.getName(speedType).getString();
|
||||||
|
drawString(graphics, xPos - width, yPos - Config.getImageSize() - lineHeight - 1, speedString, Config.getColor().getRGB());
|
||||||
|
}
|
||||||
|
|
||||||
BufferedImage img = ImageHandler.scale(Client.img, Config.getImageSize(), Config.getImageSize());
|
BufferedImage img = ImageHandler.scale(Client.img, Config.getImageSize(), Config.getImageSize());
|
||||||
|
|
||||||
@@ -176,9 +208,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();
|
||||||
@@ -207,15 +236,12 @@ public class Client {
|
|||||||
// i -> x
|
// i -> x
|
||||||
// j -> y
|
// j -> y
|
||||||
// k -> color RGB int
|
// k -> color RGB int
|
||||||
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.getXPosition(), 0) - width,
|
xPos - width,
|
||||||
getPos(graphics, Config.getYPosition(), 1) - lineHeight,
|
yPos - lineHeight,
|
||||||
Config.getColor().getColor()
|
Config.getColor().getRGB()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,7 +263,7 @@ public class Client {
|
|||||||
"Velocity total average: " + speed + "\n" +
|
"Velocity total average: " + speed + "\n" +
|
||||||
"Velocity total in " + speedType.name() + ": " + speedTypeSpeed + "\n" +
|
"Velocity total in " + speedType.name() + ": " + speedTypeSpeed + "\n" +
|
||||||
"Percentage point of visual speedometer: " + v + "\n" +
|
"Percentage point of visual speedometer: " + v + "\n" +
|
||||||
"Degree end point: " + (i+45) +"\n" +
|
"Degree end point: " + i +"\n" +
|
||||||
(Config.getVisualSpeedometer()?"Visual Size: ":"Textual display") + Config.getImageSize();
|
(Config.getVisualSpeedometer()?"Visual Size: ":"Textual display") + Config.getImageSize();
|
||||||
|
|
||||||
Color color = new Color(255, 255, 255);
|
Color color = new Color(255, 255, 255);
|
||||||
@@ -260,7 +286,7 @@ public class Client {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getPos(GuiGraphics event, String input, int type) {
|
private static int getPos(GuiGraphics event, int width, String input, int type) {
|
||||||
ArrayList<String> passerPose = new ArrayList<>();
|
ArrayList<String> passerPose = new ArrayList<>();
|
||||||
final char[] s = input.toCharArray();
|
final char[] s = input.toCharArray();
|
||||||
try{
|
try{
|
||||||
@@ -271,6 +297,9 @@ public class Client {
|
|||||||
}else if(s[i] == 'h' || s[i] == 'w'){
|
}else if(s[i] == 'h' || s[i] == 'w'){
|
||||||
if(type == 0) passerPose.add(String.valueOf(event.guiWidth() / 2));
|
if(type == 0) passerPose.add(String.valueOf(event.guiWidth() / 2));
|
||||||
else if(type == 1) passerPose.add(String.valueOf(event.guiHeight() / 2));
|
else if(type == 1) passerPose.add(String.valueOf(event.guiHeight() / 2));
|
||||||
|
}else if(s[i] == 'S' || s[i] == 's'){
|
||||||
|
if(type == 0) passerPose.add(String.valueOf(width));
|
||||||
|
else if(type == 1) passerPose.add(String.valueOf(width));
|
||||||
}else if(s[i] == '+'){
|
}else if(s[i] == '+'){
|
||||||
passerPose.add("+");
|
passerPose.add("+");
|
||||||
}else if(s[i] == '-'){
|
}else if(s[i] == '-'){
|
||||||
@@ -281,8 +310,14 @@ public class Client {
|
|||||||
passerPose.add("/");
|
passerPose.add("/");
|
||||||
}else if(Character.isDigit(s[i])){
|
}else if(Character.isDigit(s[i])){
|
||||||
try{
|
try{
|
||||||
Integer.parseInt(passerPose.get(i-1));
|
if(i-1 > 0) {
|
||||||
passerPose.add(i-1,passerPose.get(i-1)+s[i]);
|
Integer.parseInt(passerPose.get(i - 1));
|
||||||
|
passerPose.add(i - 1, passerPose.get(i - 1) + s[i]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
passerPose.add(Character.toString(s[i]));
|
||||||
|
}
|
||||||
}catch (NumberFormatException e){
|
}catch (NumberFormatException e){
|
||||||
passerPose.add(Character.toString(s[i]));
|
passerPose.add(Character.toString(s[i]));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,54 +3,56 @@ package me.zacharias.speedometer;
|
|||||||
import dev.architectury.platform.Platform;
|
import dev.architectury.platform.Platform;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
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;
|
||||||
|
private static String configPath;
|
||||||
|
|
||||||
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");
|
configPath = Platform.getConfigFolder().toString()+"/"+MOD_ID+"/config.json";
|
||||||
if(!config.exists()){
|
File configFile = new File(configPath);
|
||||||
|
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,58 +63,53 @@ 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")){
|
||||||
|
config.put("showVisualSpeedType", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!config.has("showSpeedType")){
|
||||||
|
config.put("showSpeedType", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void save(){
|
public static void save(){
|
||||||
File config = new File(Platform.getConfigFolder().toString()+"/"+MOD_ID+"/config.json");
|
File config = new File(configPath);
|
||||||
if(!config.exists()){
|
if(!config.exists()){
|
||||||
try {
|
try {
|
||||||
config.getParentFile().mkdir();
|
config.getParentFile().mkdir();
|
||||||
@@ -123,7 +120,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){
|
||||||
@@ -133,45 +130,45 @@ 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 new Color(
|
||||||
color.getInt("r"),
|
color.getInt("r"),
|
||||||
color.getInt("g"),
|
color.getInt("g"),
|
||||||
color.getInt("b")
|
color.getInt("b")
|
||||||
);
|
);
|
||||||
}else{
|
}else{
|
||||||
return Color.ofRGB(16, 146, 158);
|
return new Color(16, 146, 158);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
@@ -184,111 +181,80 @@ 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 void setColor(Color color){
|
public static boolean getShowSpeedType(){
|
||||||
Config.put("color", new JSONObject()
|
if(config.has("getShowSpeedType")){
|
||||||
.put("r", color.getRed())
|
return config.getBoolean("showSpeedType");
|
||||||
.put("g", color.getGreen())
|
}else{
|
||||||
.put("b", color.getBlue())
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setColor(int r, int g, int b){
|
||||||
|
config.put("color", new JSONObject()
|
||||||
|
.put("r", r)
|
||||||
|
.put("g", g)
|
||||||
|
.put("b", b)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
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 setShowSpeedType(boolean showSpeedType){
|
||||||
|
config.put("showSpeedType", showSpeedType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getConfigPath()
|
||||||
|
{
|
||||||
|
return configPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
@@ -24,8 +25,10 @@ public class ConfigMenu {
|
|||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
|
|
||||||
category.addEntry(entryBuilder.startColorField(Component.translatable("speedometer.config.color"), me.zacharias.speedometer.Config.getColor())
|
category.addEntry(entryBuilder.startColorField(Component.translatable("speedometer.config.color"), me.zacharias.speedometer.Config.getColor().getRGB())
|
||||||
.setSaveConsumer2(me.zacharias.speedometer.Config::setColor)
|
.setSaveConsumer2(color -> {
|
||||||
|
me.zacharias.speedometer.Config.setColor(color.getRed(), color.getGreen(), color.getBlue());
|
||||||
|
})
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -46,79 +49,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 -> {
|
||||||
@@ -130,7 +60,8 @@ public class ConfigMenu {
|
|||||||
})
|
})
|
||||||
.setTooltip(
|
.setTooltip(
|
||||||
Component.translatable("speedometer.config.tooltip.xPosition.line1"),
|
Component.translatable("speedometer.config.tooltip.xPosition.line1"),
|
||||||
Component.translatable("speedometer.config.tooltip.xPosition.line2")
|
Component.translatable("speedometer.config.tooltip.xPosition.line2"),
|
||||||
|
Component.translatable("speedometer.config.tooltip.xPosition.line3")
|
||||||
)
|
)
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
@@ -147,7 +78,8 @@ public class ConfigMenu {
|
|||||||
})
|
})
|
||||||
.setTooltip(
|
.setTooltip(
|
||||||
Component.translatable("speedometer.config.tooltip.yPosition.line1"),
|
Component.translatable("speedometer.config.tooltip.yPosition.line1"),
|
||||||
Component.translatable("speedometer.config.tooltip.yPosition.line2")
|
Component.translatable("speedometer.config.tooltip.yPosition.line2"),
|
||||||
|
Component.translatable("speedometer.config.tooltip.yPosition.line3")
|
||||||
)
|
)
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
@@ -160,6 +92,17 @@ 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.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))
|
||||||
|
|||||||
@@ -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,6 +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": "\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",
|
||||||
@@ -38,6 +40,9 @@
|
|||||||
"speedometer.debug.true": "\u00A74Yes",
|
"speedometer.debug.true": "\u00A74Yes",
|
||||||
"speedometer.debug.false": "\u00A74No",
|
"speedometer.debug.false": "\u00A74No",
|
||||||
|
|
||||||
|
"speedometer.show": "Show",
|
||||||
|
"speedometer.hide": "Hide",
|
||||||
|
|
||||||
"speedometer.config.tooltip.xPosition.line1": "W = the width of the screen",
|
"speedometer.config.tooltip.xPosition.line1": "W = the width of the screen",
|
||||||
"speedometer.config.tooltip.xPosition.line2": "w = half the width of the screen",
|
"speedometer.config.tooltip.xPosition.line2": "w = half the width of the screen",
|
||||||
"speedometer.config.tooltip.xPosition.line3": "s = the width of the text or image",
|
"speedometer.config.tooltip.xPosition.line3": "s = the width of the text or image",
|
||||||
@@ -50,5 +55,12 @@
|
|||||||
|
|
||||||
"speedometer.config.tooltip.imageSize": "Size of the image. This sets both the height and width",
|
"speedometer.config.tooltip.imageSize": "Size of the image. This sets both the height and width",
|
||||||
|
|
||||||
"speedometer.invalid": "Invalid String"
|
"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.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.error.missing_cloth": "Missing Cloth Config API for Config Screen"
|
||||||
}
|
}
|
||||||
@@ -18,6 +18,7 @@ configurations {
|
|||||||
repositories {
|
repositories {
|
||||||
maven { url "https://maven.shedaniel.me/" }
|
maven { url "https://maven.shedaniel.me/" }
|
||||||
maven { url "https://maven.terraformersmc.com/releases/" }
|
maven { url "https://maven.terraformersmc.com/releases/" }
|
||||||
|
maven { url "https://maven.nucleoid.xyz/" }
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -26,8 +27,9 @@ dependencies {
|
|||||||
// Remove the next line if you don't want to depend on the API
|
// Remove the next line if you don't want to depend on the API
|
||||||
modApi "dev.architectury:architectury-fabric:${rootProject.architectury_version}"
|
modApi "dev.architectury:architectury-fabric:${rootProject.architectury_version}"
|
||||||
|
|
||||||
modApi "me.shedaniel.cloth:cloth-config-fabric:11.1.106"
|
modApi "me.shedaniel.cloth:cloth-config-fabric:${rootProject.cloth_config_version}"
|
||||||
modApi "com.terraformersmc:modmenu:7.1.0"
|
modApi "com.terraformersmc:modmenu:11.0.0"
|
||||||
|
modApi "eu.pb4:placeholder-api:2.4.0-pre.2+1.21"
|
||||||
|
|
||||||
common(project(path: ":common", configuration: "namedElements")) { transitive false }
|
common(project(path: ":common", configuration: "namedElements")) { transitive false }
|
||||||
shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false }
|
shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false }
|
||||||
|
|||||||
@@ -2,6 +2,13 @@ package me.zacharias.speedometer.fabric;
|
|||||||
|
|
||||||
import me.zacharias.speedometer.Speedometer;
|
import me.zacharias.speedometer.Speedometer;
|
||||||
import net.fabricmc.api.ModInitializer;
|
import net.fabricmc.api.ModInitializer;
|
||||||
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
|
import net.minecraft.ChatFormatting;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.network.chat.ClickEvent;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
public class SpeedometerFabric implements ModInitializer {
|
public class SpeedometerFabric implements ModInitializer {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
"name": "speedometer",
|
"name": "speedometer",
|
||||||
"description": "just displaying your speed",
|
"description": "just displaying your speed",
|
||||||
"authors": ["Allen"],
|
"authors": ["Zacharias"],
|
||||||
"contact": {
|
"contact": {
|
||||||
"sources": "https://github.com/zaze06/Speedometer",
|
"sources": "https://github.com/zaze06/Speedometer",
|
||||||
"issues": "https://github.com/zaze06/Speedometer/issues"
|
"issues": "https://github.com/zaze06/Speedometer/issues"
|
||||||
@@ -19,9 +19,8 @@
|
|||||||
"main": ["me.zacharias.speedometer.fabric.SpeedometerFabric"]
|
"main": ["me.zacharias.speedometer.fabric.SpeedometerFabric"]
|
||||||
},
|
},
|
||||||
"depends": {
|
"depends": {
|
||||||
"fabricloader": ">=0.14.21",
|
"fabricloader": ">=0.15.11",
|
||||||
"minecraft": ">=1.20",
|
"minecraft": ">=1.21",
|
||||||
"cloth-config": ">=11.1.106",
|
"architectury": ">=13.0.1"
|
||||||
"architectury": ">=9.1.10"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
loom.platform=forge
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package me.zacharias.speedometer.forge;
|
|
||||||
|
|
||||||
import dev.architectury.platform.forge.EventBuses;
|
|
||||||
import me.zacharias.speedometer.Speedometer;
|
|
||||||
import net.minecraftforge.fml.common.Mod;
|
|
||||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
|
||||||
|
|
||||||
@Mod(Speedometer.MOD_ID)
|
|
||||||
public class SpeedometerForge {
|
|
||||||
public SpeedometerForge() {
|
|
||||||
// Submit our event bus to let architectury register our content on the right time
|
|
||||||
EventBuses.registerModEventBus(Speedometer.MOD_ID, FMLJavaModLoadingContext.get().getModEventBus());
|
|
||||||
Speedometer.init();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,7 +6,9 @@
|
|||||||
"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"
|
"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.1": "Added second speed display"
|
||||||
},
|
},
|
||||||
"1.20": {
|
"1.20": {
|
||||||
"1.0": "First version",
|
"1.0": "First version",
|
||||||
@@ -14,13 +16,15 @@
|
|||||||
"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"
|
"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.1": "Added second speed display"
|
||||||
},
|
},
|
||||||
"promos": {
|
"promos": {
|
||||||
"1.20.1-latest": "4.0",
|
"1.20.1-latest": "5.1",
|
||||||
"1.20.1-recommended": "4.0",
|
"1.20.1-recommended": "5.1",
|
||||||
|
|
||||||
"1.20-latest": "4.0",
|
"1.20-latest": "5.1",
|
||||||
"1.20-recommended": "4.0"
|
"1.20-recommended": "5.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,14 +1,16 @@
|
|||||||
org.gradle.jvmargs=-Xmx8G
|
org.gradle.jvmargs=-Xmx8G
|
||||||
|
|
||||||
minecraft_version=1.20.1
|
minecraft_version=1.21
|
||||||
|
|
||||||
archives_base_name=speedometer
|
archives_base_name=speedometer
|
||||||
mod_version=5-alpha
|
mod_version=6.0.1
|
||||||
maven_group=me.zacharias
|
maven_group=me.zacharias
|
||||||
|
|
||||||
architectury_version=9.1.10
|
architectury_version=13.0.1
|
||||||
|
|
||||||
fabric_loader_version=0.14.21
|
fabric_loader_version=0.15.11
|
||||||
fabric_api_version=0.84.0+1.20.1
|
fabric_api_version=0.100.3+1.21
|
||||||
|
|
||||||
forge_version=1.20.1-47.0.19
|
neoforge_version = 21.0.21-beta
|
||||||
|
|
||||||
|
cloth_config_version = 15.0.127
|
||||||
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
|||||||
|
#Fri Jun 21 10:45:53 CEST 2024
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
|
||||||
networkTimeout=10000
|
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
@@ -1,12 +1,16 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id "com.github.johnrengelman.shadow" version "7.1.2"
|
id "com.github.johnrengelman.shadow" version "8.1.1"
|
||||||
}
|
}
|
||||||
architectury {
|
architectury {
|
||||||
platformSetupLoomIde()
|
platformSetupLoomIde()
|
||||||
forge()
|
neoForge()
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories{
|
repositories{
|
||||||
|
maven {
|
||||||
|
name = 'NeoForged'
|
||||||
|
url = 'https://maven.neoforged.net/releases'
|
||||||
|
}
|
||||||
maven { url "https://maven.shedaniel.me/" }
|
maven { url "https://maven.shedaniel.me/" }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -15,24 +19,24 @@ configurations {
|
|||||||
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
|
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
|
||||||
compileClasspath.extendsFrom common
|
compileClasspath.extendsFrom common
|
||||||
runtimeClasspath.extendsFrom common
|
runtimeClasspath.extendsFrom common
|
||||||
developmentForge.extendsFrom common
|
developmentNeoForge.extendsFrom common
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
forge "net.minecraftforge:forge:${rootProject.forge_version}"
|
neoForge "net.neoforged:neoforge:$rootProject.neoforge_version"
|
||||||
// Remove the next line if you don't want to depend on the API
|
// Remove the next line if you don't want to depend on the API
|
||||||
modApi "dev.architectury:architectury-forge:${rootProject.architectury_version}"
|
modImplementation "dev.architectury:architectury-neoforge:$rootProject.architectury_version"
|
||||||
|
|
||||||
modApi "me.shedaniel.cloth:cloth-config-forge:11.1.106"
|
modImplementation "me.shedaniel.cloth:cloth-config-neoforge:$rootProject.cloth_config_version"
|
||||||
|
|
||||||
common(project(path: ":common", configuration: "namedElements")) { transitive false }
|
common(project(path: ":common", configuration: "namedElements")) { transitive false }
|
||||||
shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive = false }
|
shadowCommon(project(path: ":common", configuration: "transformProductionNeoForge")) { transitive = false }
|
||||||
}
|
}
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
inputs.property "version", project.version
|
inputs.property "version", project.version
|
||||||
|
|
||||||
filesMatching("META-INF/mods.toml") {
|
filesMatching("META-INF/neoforge.mods.toml") {
|
||||||
expand "version": project.version
|
expand "version": project.version
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
1
neoforge/gradle.properties
Normal file
1
neoforge/gradle.properties
Normal file
@@ -0,0 +1 @@
|
|||||||
|
loom.platform=neoforge
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package me.zacharias.speedometer.forge;
|
||||||
|
|
||||||
|
import me.zacharias.speedometer.Speedometer;
|
||||||
|
import net.neoforged.fml.common.Mod;
|
||||||
|
|
||||||
|
@Mod(Speedometer.MOD_ID)
|
||||||
|
public class SpeedometerNeoForge {
|
||||||
|
public SpeedometerNeoForge() {
|
||||||
|
// Submit our event bus to let architectury register our content on the right time
|
||||||
|
Speedometer.init();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
# This is an example mods.toml file. It contains the data relating to the loading mods.
|
# This is an example neoforge.mods.toml file. It contains the data relating to the loading mods.
|
||||||
# There are several mandatory fields (#mandatory), and many more that are optional (#optional).
|
# There are several mandatory fields (#mandatory), and many more that are optional (#optional).
|
||||||
# The overall format is standard TOML format, v0.5.0.
|
# The overall format is standard TOML format, v0.5.0.
|
||||||
# Note that there are a couple of TOML lists in this file.
|
# Note that there are a couple of TOML lists in this file.
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
|
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
|
||||||
modLoader="javafml" #mandatory
|
modLoader="javafml" #mandatory
|
||||||
# A version range to match for said mod loader - for regular FML @Mod it will be the forge version
|
# A version range to match for said mod loader - for regular FML @Mod it will be the forge version
|
||||||
loaderVersion="[46,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
|
loaderVersion="[2,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
|
||||||
# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties.
|
# The license for you mod. This is mandatory metadata and allows for easier comprehension of your redistributive properties.
|
||||||
# Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here.
|
# Review your options at https://choosealicense.com/. All rights reserved is the default copyright stance, and is thus the default here.
|
||||||
license="All Rights Reserved"
|
license="All Rights Reserved"
|
||||||
@@ -31,7 +31,7 @@ logoFile="icon.png" #optional
|
|||||||
# A text field displayed in the mod UI
|
# A text field displayed in the mod UI
|
||||||
#credits="Thanks for this example mod goes to Java" #optional
|
#credits="Thanks for this example mod goes to Java" #optional
|
||||||
# A text field displayed in the mod UI
|
# A text field displayed in the mod UI
|
||||||
authors="Allen" #optional
|
authors="Zacharias" #optional
|
||||||
# Display Test controls the display for your mod in the server connection screen
|
# Display Test controls the display for your mod in the server connection screen
|
||||||
# MATCH_VERSION means that your mod will cause a red X if the versions on client and server differ. This is the default behaviour and should be what you choose if you have server and client elements to your mod.
|
# MATCH_VERSION means that your mod will cause a red X if the versions on client and server differ. This is the default behaviour and should be what you choose if you have server and client elements to your mod.
|
||||||
# IGNORE_SERVER_VERSION means that your mod will not cause a red X if it's present on the server but not on the client. This is what you should use if you're a server only mod.
|
# IGNORE_SERVER_VERSION means that your mod will not cause a red X if it's present on the server but not on the client. This is what you should use if you're a server only mod.
|
||||||
@@ -47,32 +47,32 @@ just displaying your speed
|
|||||||
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
|
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
|
||||||
[[dependencies.speedometer]] #optional
|
[[dependencies.speedometer]] #optional
|
||||||
# the modid of the dependency
|
# the modid of the dependency
|
||||||
modId="forge" #mandatory
|
modId="neoforge" #mandatory
|
||||||
# Does this dependency have to exist - if not, ordering below must be specified
|
# Does this dependency have to exist - if not, ordering below must be specified
|
||||||
mandatory=true #mandatory
|
mandatory=true #mandatory
|
||||||
# The version range of the dependency
|
# The version range of the dependency
|
||||||
versionRange="[46,)" #mandatory
|
versionRange="[2,)" #mandatory
|
||||||
# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
|
# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
|
||||||
ordering="NONE"
|
ordering="NONE"
|
||||||
# Side this dependency is applied on - BOTH, CLIENT or SERVER
|
# Side this dependency is applied on - BOTH, CLIENT or SERVER
|
||||||
side="BOTH"
|
side="CLIENT"
|
||||||
# Here's another dependency
|
# Here's another dependency
|
||||||
[[dependencies.speedometer]]
|
[[dependencies.speedometer]]
|
||||||
modId="minecraft"
|
modId="minecraft"
|
||||||
mandatory=true
|
mandatory=true
|
||||||
# This version range declares a minimum of the current minecraft version up to but not including the next major version
|
# This version range declares a minimum of the current minecraft version up to but not including the next major version
|
||||||
versionRange="[1.20,1.21)"
|
versionRange="[1.21,1.22)"
|
||||||
ordering="NONE"
|
ordering="NONE"
|
||||||
side="BOTH"
|
side="BOTH"
|
||||||
[[dependencies.speedometer]]
|
[[dependencies.speedometer]]
|
||||||
modId="architectury"
|
modId="architectury"
|
||||||
mandatory=true
|
mandatory=true
|
||||||
versionRange="[9.1.10,)"
|
versionRange="[13.0.1,)"
|
||||||
ordering="NONE"
|
ordering="NONE"
|
||||||
side="CLIENT"
|
side="CLIENT"
|
||||||
[[dependencies.speedometer]]
|
[[dependencies.speedometer]]
|
||||||
modId="cloth_config"
|
modId="cloth_config"
|
||||||
mandatory=true
|
mandatory=false
|
||||||
versionRange="[11.1.106,)"
|
versionRange="[15.0.127,)"
|
||||||
ordering="NONE"
|
ordering="NONE"
|
||||||
side="CLIENT"
|
side="CLIENT"
|
||||||
|
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
11
neoforge/src/main/resources/updateChecker.json
Normal file
11
neoforge/src/main/resources/updateChecker.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"homepage": "https://modrinth.com/mod/speedometer/versions",
|
||||||
|
"1.21": {
|
||||||
|
"6.0": "Lost support for Forge and gain NeoForge support",
|
||||||
|
"6.0.1": "Small bug fix in Parser"
|
||||||
|
},
|
||||||
|
"promos": {
|
||||||
|
"1.21-latest": "6.0.1",
|
||||||
|
"1.21-recommended": "6.0.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,10 +1,13 @@
|
|||||||
# 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`
|
||||||
* Download the source code from github page [master.zip](https://github.com/zaze06/Speedometer/archive/refs/heads/master.zip)
|
* Download the source code from GitHub page [master.zip](https://github.com/zaze06/Speedometer/archive/refs/heads/master.zip)
|
||||||
* unzip the folder
|
* unzip the folder
|
||||||
2. Open the folder
|
2. Open the folder
|
||||||
3. Run `gradlew build`(Windows cmd) or `./gradlew build`(Linux, MacOS, Windows powershell)
|
3. Run `gradlew build`(Windows cmd) or `./gradlew build`(Linux, MacOS, Windows powershell)
|
||||||
|
|||||||
@@ -9,4 +9,4 @@ pluginManagement {
|
|||||||
|
|
||||||
include("common")
|
include("common")
|
||||||
include("fabric")
|
include("fabric")
|
||||||
include("forge")
|
include("neoforge")
|
||||||
Reference in New Issue
Block a user