initial commit
This commit is contained in:
118
.gitignore
vendored
Normal file
118
.gitignore
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
# User-specific stuff
|
||||
.idea/
|
||||
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
|
||||
# IntelliJ
|
||||
out/
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Compiled class file
|
||||
*.class
|
||||
|
||||
# Log file
|
||||
*.log
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.nar
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
|
||||
*~
|
||||
|
||||
# temporary files which can be created if a process still has a handle open of a deleted file
|
||||
.fuse_hidden*
|
||||
|
||||
# KDE directory preferences
|
||||
.directory
|
||||
|
||||
# Linux trash folder which might appear on any partition or disk
|
||||
.Trash-*
|
||||
|
||||
# .nfs files are created when an open file is removed but is still being accessed
|
||||
.nfs*
|
||||
|
||||
# General
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
# Windows thumbnail cache files
|
||||
Thumbs.db
|
||||
Thumbs.db:encryptable
|
||||
ehthumbs.db
|
||||
ehthumbs_vista.db
|
||||
|
||||
# Dump file
|
||||
*.stackdump
|
||||
|
||||
# Folder config file
|
||||
[Dd]esktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Windows Installer files
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
|
||||
.gradle
|
||||
build/
|
||||
|
||||
# Ignore Gradle GUI config
|
||||
gradle-app.setting
|
||||
|
||||
# Cache of project
|
||||
.gradletasknamecache
|
||||
|
||||
**/build/
|
||||
|
||||
# Common working directory
|
||||
run/
|
||||
|
||||
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
|
||||
!gradle-wrapper.jar
|
||||
51
build.gradle
Normal file
51
build.gradle
Normal file
@@ -0,0 +1,51 @@
|
||||
plugins {
|
||||
id "architectury-plugin" version "3.4-SNAPSHOT"
|
||||
id "dev.architectury.loom" version "1.1-SNAPSHOT" apply false
|
||||
}
|
||||
|
||||
architectury {
|
||||
minecraft = rootProject.minecraft_version
|
||||
}
|
||||
|
||||
subprojects {
|
||||
apply plugin: "dev.architectury.loom"
|
||||
|
||||
loom {
|
||||
silentMojangMappingsLicense()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft "com.mojang:minecraft:${rootProject.minecraft_version}"
|
||||
// The following line declares the mojmap mappings, you may use other mappings as well
|
||||
mappings loom.officialMojangMappings()
|
||||
// The following line declares the yarn mappings you may select this one as well.
|
||||
// mappings "net.fabricmc:yarn:@YARN_MAPPINGS@:v2"
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
apply plugin: "java"
|
||||
apply plugin: "architectury-plugin"
|
||||
apply plugin: "maven-publish"
|
||||
|
||||
archivesBaseName = rootProject.archives_base_name
|
||||
version = rootProject.mod_version
|
||||
group = rootProject.maven_group
|
||||
|
||||
repositories {
|
||||
// Add repositories to retrieve artifacts from in here.
|
||||
// You should only use this when depending on other mods because
|
||||
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
|
||||
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
|
||||
// for more information about repositories.
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.encoding = "UTF-8"
|
||||
options.release = 17
|
||||
}
|
||||
|
||||
java {
|
||||
withSourcesJar()
|
||||
}
|
||||
}
|
||||
30
common/build.gradle
Normal file
30
common/build.gradle
Normal file
@@ -0,0 +1,30 @@
|
||||
dependencies {
|
||||
// We depend on fabric loader here to use the fabric @Environment annotations and get the mixin dependencies
|
||||
// Do NOT use other classes from fabric loader
|
||||
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
|
||||
// Remove the next line if you don't want to depend on the API
|
||||
modApi "dev.architectury:architectury:${rootProject.architectury_version}"
|
||||
|
||||
modApi "me.shedaniel.cloth:cloth-config-fabric:11.0.99"
|
||||
|
||||
implementation 'org.json:json:20230227'
|
||||
include 'org.json:json:20230227'
|
||||
}
|
||||
|
||||
architectury {
|
||||
common()
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
mavenCommon(MavenPublication) {
|
||||
artifactId = rootProject.archives_base_name
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
|
||||
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
|
||||
repositories {
|
||||
// Add repositories to publish to here.
|
||||
}
|
||||
}
|
||||
126
common/src/main/java/me/zacharias/speedometer/Config.java
Normal file
126
common/src/main/java/me/zacharias/speedometer/Config.java
Normal file
@@ -0,0 +1,126 @@
|
||||
package me.zacharias.speedometer;
|
||||
|
||||
import dev.architectury.platform.Platform;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.joml.Vector3i;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import javax.swing.plaf.ColorUIResource;
|
||||
import java.io.*;
|
||||
|
||||
import me.shedaniel.math.Color;
|
||||
|
||||
import static me.zacharias.speedometer.Speedometer.MOD_ID;
|
||||
|
||||
public class Config {
|
||||
private static JSONObject Config;
|
||||
|
||||
public static void initialize(){
|
||||
if(Config != null) throw new RuntimeException("Already Initialized");
|
||||
File config = new File(Platform.getConfigFolder().toString()+"/"+MOD_ID+"/config.json");
|
||||
if(!config.exists()){
|
||||
try {
|
||||
config.getParentFile().mkdir();
|
||||
config.createNewFile();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
Config = new JSONObject();
|
||||
|
||||
|
||||
Config.put("speed", SpeedTypes.BlockPS);
|
||||
Config.put("useKnot", false);
|
||||
Config.put("color", new JSONObject()
|
||||
.put("r", 16)
|
||||
.put("g", 146)
|
||||
.put("b", 158)
|
||||
);
|
||||
Config.put("debug", false);
|
||||
}else {
|
||||
try {
|
||||
BufferedReader in = new BufferedReader(new FileReader(config));
|
||||
String tmp = "";
|
||||
StringBuilder builder = new StringBuilder();
|
||||
while((tmp = in.readLine()) != null){
|
||||
builder.append(tmp);
|
||||
}
|
||||
Config = new JSONObject(builder.toString());
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void save(){
|
||||
File config = new File(Platform.getConfigFolder().toString()+"/"+MOD_ID+"/config.json");
|
||||
if(!config.exists()){
|
||||
try {
|
||||
config.getParentFile().mkdir();
|
||||
config.createNewFile();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
try {
|
||||
BufferedWriter out = new BufferedWriter(new FileWriter(config));
|
||||
out.write(Config.toString(4));
|
||||
out.flush();
|
||||
out.close();
|
||||
}catch (Exception e){
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static SpeedTypes getSpeedType(){
|
||||
if(Config.has("speed")){
|
||||
return Config.getEnum(SpeedTypes.class, "speed");
|
||||
}else{
|
||||
return SpeedTypes.BlockPS;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean getUseKnot() {
|
||||
if(Config.has("useKnot")){
|
||||
return Config.getBoolean("useKnot");
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static Color getColor(){
|
||||
if(Config.has("color")){
|
||||
JSONObject color = Config.getJSONObject("color");
|
||||
return Color.ofRGB(
|
||||
color.getInt("r"),
|
||||
color.getInt("g"),
|
||||
color.getInt("b")
|
||||
);
|
||||
}else{
|
||||
return Color.ofRGB(16, 146, 158);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean getIsDebug() {
|
||||
if(Config.has("debug")){
|
||||
return Config.getBoolean("debug");
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setColor(Color color){
|
||||
Config.put("color", new JSONObject()
|
||||
.put("r", color.getRed())
|
||||
.put("g", color.getGreen())
|
||||
.put("b", color.getBlue())
|
||||
);
|
||||
}
|
||||
|
||||
public static void setUseKnot(boolean useKnot){
|
||||
Config.put("useKnot", useKnot);
|
||||
}
|
||||
|
||||
public static void setSpeedType(SpeedTypes speedType) {
|
||||
Config.put("speed", speedType);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package me.zacharias.speedometer;
|
||||
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
public enum SpeedTypes {
|
||||
MPH,
|
||||
KMPH,
|
||||
MPS,
|
||||
BlockPS,
|
||||
KNOT;
|
||||
|
||||
public static Component getName(Enum anEnum) {
|
||||
if(anEnum instanceof SpeedTypes speedType) {
|
||||
return Component.translatable("speedometer.speed." + switch (speedType) {
|
||||
case MPH -> "mph";
|
||||
case MPS -> "mps";
|
||||
case KMPH -> "kmph";
|
||||
case BlockPS -> "bps";
|
||||
case KNOT -> "knot";
|
||||
default -> "error";
|
||||
});
|
||||
}else {
|
||||
return Component.translatable("speedometer.speed.error");
|
||||
}
|
||||
}
|
||||
}
|
||||
274
common/src/main/java/me/zacharias/speedometer/Speedometer.java
Normal file
274
common/src/main/java/me/zacharias/speedometer/Speedometer.java
Normal file
@@ -0,0 +1,274 @@
|
||||
package me.zacharias.speedometer;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.base.Suppliers;
|
||||
import com.mojang.authlib.minecraft.client.MinecraftClient;
|
||||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
import dev.architectury.event.events.client.ClientGuiEvent;
|
||||
import dev.architectury.event.events.client.ClientTickEvent;
|
||||
import dev.architectury.injectables.targets.ArchitecturyTarget;
|
||||
import dev.architectury.platform.Platform;
|
||||
import dev.architectury.registry.client.keymappings.KeyMappingRegistry;
|
||||
import dev.architectury.registry.registries.RegistrarManager;
|
||||
import dev.architectury.event.EventHandler;
|
||||
import dev.architectury.utils.Env;
|
||||
import dev.architectury.utils.EnvExecutor;
|
||||
import me.shedaniel.clothconfig2.api.ConfigBuilder;
|
||||
import me.shedaniel.clothconfig2.api.ConfigCategory;
|
||||
import me.shedaniel.clothconfig2.api.ConfigEntryBuilder;
|
||||
import net.minecraft.client.KeyMapping;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.font.FontSet;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.vehicle.Boat;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import javax.swing.plaf.ColorUIResource;
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class Speedometer
|
||||
{
|
||||
public static final String MOD_ID = "speedometer";
|
||||
public static final Supplier<RegistrarManager> MANAGER = Suppliers.memoize(() -> RegistrarManager.get(MOD_ID));
|
||||
public static final Logger LOGGER = LogManager.getLogger(MOD_ID);
|
||||
|
||||
public static final KeyMapping CONFIG_KEY = new KeyMapping(
|
||||
"speedometer.key.configkey",
|
||||
InputConstants.Type.KEYSYM,
|
||||
InputConstants.KEY_O,
|
||||
"speedometer.key.catagory"
|
||||
);
|
||||
|
||||
public static void init() {
|
||||
if(Platform.isForge()){
|
||||
LOGGER.info("Hello, Forge! from Architectury");
|
||||
}else if(Platform.isFabric()){
|
||||
LOGGER.info("Hello, Fabric! from Architectury");
|
||||
}else{
|
||||
LOGGER.info("Hello! from Architectury");
|
||||
}
|
||||
|
||||
if(Platform.getEnvironment() != Env.CLIENT) return;
|
||||
|
||||
KeyMappingRegistry.register(CONFIG_KEY);
|
||||
ClientTickEvent.CLIENT_POST.register(minecraft -> {
|
||||
if(CONFIG_KEY.consumeClick()){
|
||||
Minecraft.getInstance().setScreen(getConfig(Minecraft.getInstance().screen).build());
|
||||
}
|
||||
});
|
||||
|
||||
Config.initialize();
|
||||
Config.save();
|
||||
|
||||
// TODO add cloth config for abstract config system
|
||||
|
||||
ArrayList<Double> speeds = new ArrayList<>();
|
||||
|
||||
ClientGuiEvent.RENDER_HUD.register((graphics, tick) -> {
|
||||
if(Minecraft.getInstance().player == null) return;
|
||||
Entity entity = Minecraft.getInstance().player.getRootVehicle();
|
||||
|
||||
Level world = entity.level();
|
||||
double x = entity.position().x;
|
||||
double y = entity.position().y;
|
||||
double z = entity.position().z;
|
||||
|
||||
Vec3 vec = entity.getDeltaMovement();
|
||||
|
||||
double yOffset = 0.0784000015258789D;
|
||||
double xOffset = 0D;
|
||||
double zOffset = 0D;
|
||||
double vOffset = 0D;
|
||||
|
||||
if (entity instanceof Player e) {
|
||||
if (!e.onGround() && e.isCreative()) {
|
||||
yOffset = 0;
|
||||
} else if (e.isInWater()) {
|
||||
yOffset = 0;
|
||||
}
|
||||
} else if (entity instanceof Boat) {
|
||||
yOffset = 0;
|
||||
}
|
||||
|
||||
double speed = (Math.sqrt(Math.pow(vec.x + xOffset, 2) + Math.pow(vec.y + yOffset, 2) + Math.pow(vec.z + zOffset, 2)) * 20)+vOffset;
|
||||
|
||||
if (speeds.size() >= 30) {
|
||||
speeds.remove(0);
|
||||
}
|
||||
speeds.add(speed);
|
||||
speed = 0;
|
||||
for (Double aDouble : speeds) {
|
||||
speed += aDouble;
|
||||
}
|
||||
speed = speed / speeds.size();
|
||||
|
||||
SpeedTypes speedType = Config.getSpeedType();
|
||||
if (speedType == SpeedTypes.KNOT || (entity instanceof Boat && Config.getUseKnot())) {
|
||||
speed = speed * 1.94384449;
|
||||
}else if (speedType == SpeedTypes.KMPH) {
|
||||
speed = speed * 3.6;
|
||||
} else if (speedType == SpeedTypes.MPH) {
|
||||
speed = speed * 2.23693629;
|
||||
}
|
||||
|
||||
String format = String.format("%.2f", speed);
|
||||
|
||||
|
||||
// i -> x
|
||||
// j -> y
|
||||
// k -> color RGB int
|
||||
graphics.drawString(
|
||||
Minecraft.getInstance().font,
|
||||
format+" "+SpeedTypes.getName(speedType).getString(),
|
||||
getPos(graphics, "W-70", 0, false),
|
||||
getPos(graphics, "H-17", 1, true),
|
||||
Config.getColor().getColor());
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
static boolean flag = true;
|
||||
|
||||
private static int getPos(GuiGraphics event, String input, int type, boolean changeFlag) {
|
||||
ArrayList<String> paserdPos = new ArrayList<String>();
|
||||
final char[] s = input.toCharArray();
|
||||
try{
|
||||
for(int i = 0; i <s.length; i++){
|
||||
if(s[i] == 'W' || s[i] == 'H'){
|
||||
if(type == 0) paserdPos.add(event.guiWidth()+"");
|
||||
else if(type == 1) paserdPos.add(event.guiHeight()+"");
|
||||
}else if(s[i] == 'h' || s[i] == 'w'){
|
||||
if(type == 0) paserdPos.add(((int)(event.guiWidth()/2))+"");
|
||||
else if(type == 1) paserdPos.add(((int)(event.guiHeight()/2))+"");
|
||||
}else if(s[i] == '+'){
|
||||
paserdPos.add("+");
|
||||
}else if(s[i] == '-'){
|
||||
paserdPos.add("-");
|
||||
}else if(s[i] == '*'){
|
||||
paserdPos.add("/");
|
||||
}else if(s[i] == '/'){
|
||||
paserdPos.add("/");
|
||||
}else if(testIfInt(s[i])){
|
||||
try{
|
||||
Integer.parseInt(paserdPos.get(i-1));
|
||||
paserdPos.add(i-1,paserdPos.get(i-1)+s[i]);
|
||||
}catch (NumberFormatException e){
|
||||
paserdPos.add(Character.toString(s[i]));
|
||||
}
|
||||
}else{
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
paserdPos.clear();
|
||||
if(type == 0){
|
||||
paserdPos.add(event.guiWidth()+"");
|
||||
paserdPos.add("-");
|
||||
paserdPos.add("70");
|
||||
}else if(type == 1){
|
||||
paserdPos.add(event.guiHeight()+"");
|
||||
paserdPos.add("-");
|
||||
paserdPos.add("15");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int xPos = 0;
|
||||
try{
|
||||
xPos = Integer.parseInt(paserdPos.get(0));
|
||||
}catch (NumberFormatException e){
|
||||
if(type == 0){
|
||||
paserdPos.add(event.guiWidth()+"");
|
||||
paserdPos.add("-");
|
||||
paserdPos.add("70");
|
||||
}else if(type == 1){
|
||||
paserdPos.add(event.guiHeight()+"");
|
||||
paserdPos.add("-");
|
||||
paserdPos.add("15");
|
||||
}
|
||||
xPos = Integer.parseInt(paserdPos.get(0));
|
||||
}
|
||||
|
||||
for(int i = 1; i < paserdPos.size(); i++){
|
||||
boolean first = i == 0;
|
||||
String s1 = paserdPos.get(i);
|
||||
String s2 = "";
|
||||
try{
|
||||
s2 = paserdPos.get(i+1);
|
||||
}catch (Exception e){
|
||||
first = true;
|
||||
}
|
||||
|
||||
if(s1 == "+" && !first){
|
||||
xPos += Integer.parseInt(s2);
|
||||
}else if(s1 == "-" && !first){
|
||||
xPos -= Integer.parseInt(s2);
|
||||
}else if(s1 == "*" && !first){
|
||||
xPos *= Integer.parseInt(s2);
|
||||
}else if(s1 == "/" && !first){
|
||||
xPos /= Integer.parseInt(s2);
|
||||
}
|
||||
}
|
||||
if((Platform.isDevelopmentEnvironment() || Config.getIsDebug()) && flag) {
|
||||
LOGGER.info("Selected speed type: "+SpeedTypes.getName(Config.getSpeedType()).getString()+"\n"+
|
||||
Arrays.toString(paserdPos.toArray())+"\n\n"+
|
||||
xPos);
|
||||
flag = !changeFlag;
|
||||
}
|
||||
return xPos;
|
||||
}
|
||||
|
||||
private static boolean testIfInt(char c) {
|
||||
int i = Integer.parseInt(Character.toString(c));
|
||||
return (i == 0 || i == 1 || i == 2 ||
|
||||
i == 3 || i == 4 || i == 5 ||
|
||||
i == 6 || i == 7 || i == 8 ||
|
||||
i == 9);
|
||||
}
|
||||
|
||||
public static ConfigBuilder getConfig(Screen parent) {
|
||||
ConfigBuilder builder = ConfigBuilder.create()
|
||||
.setParentScreen(parent)
|
||||
.setTitle(Component.translatable("speedometer.config.name"));
|
||||
|
||||
ConfigCategory category = builder.getOrCreateCategory(Component.translatable("speedometer.config.category.name"));
|
||||
|
||||
ConfigEntryBuilder entryBuilder = builder.entryBuilder();
|
||||
|
||||
category.addEntry(entryBuilder.startEnumSelector(Component.translatable("speedometer.config.speed"), SpeedTypes.class, me.zacharias.speedometer.Config.getSpeedType())
|
||||
.setEnumNameProvider(SpeedTypes::getName)
|
||||
.setSaveConsumer(me.zacharias.speedometer.Config::setSpeedType)
|
||||
.build()
|
||||
);
|
||||
|
||||
category.addEntry(entryBuilder.startColorField(Component.translatable("speedometer.config.color"), me.zacharias.speedometer.Config.getColor())
|
||||
.setSaveConsumer2(me.zacharias.speedometer.Config::setColor)
|
||||
.build());
|
||||
|
||||
category.addEntry(entryBuilder.startBooleanToggle(Component.translatable("speedometer.config.knot"), me.zacharias.speedometer.Config.getUseKnot())
|
||||
.setSaveConsumer(me.zacharias.speedometer.Config::setUseKnot)
|
||||
.build()
|
||||
);
|
||||
|
||||
builder.setSavingRunnable(me.zacharias.speedometer.Config::save);
|
||||
|
||||
return builder;
|
||||
}
|
||||
}
|
||||
17
common/src/main/resources/assets/speedometer/lang/en_us.json
Normal file
17
common/src/main/resources/assets/speedometer/lang/en_us.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"speedometer.config.name": "Speedometer Config",
|
||||
"speedometer.config.category.name": "Speedometer Config Category",
|
||||
"speedometer.config.speed": "Speed Type",
|
||||
"speedometer.config.color": "Color",
|
||||
"speedometer.config.knot": "Use knot in boats",
|
||||
|
||||
"speedometer.key.configkey": "Config Key",
|
||||
"speedometer.key.catagory": "Speedometer",
|
||||
|
||||
"speedometer.speed.mph": "MPH",
|
||||
"speedometer.speed.mps": "Meters/s",
|
||||
"speedometer.speed.kmph": "Km/h",
|
||||
"speedometer.speed.bps": "Blocks/s",
|
||||
"speedometer.speed.knot": "Knot",
|
||||
"speedometer.speed.error": "Unknown Speed Type"
|
||||
}
|
||||
5
common/src/main/resources/pack.mcmeta
Normal file
5
common/src/main/resources/pack.mcmeta
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"pack": {
|
||||
"pack_format": 15
|
||||
}
|
||||
}
|
||||
86
fabric/build.gradle
Normal file
86
fabric/build.gradle
Normal file
@@ -0,0 +1,86 @@
|
||||
plugins {
|
||||
id "com.github.johnrengelman.shadow" version "7.1.2"
|
||||
}
|
||||
|
||||
architectury {
|
||||
platformSetupLoomIde()
|
||||
fabric()
|
||||
}
|
||||
|
||||
configurations {
|
||||
common
|
||||
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
|
||||
compileClasspath.extendsFrom common
|
||||
runtimeClasspath.extendsFrom common
|
||||
developmentFabric.extendsFrom common
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven { url "https://maven.shedaniel.me/" }
|
||||
maven { url "https://maven.terraformersmc.com/releases/" }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
|
||||
modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}"
|
||||
// Remove the next line if you don't want to depend on the API
|
||||
modApi "dev.architectury:architectury-fabric:${rootProject.architectury_version}"
|
||||
|
||||
modApi "me.shedaniel.cloth:cloth-config-fabric:11.0.99"
|
||||
modApi "com.terraformersmc:modmenu:7.0.1"
|
||||
|
||||
common(project(path: ":common", configuration: "namedElements")) { transitive false }
|
||||
shadowCommon(project(path: ":common", configuration: "transformProductionFabric")) { transitive false }
|
||||
|
||||
implementation 'org.json:json:20230227'
|
||||
include 'org.json:json:20230227'
|
||||
}
|
||||
|
||||
processResources {
|
||||
inputs.property "version", project.version
|
||||
|
||||
filesMatching("fabric.mod.json") {
|
||||
expand "version": project.version
|
||||
}
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
configurations = [project.configurations.shadowCommon]
|
||||
archiveClassifier.set("dev-shadow")
|
||||
}
|
||||
|
||||
remapJar {
|
||||
inputFile.set shadowJar.archiveFile
|
||||
dependsOn shadowJar
|
||||
archiveClassifier.set(null)
|
||||
}
|
||||
|
||||
jar {
|
||||
archiveClassifier.set("dev")
|
||||
}
|
||||
|
||||
sourcesJar {
|
||||
def commonSources = project(":common").sourcesJar
|
||||
dependsOn commonSources
|
||||
from commonSources.archiveFile.map { zipTree(it) }
|
||||
}
|
||||
|
||||
components.java {
|
||||
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
|
||||
skip()
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
mavenFabric(MavenPublication) {
|
||||
artifactId = rootProject.archives_base_name + "-" + project.name
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
|
||||
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
|
||||
repositories {
|
||||
// Add repositories to publish to here.
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package me.zacharias.speedometer.fabric;
|
||||
|
||||
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
|
||||
import com.terraformersmc.modmenu.api.ModMenuApi;
|
||||
import me.shedaniel.clothconfig2.api.ConfigBuilder;
|
||||
import me.shedaniel.clothconfig2.api.ConfigCategory;
|
||||
import me.shedaniel.clothconfig2.api.ConfigEntryBuilder;
|
||||
import me.zacharias.speedometer.SpeedTypes;
|
||||
import me.zacharias.speedometer.Speedometer;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
public class Config implements ModMenuApi {
|
||||
@Override
|
||||
public ConfigScreenFactory<?> getModConfigScreenFactory() {
|
||||
return parent -> {
|
||||
ConfigBuilder builder = Speedometer.getConfig(parent);
|
||||
|
||||
return builder.build();
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package me.zacharias.speedometer.fabric;
|
||||
|
||||
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
|
||||
import com.terraformersmc.modmenu.api.ModMenuApi;
|
||||
import me.shedaniel.clothconfig2.api.ConfigBuilder;
|
||||
import me.zacharias.speedometer.Speedometer;
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
public class SpeedometerFabric implements ModInitializer {
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
Speedometer.init();
|
||||
|
||||
}
|
||||
}
|
||||
23
fabric/src/main/resources/fabric.mod.json
Normal file
23
fabric/src/main/resources/fabric.mod.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "speedometer",
|
||||
"version": "${version}",
|
||||
|
||||
"name": "speedometer",
|
||||
"description": "just displaying your speed",
|
||||
"authors": [],
|
||||
"contact": {},
|
||||
|
||||
"license": "All Rights Reserved",
|
||||
"icon": "icon.png",
|
||||
|
||||
"environment": "*",
|
||||
"entrypoints": {
|
||||
"main": ["me.zacharias.speedometer.fabric.SpeedometerFabric"],
|
||||
"modmenu": ["me.zacharias.speedometer.fabric.Config"]
|
||||
},
|
||||
"depends": {
|
||||
"fabricloader": ">=0.14.21",
|
||||
"minecraft": ">=1.20"
|
||||
}
|
||||
}
|
||||
BIN
fabric/src/main/resources/icon.png
Normal file
BIN
fabric/src/main/resources/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 453 B |
86
forge/build.gradle
Normal file
86
forge/build.gradle
Normal file
@@ -0,0 +1,86 @@
|
||||
plugins {
|
||||
id "com.github.johnrengelman.shadow" version "7.1.2"
|
||||
}
|
||||
architectury {
|
||||
platformSetupLoomIde()
|
||||
forge()
|
||||
}
|
||||
|
||||
repositories{
|
||||
maven { url "https://maven.shedaniel.me/" }
|
||||
}
|
||||
|
||||
configurations {
|
||||
common
|
||||
shadowCommon // Don't use shadow from the shadow plugin because we don't want IDEA to index this.
|
||||
compileClasspath.extendsFrom common
|
||||
runtimeClasspath.extendsFrom common
|
||||
developmentForge.extendsFrom common
|
||||
}
|
||||
|
||||
dependencies {
|
||||
forge "net.minecraftforge:forge:${rootProject.forge_version}"
|
||||
// Remove the next line if you don't want to depend on the API
|
||||
modApi "dev.architectury:architectury-forge:${rootProject.architectury_version}"
|
||||
|
||||
modApi "me.shedaniel.cloth:cloth-config-forge:11.0.99"
|
||||
|
||||
common(project(path: ":common", configuration: "namedElements")) { transitive false }
|
||||
shadowCommon(project(path: ":common", configuration: "transformProductionForge")) { transitive = false }
|
||||
|
||||
implementation 'org.json:json:20230227'
|
||||
include 'org.json:json:20230227'
|
||||
forgeRuntimeLibrary 'org.json:json:20230227'
|
||||
}
|
||||
|
||||
processResources {
|
||||
inputs.property "version", project.version
|
||||
|
||||
filesMatching("META-INF/mods.toml") {
|
||||
expand "version": project.version
|
||||
}
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
exclude "fabric.mod.json"
|
||||
|
||||
|
||||
configurations = [project.configurations.shadowCommon]
|
||||
archiveClassifier.set("dev-shadow")
|
||||
}
|
||||
|
||||
remapJar {
|
||||
inputFile.set shadowJar.archiveFile
|
||||
dependsOn shadowJar
|
||||
archiveClassifier.set(null)
|
||||
}
|
||||
|
||||
jar {
|
||||
archiveClassifier.set("dev")
|
||||
}
|
||||
|
||||
sourcesJar {
|
||||
def commonSources = project(":common").sourcesJar
|
||||
dependsOn commonSources
|
||||
from commonSources.archiveFile.map { zipTree(it) }
|
||||
}
|
||||
|
||||
components.java {
|
||||
withVariantsFromConfiguration(project.configurations.shadowRuntimeElements) {
|
||||
skip()
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
mavenForge(MavenPublication) {
|
||||
artifactId = rootProject.archives_base_name + "-" + project.name
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
|
||||
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
|
||||
repositories {
|
||||
// Add repositories to publish to here.
|
||||
}
|
||||
}
|
||||
1
forge/gradle.properties
Normal file
1
forge/gradle.properties
Normal file
@@ -0,0 +1 @@
|
||||
loom.platform=forge
|
||||
@@ -0,0 +1,15 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
66
forge/src/main/resources/META-INF/mods.toml
Normal file
66
forge/src/main/resources/META-INF/mods.toml
Normal file
@@ -0,0 +1,66 @@
|
||||
# This is an example 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).
|
||||
# The overall format is standard TOML format, v0.5.0.
|
||||
# Note that there are a couple of TOML lists in this file.
|
||||
# Find more information on toml format here: https://github.com/toml-lang/toml
|
||||
# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
|
||||
modLoader="javafml" #mandatory
|
||||
# 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.
|
||||
# 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.
|
||||
license="All Rights Reserved"
|
||||
# A URL to refer people to when problems occur with this mod
|
||||
issueTrackerURL="https://github.com/zaze06/speedometer/issues"
|
||||
# A list of mods - how many allowed here is determined by the individual mod loader
|
||||
[[mods]] #mandatory
|
||||
# The modid of the mod
|
||||
modId="speedometer" #mandatory
|
||||
# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
|
||||
# ${version} will substitute the value of the Implementation-Version as read from the mod's JAR file metadata
|
||||
# see the associated build.gradle script for how to populate this completely automatically during a build
|
||||
version="${version}" #mandatory
|
||||
# A display name for the mod
|
||||
displayName="speedometer" #mandatory
|
||||
# A URL to query for updates for this mod. See the JSON update specification <here>
|
||||
#updateJSONURL="http://myurl.me/" #optional
|
||||
# A URL for the "homepage" for this mod, displayed in the mod UI
|
||||
#displayURL="http://example.com/" #optional
|
||||
# A file name (in the root of the mod JAR) containing a logo for display
|
||||
logoFile="icon.png" #optional
|
||||
# A text field displayed in the mod UI
|
||||
#credits="Thanks for this example mod goes to Java" #optional
|
||||
# A text field displayed in the mod UI
|
||||
authors="Zacharias" #optional
|
||||
# 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.
|
||||
# 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_ALL_VERSION means that your mod will not cause a red X if it's present on the client or the server. This is a special case and should only be used if your mod has no server component.
|
||||
# NONE means that no display test is set on your mod. You need to do this yourself, see IExtensionPoint.DisplayTest for more information. You can define any scheme you wish with this value.
|
||||
# IMPORTANT NOTE: this is NOT an instruction as to which environments (CLIENT or DEDICATED SERVER) your mod loads on. Your mod should load (and maybe do nothing!) whereever it finds itself.
|
||||
#displayTest="MATCH_VERSION" # MATCH_VERSION is the default if nothing is specified (#optional)
|
||||
|
||||
# The description text for the mod (multi line!) (#mandatory)
|
||||
description='''
|
||||
just displaying your speed
|
||||
'''
|
||||
# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
|
||||
[[dependencies.speedometer]] #optional
|
||||
# the modid of the dependency
|
||||
modId="forge" #mandatory
|
||||
# Does this dependency have to exist - if not, ordering below must be specified
|
||||
mandatory=true #mandatory
|
||||
# The version range of the dependency
|
||||
versionRange="[46,)" #mandatory
|
||||
# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
|
||||
ordering="NONE"
|
||||
# Side this dependency is applied on - BOTH, CLIENT or SERVER
|
||||
side="BOTH"
|
||||
# Here's another dependency
|
||||
[[dependencies.speedometer]]
|
||||
modId="minecraft"
|
||||
mandatory=true
|
||||
# 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)"
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
||||
BIN
forge/src/main/resources/icon.png
Normal file
BIN
forge/src/main/resources/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 453 B |
7
forge/src/main/resources/pack.mcmeta
Normal file
7
forge/src/main/resources/pack.mcmeta
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"pack": {
|
||||
"description": "speedometer resources",
|
||||
"pack_format": 13,
|
||||
"forge:server_data_pack_format": 12
|
||||
}
|
||||
}
|
||||
14
gradle.properties
Normal file
14
gradle.properties
Normal file
@@ -0,0 +1,14 @@
|
||||
org.gradle.jvmargs=-Xmx1G
|
||||
|
||||
minecraft_version=1.20
|
||||
|
||||
archives_base_name=speedometer
|
||||
mod_version=1.0
|
||||
maven_group=me.zacharias
|
||||
|
||||
architectury_version=9.0.8
|
||||
|
||||
fabric_loader_version=0.14.21
|
||||
fabric_api_version=0.83.0+1.20
|
||||
|
||||
forge_version=1.20-46.0.14
|
||||
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
|
||||
networkTimeout=10000
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
8
readme.md
Normal file
8
readme.md
Normal file
@@ -0,0 +1,8 @@
|
||||
# Speedometer
|
||||
This is a simple mod for forge and fabric that displays your current speed
|
||||
|
||||
This mod is a newer version of [speedometer-forge](https://github.com/zaze06/speedometer-forge)
|
||||
|
||||
## Changes from old forge version?
|
||||
This was just a project I choose for trying the Architectury API for abstraction.
|
||||
So changes are that now Architectury APi is required for this mod to work
|
||||
12
settings.gradle
Normal file
12
settings.gradle
Normal file
@@ -0,0 +1,12 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
maven { url "https://maven.fabricmc.net/" }
|
||||
maven { url "https://maven.architectury.dev/" }
|
||||
maven { url "https://maven.minecraftforge.net/" }
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
|
||||
include("common")
|
||||
include("fabric")
|
||||
include("forge")
|
||||
Reference in New Issue
Block a user