Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
e5ac3d74c4
|
|||
|
66d63b03ea
|
|||
|
6f8b024bcc
|
|||
|
9c05791a20
|
|||
|
|
7be0ea014c | ||
|
|
0fdab6874c | ||
|
4f6bf01581
|
|||
|
ea3cd92c33
|
|||
|
|
2c88f99140 | ||
|
4b2a150a30
|
|||
|
bd205b5ae6
|
|||
|
192735d352
|
|||
|
216a498d72
|
|||
|
|
d7dbf65446 | ||
|
|
3e282612a3 | ||
| 1a59e3dc2a | |||
| 1fc71a34a9 | |||
|
|
d1e5ef63ee | ||
|
|
32b6198f71 | ||
|
|
5c95f394a8 | ||
| 38f96cb1e9 |
2
.github/ISSUE_TEMPLATE/bug-report.md
vendored
2
.github/ISSUE_TEMPLATE/bug-report.md
vendored
@@ -27,7 +27,7 @@ assignees: zaze06
|
|||||||
|
|
||||||
**Config**
|
**Config**
|
||||||
*If needed*
|
*If needed*
|
||||||
*Use [GitHub Gist](gist.gihub.com) to upload your speedometer config, located in *
|
*Use [GitHub Gist](gist.gihub.com) to upload your speedometer config, located in `<minecraft>/config/speedometer/config.json`*
|
||||||
|
|
||||||
**Logs**
|
**Logs**
|
||||||
*If needed(Most of the times)*
|
*If needed(Most of the times)*
|
||||||
|
|||||||
22
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
22
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
---
|
||||||
|
name: Feature request
|
||||||
|
about: Suggest an idea for this project
|
||||||
|
title: ''
|
||||||
|
labels: ''
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
Make sure your feature havent ben requested at [Feature Requests](https://github.com/zaze06/Speedometer/issues?q=label%3A%22Feature+Request%22)
|
||||||
|
|
||||||
|
**Is your feature request related to a problem? Please describe.**
|
||||||
|
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||||
|
|
||||||
|
**Describe the solution you'd like**
|
||||||
|
A clear and concise description of what you want to happen.
|
||||||
|
|
||||||
|
**Describe alternatives you've considered**
|
||||||
|
A clear and concise description of any alternative solutions or features you've considered.
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context or screenshots about the feature request here.
|
||||||
6
Resourcepack/quarter_circle_speedometer/ReadMe.txt
Normal file
6
Resourcepack/quarter_circle_speedometer/ReadMe.txt
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
Hello there!
|
||||||
|
|
||||||
|
If you're reading this I assume you might be interested in making your own!
|
||||||
|
|
||||||
|
You're in luck, I have provided a guide. Over on GitHub on how to do it!
|
||||||
|
Please check out https://github.com/zaze06/Speedometer/blob/master/resourcepack.md for a guide to get started
|
||||||
@@ -1,6 +1,10 @@
|
|||||||
{
|
{
|
||||||
"pack": {
|
"pack": {
|
||||||
"pack_format": 34,
|
"pack_format": 34,
|
||||||
"description": "A different speedometer"
|
"description": "A different speedometer",
|
||||||
|
"supported_formats": {
|
||||||
|
"min_inclusive": 34,
|
||||||
|
"max_inclusive": 80
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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.7-SNAPSHOT" apply false
|
id "dev.architectury.loom" version "1.10-SNAPSHOT" apply false
|
||||||
}
|
}
|
||||||
|
|
||||||
architectury {
|
architectury {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import dev.architectury.event.events.client.ClientTickEvent;
|
|||||||
import dev.architectury.platform.Platform;
|
import dev.architectury.platform.Platform;
|
||||||
import dev.architectury.registry.client.keymappings.KeyMappingRegistry;
|
import dev.architectury.registry.client.keymappings.KeyMappingRegistry;
|
||||||
import net.minecraft.ChatFormatting;
|
import net.minecraft.ChatFormatting;
|
||||||
|
import net.minecraft.CrashReport;
|
||||||
import net.minecraft.client.DeltaTracker;
|
import net.minecraft.client.DeltaTracker;
|
||||||
import net.minecraft.client.KeyMapping;
|
import net.minecraft.client.KeyMapping;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
@@ -23,370 +24,312 @@ import java.util.*;
|
|||||||
import static me.zacharias.speedometer.Speedometer.*;
|
import static me.zacharias.speedometer.Speedometer.*;
|
||||||
|
|
||||||
public class Client {
|
public class Client {
|
||||||
public static final KeyMapping CONFIG_KEY = new KeyMapping(
|
public static final KeyMapping CONFIG_KEY = new KeyMapping(
|
||||||
"speedometer.key.configKey",
|
"speedometer.key.configKey",
|
||||||
InputConstants.Type.KEYSYM,
|
InputConstants.Type.KEYSYM,
|
||||||
InputConstants.KEY_O,
|
InputConstants.KEY_O,
|
||||||
"speedometer.key.category"
|
"speedometer.key.category"
|
||||||
);
|
);
|
||||||
public static final KeyMapping DEBUG_KEY = new KeyMapping(
|
public static final KeyMapping DEBUG_KEY = new KeyMapping(
|
||||||
"speedometer.key.debugKey",
|
"speedometer.key.debugKey",
|
||||||
InputConstants.Type.KEYSYM,
|
InputConstants.Type.KEYSYM,
|
||||||
InputConstants.KEY_F6,
|
InputConstants.KEY_F6,
|
||||||
"speedometer.key.category"
|
"speedometer.key.category"
|
||||||
);
|
);
|
||||||
|
|
||||||
private static final ArrayList<Double> speeds = new ArrayList<>();
|
private static final ArrayList<Double> speeds = new ArrayList<>();
|
||||||
private static boolean speedometerVisualDisplayFailed = false;
|
|
||||||
|
|
||||||
public static void init(){
|
|
||||||
|
|
||||||
final boolean isClothLoaded = Platform.isModLoaded("cloth_config") || Platform.isModLoaded("cloth-config");
|
public static void init(){
|
||||||
|
|
||||||
if(isClothLoaded) {
|
final boolean isClothLoaded = Platform.isModLoaded("cloth_config") || Platform.isModLoaded("cloth-config");
|
||||||
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);
|
|
||||||
ClientTickEvent.CLIENT_POST.register(minecraft -> {
|
|
||||||
if(CONFIG_KEY.consumeClick()){
|
|
||||||
if(isClothLoaded) {
|
if(isClothLoaded) {
|
||||||
Minecraft.getInstance().setScreen(ConfigMenu.getConfig(Minecraft.getInstance().screen).build());
|
Platform.getMod(MOD_ID).registerConfigurationScreen(parent -> ConfigMenu.getConfig(parent).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
|
else
|
||||||
{
|
{
|
||||||
LOGGER.warn(Component.translatable("speedometer.error.missing_cloth").getString());
|
LOGGER.warn("Missing Cloth Config API, In game config menu will not be available");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
KeyMappingRegistry.register(DEBUG_KEY);
|
KeyMappingRegistry.register(CONFIG_KEY);
|
||||||
ClientTickEvent.CLIENT_POST.register(minecraft -> {
|
ClientTickEvent.CLIENT_POST.register(minecraft -> {
|
||||||
if(DEBUG_KEY.consumeClick()){
|
if(CONFIG_KEY.consumeClick()){
|
||||||
Config.setDebug(!Config.isDebug());
|
if(isClothLoaded) {
|
||||||
}
|
Minecraft.getInstance().setScreen(ConfigMenu.getConfig(Minecraft.getInstance().screen).build());
|
||||||
});
|
}
|
||||||
|
else if(Minecraft.getInstance().player != null)
|
||||||
|
{
|
||||||
|
Minecraft.getInstance().player.displayClientMessage(
|
||||||
|
Component
|
||||||
|
.translatable("speedometer.error.missing_cloth")
|
||||||
|
.withColor(new Color(190, 0, 0).getRGB())
|
||||||
|
.append(Component
|
||||||
|
.translatable("speedometer.error.missing_cloth.open_config")
|
||||||
|
.withStyle(ChatFormatting.UNDERLINE)
|
||||||
|
.withStyle((style) -> style.withClickEvent(new ClickEvent.OpenFile(Config.getConfigPath())))
|
||||||
|
), false);
|
||||||
|
LOGGER.warn(Component.translatable("speedometer.error.missing_cloth").getString());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOGGER.warn(Component.translatable("speedometer.error.missing_cloth").getString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Config.initialize();
|
KeyMappingRegistry.register(DEBUG_KEY);
|
||||||
Config.save();
|
ClientTickEvent.CLIENT_POST.register(minecraft -> {
|
||||||
|
if(DEBUG_KEY.consumeClick()){
|
||||||
|
Config.setDebug(!Config.isDebug());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
ClientGuiEvent.RENDER_HUD.register(Client::render);
|
Config.initialize();
|
||||||
|
Config.save();
|
||||||
|
|
||||||
LOGGER.info("Finished loading speedometer");
|
ClientGuiEvent.RENDER_HUD.register(Client::render);
|
||||||
|
|
||||||
/*((IPackRepository) Minecraft.getInstance().getResourcePackRepository()).addSource(new RepositorySource() {
|
LOGGER.info("Finished loading speedometer");
|
||||||
@Override
|
|
||||||
public void loadPacks(Consumer<Pack> consumer) {
|
|
||||||
consumer.accept(new Pack(new PackLocationInfo(
|
|
||||||
"quarter_circle_speedometer",
|
|
||||||
Component.translatable("resourcepack.speedometer.quarter_circle_speedometer"),
|
|
||||||
new PackSource() {
|
|
||||||
@Override
|
|
||||||
public Component decorate(Component component) {
|
|
||||||
return component;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldAddAutomatically() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
Optional.empty()
|
|
||||||
),
|
|
||||||
new Pack.ResourcesSupplier() {
|
|
||||||
@Override
|
|
||||||
public PackResources openPrimary(PackLocationInfo packLocationInfo) {
|
|
||||||
return packLocationInfo.;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PackResources openFull(PackLocationInfo packLocationInfo, Pack.Metadata metadata) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
});*/
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void render(GuiGraphics graphics, DeltaTracker deltaTracker) {
|
|
||||||
if(Minecraft.getInstance().player == null) return;
|
|
||||||
Entity entity = Minecraft.getInstance().player.getRootVehicle();
|
|
||||||
|
|
||||||
Vec3 vec = new Vec3(
|
|
||||||
entity.getX() - entity.xOld,
|
|
||||||
entity.getY() - entity.yOld,
|
|
||||||
entity.getZ() - entity.zOld
|
|
||||||
);
|
|
||||||
|
|
||||||
double yOffset = 0D;
|
|
||||||
double xOffset = 0D;
|
|
||||||
double zOffset = 0D;
|
|
||||||
double vOffset = 0D;
|
|
||||||
|
|
||||||
double speed = (Math.sqrt(Math.pow(vec.x + xOffset, 2) + Math.pow(vec.y + yOffset, 2) + Math.pow(vec.z + zOffset, 2)) * 20)+vOffset;
|
|
||||||
double lSpeed = speed;
|
|
||||||
|
|
||||||
if (speeds.size() >= 30) {
|
|
||||||
speeds.removeFirst();
|
|
||||||
}
|
|
||||||
speeds.add(speed);
|
|
||||||
speed = 0;
|
|
||||||
for (Double aDouble : speeds) {
|
|
||||||
speed += aDouble;
|
|
||||||
}
|
|
||||||
speed = speed / speeds.size();
|
|
||||||
|
|
||||||
double speedTypeSpeed;
|
|
||||||
|
|
||||||
SpeedTypes speedType = Config.getSpeedType();
|
|
||||||
if (speedType == SpeedTypes.KNOT || (entity instanceof Boat && Config.getUseKnot())) {
|
|
||||||
speedTypeSpeed = speed * 1.94384449;
|
|
||||||
}else if (speedType == SpeedTypes.KMPH) {
|
|
||||||
speedTypeSpeed = speed * 3.6;
|
|
||||||
} else if (speedType == SpeedTypes.MPH) {
|
|
||||||
speedTypeSpeed = speed * 2.23693629;
|
|
||||||
}else {
|
|
||||||
speedTypeSpeed = speed;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String format = String.format("%.2f", speedTypeSpeed);
|
private static void render(GuiGraphics graphics, DeltaTracker deltaTracker) {
|
||||||
|
if(Minecraft.getInstance().player == null) return;
|
||||||
|
if(Minecraft.getInstance().options.hideGui) return;
|
||||||
|
Entity entity = Minecraft.getInstance().player.getRootVehicle();
|
||||||
|
|
||||||
String speedString = format + " " + SpeedTypes.getName(speedType).getString();
|
Vec3 vec = new Vec3(
|
||||||
|
entity.getX() - entity.xOld,
|
||||||
int width = switch ((Config.getVisualSpeedometer() && !Config.isDisableVisualSpeedometer()) ? 1 : 0){
|
entity.getY() - entity.yOld,
|
||||||
case 1 -> Config.getImageSize();
|
entity.getZ() - entity.zOld
|
||||||
case 0 -> Minecraft.getInstance().font.width(speedString);
|
|
||||||
default -> 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
int yPos = getPos(graphics, width, Config.getYPosition(), false);
|
|
||||||
int xPos = getPos(graphics, width, Config.getXPosition(), true);
|
|
||||||
|
|
||||||
int lineHeight = Minecraft.getInstance().font.lineHeight;
|
|
||||||
|
|
||||||
if(Config.getVisualSpeedometer() && !Config.isDisableVisualSpeedometer()){
|
|
||||||
|
|
||||||
//double v = speedTypeSpeed / speedType.gatMaxVisual();
|
|
||||||
|
|
||||||
BufferedImage img = ImageHandler.scale(ICON.getSpeedometerIcon(speedTypeSpeed), Config.getImageSize(), Config.getImageSize());
|
|
||||||
|
|
||||||
/*int radius = img.getWidth()/2-4;
|
|
||||||
|
|
||||||
int x3 = (int) Math.round(radius*Math.cos(Math.toRadians(i+90)))+(img.getWidth()/2);
|
|
||||||
int y3 = (int) Math.round(radius*Math.sin(Math.toRadians(i+90)))+(img.getHeight()/2);
|
|
||||||
|
|
||||||
Graphics2D g2d = img.createGraphics();
|
|
||||||
|
|
||||||
g2d.setColor(new Color(138, 0, 0));
|
|
||||||
|
|
||||||
g2d.setStroke(new BasicStroke(2));
|
|
||||||
|
|
||||||
g2d.drawLine(x3,y3,img.getWidth()/2,img.getHeight()/2);
|
|
||||||
|
|
||||||
for(int x1 = 0; x1 < img.getWidth(); x1++){
|
|
||||||
for(int y1 = 0; y1 < img.getHeight(); y1++){
|
|
||||||
int x2 = x1 + xPos - img.getWidth();
|
|
||||||
int y2 = y1 + yPos - img.getHeight();
|
|
||||||
|
|
||||||
int rgb = img.getRGB(x1, y1);
|
|
||||||
|
|
||||||
if(new Color(rgb).equals(Color.black)) continue;
|
|
||||||
|
|
||||||
graphics.fill(x2, y2, x2+1, y2+1, rgb);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(i >= 360+45){
|
|
||||||
String string = "x" + (int)Math.floor(i/(365+45));
|
|
||||||
graphics.drawString(
|
|
||||||
Minecraft.getInstance().font,
|
|
||||||
string,
|
|
||||||
xPos-Minecraft.getInstance().font.width(string),
|
|
||||||
(int)(yPos-4.5-((double) Config.getImageSize() /2)),
|
|
||||||
new Color(138, 0, 0).getRGB()
|
|
||||||
);
|
);
|
||||||
}*/
|
|
||||||
for(int x1 = 0; x1 < img.getWidth(); x1++){
|
|
||||||
for(int y1 = 0; y1 < img.getHeight(); y1++){
|
|
||||||
int x2 = x1 + xPos - img.getWidth();
|
|
||||||
int y2 = y1 + yPos - img.getHeight();
|
|
||||||
|
|
||||||
int rgb = img.getRGB(x1, y1);
|
double yOffset = 0D;
|
||||||
|
double xOffset = 0D;
|
||||||
|
double zOffset = 0D;
|
||||||
|
double vOffset = 0D;
|
||||||
|
|
||||||
if(new Color(rgb).equals(Color.black)) continue;
|
double speed = (Math.sqrt(Math.pow(vec.x + xOffset, 2) + Math.pow(vec.y + yOffset, 2) + Math.pow(vec.z + zOffset, 2)) * 20)+vOffset;
|
||||||
|
double lSpeed = speed;
|
||||||
|
|
||||||
graphics.fill(x2, y2, x2+1, y2+1, rgb);
|
if (speeds.size() >= 30) {
|
||||||
|
speeds.removeFirst();
|
||||||
}
|
}
|
||||||
}
|
speeds.add(speed);
|
||||||
|
speed = 0;
|
||||||
}else {
|
for (Double aDouble : speeds) {
|
||||||
// i -> x
|
speed += aDouble;
|
||||||
// j -> y
|
}
|
||||||
// k -> color RGB int
|
speed = speed / speeds.size();
|
||||||
graphics.drawString(
|
|
||||||
Minecraft.getInstance().font,
|
double speedTypeSpeed;
|
||||||
speedString,
|
|
||||||
xPos - width,
|
SpeedTypes speedType = Config.getSpeedType();
|
||||||
yPos - lineHeight,
|
if (speedType == SpeedTypes.KNOT || (entity instanceof Boat && Config.getUseKnot())) {
|
||||||
Config.getColor().getRGB()
|
speedTypeSpeed = speed * 1.94384449;
|
||||||
);
|
}else if (speedType == SpeedTypes.KMPH) {
|
||||||
}
|
speedTypeSpeed = speed * 3.6;
|
||||||
|
} else if (speedType == SpeedTypes.MPH) {
|
||||||
if(Config.isDebug()){
|
speedTypeSpeed = speed * 2.23693629;
|
||||||
String debugData = "Velocity raw:" + "\n" +
|
}else {
|
||||||
" X: " + vec.x + "\n" +
|
speedTypeSpeed = speed;
|
||||||
" Y: " + vec.y + "\n" +
|
}
|
||||||
" Z: " + vec.z + "\n" +
|
|
||||||
"Offsets:" + "\n" +
|
String format = String.format("%.2f", speedTypeSpeed);
|
||||||
" X: " + xOffset + "\n" +
|
|
||||||
" Y: " + yOffset + "\n" +
|
String speedString = format + " " + SpeedTypes.getName(speedType).getString();
|
||||||
" Z: " + zOffset + "\n" +
|
|
||||||
" Total: " + vOffset + "\n" +
|
int width = switch ((Config.getVisualSpeedometer() && !Config.isDisableVisualSpeedometer()) ? 1 : 0){
|
||||||
"Velocity modified:" + "\n" +
|
case 1 -> Config.getImageSize();
|
||||||
" X: " + (vec.x + xOffset) + "\n" +
|
case 0 -> Minecraft.getInstance().font.width(speedString);
|
||||||
" Y: " + (vec.y + yOffset) + "\n" +
|
default -> 0;
|
||||||
" Z: " + (vec.z + zOffset) + "\n" +
|
};
|
||||||
" Total: " + lSpeed + "\n" +
|
|
||||||
"Velocity total average: " + speed + "\n" +
|
int yPos = getPosImp(graphics, width, Config.getYPosition(), false);
|
||||||
"Velocity total in " + speedType.name() + ": " + speedTypeSpeed + "\n" +
|
int xPos = getPosImp(graphics, width, Config.getXPosition(), true);
|
||||||
"Endpoint position: (" + Debuger.x + ", " + Debuger.y + ")\n" +
|
|
||||||
"Percentage point of visual speedometer: " + Debuger.angle + "\n" +
|
int lineHeight = Minecraft.getInstance().font.lineHeight;
|
||||||
(Config.getVisualSpeedometer()?"Visual Size: "+Config.getImageSize():"Textual display");
|
|
||||||
|
if(Config.getVisualSpeedometer() && !Config.isDisableVisualSpeedometer()){
|
||||||
Color color = new Color(255, 255, 255);
|
|
||||||
|
//double v = speedTypeSpeed / speedType.gatMaxVisual();
|
||||||
int y = 0;
|
|
||||||
for(String s : debugData.split("\n")){
|
BufferedImage img = ImageHandler.scale(ICON.getSpeedometerIcon(speedTypeSpeed), Config.getImageSize(), Config.getImageSize());
|
||||||
drawString(graphics,0, y, s, color.getRGB());
|
|
||||||
y+=Minecraft.getInstance().font.lineHeight+1;
|
for(int x1 = 0; x1 < img.getWidth(); x1++){
|
||||||
}
|
for(int y1 = 0; y1 < img.getHeight(); y1++){
|
||||||
}
|
int x2 = x1 + xPos - img.getWidth();
|
||||||
}
|
int y2 = y1 + yPos - img.getHeight();
|
||||||
|
|
||||||
private static void drawString(GuiGraphics graphics, int x, int y, String text, int colorRGB){
|
int rgb = img.getRGB(x1, y1);
|
||||||
graphics.drawString(
|
|
||||||
Minecraft.getInstance().font,
|
if(new Color(rgb).equals(Color.black)) continue;
|
||||||
text,
|
|
||||||
x,
|
graphics.fill(x2, y2, x2+1, y2+1, rgb);
|
||||||
y,
|
}
|
||||||
colorRGB
|
}
|
||||||
);
|
|
||||||
}
|
}else {
|
||||||
|
// i -> x
|
||||||
private static int getPos(GuiGraphics event, int width, String input, boolean isXPosition) {
|
// j -> y
|
||||||
ArrayList<String> passerPose = new ArrayList<>();
|
// k -> color RGB int
|
||||||
final char[] s = input.toCharArray();
|
graphics.drawString(
|
||||||
|
Minecraft.getInstance().font,
|
||||||
try{
|
speedString,
|
||||||
for(int i = 0; i <s.length; i++){
|
xPos - width,
|
||||||
if(s[i] == 'W' || s[i] == 'H'){
|
yPos - lineHeight,
|
||||||
if(isXPosition) passerPose.add(String.valueOf(event.guiWidth()));
|
Config.getColor().getRGB()
|
||||||
else passerPose.add(String.valueOf(event.guiHeight()));
|
);
|
||||||
}else if(s[i] == 'h' || s[i] == 'w'){
|
}
|
||||||
if(isXPosition) passerPose.add(String.valueOf(event.guiWidth() / 2));
|
|
||||||
else passerPose.add(String.valueOf(event.guiHeight() / 2));
|
if(Config.isDebug()){
|
||||||
}else if(s[i] == 'S' || s[i] == 's'){
|
String debugData = "Speedometer: "+VERSION+"\n"+
|
||||||
passerPose.add(String.valueOf(width));
|
"Velocity raw:" + "\n" +
|
||||||
}else if(s[i] == '+'){
|
" X: " + vec.x + "\n" +
|
||||||
passerPose.add("+");
|
" Y: " + vec.y + "\n" +
|
||||||
}else if(s[i] == '-'){
|
" Z: " + vec.z + "\n" +
|
||||||
passerPose.add("-");
|
"Offsets:" + "\n" +
|
||||||
}else if(s[i] == '*'){
|
" X: " + xOffset + "\n" +
|
||||||
passerPose.add("/");
|
" Y: " + yOffset + "\n" +
|
||||||
}else if(s[i] == '/'){
|
" Z: " + zOffset + "\n" +
|
||||||
passerPose.add("/");
|
" Total: " + vOffset + "\n" +
|
||||||
}else if(Character.isDigit(s[i])){
|
"Velocity modified:" + "\n" +
|
||||||
try{
|
" X: " + (vec.x + xOffset) + "\n" +
|
||||||
if(i-1 > 0 && passerPose.get(i - 1).matches("^[0-9]+$")) {
|
" Y: " + (vec.y + yOffset) + "\n" +
|
||||||
Integer.parseInt(passerPose.get(i - 1));
|
" Z: " + (vec.z + zOffset) + "\n" +
|
||||||
passerPose.add(i - 1, passerPose.get(i - 1) + s[i]);
|
" Total: " + lSpeed + "\n" +
|
||||||
}
|
"Velocity total average: " + speed + "\n" +
|
||||||
else
|
"Velocity total in " + speedType.name() + ": " + speedTypeSpeed + "\n" +
|
||||||
{
|
"Endpoint position: (" + Debugger.x + ", " + Debugger.y + ")\n" +
|
||||||
passerPose.add(Character.toString(s[i]));
|
"Percentage point of visual speedometer: " + Debugger.angle + "\n" +
|
||||||
}
|
(Config.getVisualSpeedometer()?"Visual Size: "+Config.getImageSize():"Textual display");
|
||||||
}catch (NumberFormatException e){
|
|
||||||
passerPose.add(Character.toString(s[i]));
|
Color color = new Color(255, 255, 255);
|
||||||
}
|
|
||||||
}else{
|
int y = 0;
|
||||||
throw new Exception();
|
for(String s : debugData.split("\n")){
|
||||||
|
drawString(graphics,0, y, s, color.getRGB());
|
||||||
|
y+=Minecraft.getInstance().font.lineHeight+1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}catch (Exception e){
|
|
||||||
passerPose.clear();
|
|
||||||
defaultValues(event, isXPosition, passerPose);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
private static void drawString(GuiGraphics graphics, int x, int y, String text, int colorRGB){
|
||||||
|
graphics.drawString(
|
||||||
int position;
|
Minecraft.getInstance().font,
|
||||||
try{
|
text,
|
||||||
position = Integer.parseInt(passerPose.getFirst());
|
x,
|
||||||
}catch (NumberFormatException e){
|
y,
|
||||||
defaultValues(event, isXPosition, passerPose);
|
colorRGB
|
||||||
position = Integer.parseInt(passerPose.getFirst());
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 1; i < passerPose.size(); i++){
|
private static int getPosImp(GuiGraphics event, int width, String input, boolean isXPosition){
|
||||||
boolean first = false;
|
input = input.trim();
|
||||||
String s1 = passerPose.get(i);
|
input = input
|
||||||
String s2 = "";
|
.replaceAll("(W+)|(H+)", String.valueOf(isXPosition?event.guiWidth():event.guiHeight()))
|
||||||
try{
|
.replaceAll("(w+)|(h+)", String.valueOf(isXPosition?event.guiWidth()/2:event.guiHeight()/2))
|
||||||
s2 = passerPose.get(i+1);
|
.replaceAll("(S+)|(s+)", String.valueOf(width));
|
||||||
}catch (Exception e){
|
if((Config.isDebug()) && Config.getCounter() < 2) {
|
||||||
first = true;
|
//String speedDisplayType = SpeedTypes.getName(Config.getSpeedType()).getString();
|
||||||
}
|
//String splitRawSpeedPosition = Arrays.toString(passerPose.toArray());
|
||||||
|
//String rawSpeedPosition = isXPosition ? Config.getXPosition() : Config.getYPosition();
|
||||||
|
LOGGER.info("Selected speed type(DEBUG): {}\n{}\n\n\n", isXPosition, input);
|
||||||
|
Config.addCounter();
|
||||||
|
}
|
||||||
|
return getPos(event, width, input, isXPosition);
|
||||||
|
}
|
||||||
|
|
||||||
if(Objects.equals(s1, "+") && !first){
|
private static int getPos(GuiGraphics event, int width, String input, boolean isXPosition) {
|
||||||
position += Integer.parseInt(s2);
|
ArrayList<String> tokens = new ArrayList<>();
|
||||||
}else if(Objects.equals(s1, "-") && !first){
|
final char[] s = input.toCharArray();
|
||||||
position -= Integer.parseInt(s2);
|
|
||||||
}else if(Objects.equals(s1, "*") && !first){
|
|
||||||
position *= Integer.parseInt(s2);
|
|
||||||
}else if(Objects.equals(s1, "/") && !first){
|
|
||||||
position /= Integer.parseInt(s2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if((Config.isDebug()) && Config.getCounter() < 2) {
|
|
||||||
String speedDisplayType = SpeedTypes.getName(Config.getSpeedType()).getString();
|
|
||||||
String splitRawSpeedPosition = Arrays.toString(passerPose.toArray());
|
|
||||||
String rawSpeedPosition = isXPosition ? Config.getXPosition() : Config.getYPosition();
|
|
||||||
LOGGER.info("Selected speed type: {}\n{}\n\n{}\n\n{}", speedDisplayType, splitRawSpeedPosition, position, rawSpeedPosition);
|
|
||||||
Config.addCounter();
|
|
||||||
}
|
|
||||||
return position;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void defaultValues(GuiGraphics event, boolean isXPosition, ArrayList<String> passerPose) {
|
try{
|
||||||
if(isXPosition)
|
for(int i = 0; i <s.length; i++){
|
||||||
{
|
char c = s[i];
|
||||||
passerPose.add(String.valueOf(event.guiWidth()));
|
if(c == '+' ||
|
||||||
passerPose.add("-");
|
c == '-' ||
|
||||||
passerPose.add("3");
|
c == '*' ||
|
||||||
|
c == '/'){
|
||||||
|
tokens.add(Character.toString(c));
|
||||||
|
}
|
||||||
|
else if(Character.isDigit(c)){
|
||||||
|
int lastIndex = i - 1;
|
||||||
|
if(lastIndex >= 0 && tokens.get(lastIndex).matches("^[0-9]+$")) {
|
||||||
|
tokens.set(tokens.size() - 1, tokens.get(tokens.size() - 1) + c);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tokens.add(Character.toString(c));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
throw new IllegalArgumentException("Invalid character in input string: " + c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
tokens.clear();
|
||||||
|
defaultValues(event, isXPosition, tokens);
|
||||||
|
}
|
||||||
|
|
||||||
|
int position;
|
||||||
|
try{
|
||||||
|
position = Integer.parseInt(tokens.getFirst());
|
||||||
|
}catch (NumberFormatException e){
|
||||||
|
tokens.clear();
|
||||||
|
defaultValues(event, isXPosition, tokens);
|
||||||
|
position = Integer.parseInt(tokens.getFirst());
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i = 1; i < tokens.size(); i+=2){
|
||||||
|
String operator = tokens.get(i);
|
||||||
|
if(i + 1 >= tokens.size()) {
|
||||||
|
LOGGER.error("Invalid expression: missing operand after operator '{}'", operator);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
String operand = tokens.get(i + 1);
|
||||||
|
int value;
|
||||||
|
try {
|
||||||
|
value = Integer.parseInt(operand);
|
||||||
|
}
|
||||||
|
catch (NumberFormatException e) {
|
||||||
|
LOGGER.error("Invalid operand: '{}'. Using default value. REPORT THIS! https://github.com/zaze06/Speedometer/issues/new/choose", operand);
|
||||||
|
Minecraft.getInstance().emergencySaveAndCrash(new CrashReport("Invalid operand in speedometer position calculation. REPORT THIS! https://github.com/zaze06/Speedometer/issues/new/choose", e));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (operator) {
|
||||||
|
case "+" -> position += value;
|
||||||
|
case "-" -> position -= value;
|
||||||
|
case "*" -> position *= value;
|
||||||
|
case "/" -> position /= value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Config.isDebug() && Config.getCounter() < 2) {
|
||||||
|
LOGGER.info("Selected speed type: {}\n{}\n\n{}\n\n{}",
|
||||||
|
SpeedTypes.getName(Config.getSpeedType()).getString(),
|
||||||
|
Arrays.toString(tokens.toArray()),
|
||||||
|
position,
|
||||||
|
isXPosition ? Config.getXPosition() : Config.getYPosition());
|
||||||
|
Config.addCounter();
|
||||||
|
}
|
||||||
|
|
||||||
|
return position;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
private static void defaultValues(GuiGraphics event, boolean isXPosition, ArrayList<String> passerPose) {
|
||||||
passerPose.add(String.valueOf(event.guiHeight()));
|
if(isXPosition)
|
||||||
passerPose.add("-");
|
{
|
||||||
passerPose.add("3");
|
passerPose.add(String.valueOf(event.guiWidth()));
|
||||||
|
passerPose.add("-");
|
||||||
|
passerPose.add("3");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
passerPose.add(String.valueOf(event.guiHeight()));
|
||||||
|
passerPose.add("-");
|
||||||
|
passerPose.add("3");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package me.zacharias.speedometer;
|
package me.zacharias.speedometer;
|
||||||
|
|
||||||
import dev.architectury.platform.Platform;
|
import dev.architectury.platform.Platform;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
@@ -32,7 +31,7 @@ public class Config {
|
|||||||
}
|
}
|
||||||
config = new JSONObject();
|
config = new JSONObject();
|
||||||
|
|
||||||
defualt();
|
defaultValues();
|
||||||
}else {
|
}else {
|
||||||
try {
|
try {
|
||||||
BufferedReader in = new BufferedReader(new FileReader(configFile));
|
BufferedReader in = new BufferedReader(new FileReader(configFile));
|
||||||
@@ -62,7 +61,7 @@ public class Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
config = new JSONObject();
|
config = new JSONObject();
|
||||||
defualt();
|
defaultValues();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,20 +71,20 @@ public class Config {
|
|||||||
if(config.getFloat("version")!=configVersion){
|
if(config.getFloat("version")!=configVersion){
|
||||||
if(config.getFloat("version") > configVersion){
|
if(config.getFloat("version") > configVersion){
|
||||||
LOGGER.warn("Config version is too new, resting");
|
LOGGER.warn("Config version is too new, resting");
|
||||||
defualt();
|
defaultValues();
|
||||||
|
|
||||||
save();
|
save();
|
||||||
}else if(config.getFloat("version") < configVersion){
|
}else if(config.getFloat("version") < configVersion){
|
||||||
config = new JSONObject();
|
config = new JSONObject();
|
||||||
LOGGER.warn("Config version is outdated, resting");
|
LOGGER.warn("Config version is outdated, resting");
|
||||||
|
|
||||||
defualt();
|
defaultValues();
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
config = new JSONObject();
|
config = new JSONObject();
|
||||||
defualt();
|
defaultValues();
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@@ -94,7 +93,7 @@ public class Config {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void defualt() {
|
private static void defaultValues() {
|
||||||
if(!config.has("speed")) {
|
if(!config.has("speed")) {
|
||||||
config.put("speed", SpeedTypes.BlockPS);
|
config.put("speed", SpeedTypes.BlockPS);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,9 +23,7 @@ public class ConfigMenu {
|
|||||||
);
|
);
|
||||||
|
|
||||||
category.addEntry(entryBuilder.startColorField(Component.translatable("speedometer.config.color"), me.zacharias.speedometer.Config.getColorRGB())
|
category.addEntry(entryBuilder.startColorField(Component.translatable("speedometer.config.color"), me.zacharias.speedometer.Config.getColorRGB())
|
||||||
.setSaveConsumer2(color -> {
|
.setSaveConsumer2(color -> Config.setColor(color.getRed(), color.getGreen(), color.getBlue()))
|
||||||
me.zacharias.speedometer.Config.setColor(color.getRed(), color.getGreen(), color.getBlue());
|
|
||||||
})
|
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package me.zacharias.speedometer;
|
package me.zacharias.speedometer;
|
||||||
|
|
||||||
public class Debuger {
|
public class Debugger {
|
||||||
public static double angle;
|
public static double angle;
|
||||||
public static double x;
|
public static double x;
|
||||||
public static double y;
|
public static double y;
|
||||||
@@ -3,17 +3,11 @@ package me.zacharias.speedometer;
|
|||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
|
||||||
public enum SpeedTypes {
|
public enum SpeedTypes {
|
||||||
MPH(20),
|
MPH,
|
||||||
KMPH(200),
|
KMPH,
|
||||||
MPS(10),
|
MPS,
|
||||||
BlockPS(10),
|
BlockPS,
|
||||||
KNOT(20);
|
KNOT;
|
||||||
|
|
||||||
private final int maxVisual;
|
|
||||||
|
|
||||||
SpeedTypes(int maxVisual){
|
|
||||||
this.maxVisual = maxVisual;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Component getName(Enum anEnum) {
|
public static Component getName(Enum anEnum) {
|
||||||
if(anEnum instanceof SpeedTypes speedType) {
|
if(anEnum instanceof SpeedTypes speedType) {
|
||||||
@@ -28,8 +22,4 @@ public enum SpeedTypes {
|
|||||||
return Component.translatable("speedometer.speed.error");
|
return Component.translatable("speedometer.speed.error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int gatMaxVisual() {
|
|
||||||
return maxVisual;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,6 @@ package me.zacharias.speedometer;
|
|||||||
import dev.architectury.platform.Platform;
|
import dev.architectury.platform.Platform;
|
||||||
import dev.architectury.utils.Env;
|
import dev.architectury.utils.Env;
|
||||||
|
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.packs.resources.Resource;
|
import net.minecraft.server.packs.resources.Resource;
|
||||||
import net.minecraft.server.packs.resources.ResourceManager;
|
import net.minecraft.server.packs.resources.ResourceManager;
|
||||||
@@ -64,8 +63,7 @@ public class Speedometer
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try(BufferedReader stream = resource.get().openAsReader()) {
|
||||||
BufferedReader stream = resource.get().openAsReader();
|
|
||||||
String tmp;
|
String tmp;
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
while ((tmp = stream.readLine()) != null) {
|
while ((tmp = stream.readLine()) != null) {
|
||||||
|
|||||||
@@ -10,14 +10,11 @@ import org.json.JSONObject;
|
|||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import static me.zacharias.speedometer.Speedometer.MOD_ID;
|
|
||||||
|
|
||||||
public class SpeedometerIcon {
|
public class SpeedometerIcon {
|
||||||
private BufferedImage speedometerIcon;
|
private BufferedImage speedometerIcon;
|
||||||
private Pointer pointer;
|
private Pointer pointer;
|
||||||
@@ -169,7 +166,7 @@ class Pointer
|
|||||||
}
|
}
|
||||||
double angle = ((speed/max) * end)+start;
|
double angle = ((speed/max) * end)+start;
|
||||||
if(angle > end && !overflow) angle = end;
|
if(angle > end && !overflow) angle = end;
|
||||||
Debuger.angle = angle;
|
Debugger.angle = angle;
|
||||||
|
|
||||||
if(Objects.nonNull(image))
|
if(Objects.nonNull(image))
|
||||||
{
|
{
|
||||||
@@ -183,8 +180,8 @@ class Pointer
|
|||||||
double angleRads = Math.toRadians(180+angle);
|
double angleRads = Math.toRadians(180+angle);
|
||||||
int endX = (int) (Math.cos(angleRads) * length + this.start.x);
|
int endX = (int) (Math.cos(angleRads) * length + this.start.x);
|
||||||
int endY = (int) (Math.sin(angleRads) * length + this.start.y);
|
int endY = (int) (Math.sin(angleRads) * length + this.start.y);
|
||||||
Debuger.x = endX;
|
Debugger.x = endX;
|
||||||
Debuger.y = endY;
|
Debugger.y = endY;
|
||||||
|
|
||||||
g2d.setColor(c);
|
g2d.setColor(c);
|
||||||
g2d.setStroke(new BasicStroke(3, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
|
g2d.setStroke(new BasicStroke(3, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
|
||||||
|
|||||||
@@ -68,7 +68,8 @@
|
|||||||
|
|
||||||
"speedometer.config.error.size_outofbounds": "The size is out of bounds 10<=size<=300",
|
"speedometer.config.error.size_outofbounds": "The size is out of bounds 10<=size<=300",
|
||||||
|
|
||||||
"speedometer.error.missing_cloth": "Missing Cloth Config API for Config Screen",
|
"speedometer.error.missing_cloth": "Missing Cloth Config API for Config Screen, ",
|
||||||
|
"speedometer.error.missing_cloth.open_config": "Open Config",
|
||||||
|
|
||||||
"resourcepack.speedometer.quarter_circle_speedometer": "Quarter circle Speedometer"
|
"resourcepack.speedometer.quarter_circle_speedometer": "Quarter circle Speedometer"
|
||||||
}
|
}
|
||||||
@@ -68,7 +68,8 @@
|
|||||||
|
|
||||||
"speedometer.config.error.size_outofbounds": "Stolekten är felakting 10<=stolek<=300",
|
"speedometer.config.error.size_outofbounds": "Stolekten är felakting 10<=stolek<=300",
|
||||||
|
|
||||||
"speedometer.error.missing_cloth": "Saknar Cloth Config API för konfigurationsskärmen",
|
"speedometer.error.missing_cloth": "Saknar Cloth Config API för konfigurationsskärmen, ",
|
||||||
|
"speedometer.error.missing_cloth.open_config": "Öppna Config",
|
||||||
|
|
||||||
"resourcepack.speedometer.quarter_circle_speedometer": "Quarter circle Speedometer"
|
"resourcepack.speedometer.quarter_circle_speedometer": "Quarter circle Speedometer"
|
||||||
}
|
}
|
||||||
@@ -23,12 +23,12 @@ repositories {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
|
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
|
||||||
modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}"
|
modApi "net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}+${rootProject.minecraft_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-fabric:${rootProject.architectury_version}"
|
modApi "dev.architectury:architectury-fabric:${rootProject.architectury_version}"
|
||||||
|
|
||||||
modApi "me.shedaniel.cloth:cloth-config-fabric:${rootProject.cloth_config_version}"
|
modApi "me.shedaniel.cloth:cloth-config-fabric:${rootProject.cloth_config_version}"
|
||||||
modApi "com.terraformersmc:modmenu:11.0.0"
|
modApi "com.terraformersmc:modmenu:${rootProject.modmenu_version}"
|
||||||
modApi "eu.pb4:placeholder-api:2.4.0-pre.2+1.21"
|
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 }
|
||||||
|
|||||||
@@ -3,23 +3,11 @@ 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.fabricmc.fabric.api.resource.ResourceManagerHelper;
|
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
|
||||||
import net.fabricmc.fabric.api.resource.ResourcePackActivationType;
|
|
||||||
import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener;
|
import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener;
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
|
||||||
import net.fabricmc.loader.api.ModContainer;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.packs.PackType;
|
import net.minecraft.server.packs.PackType;
|
||||||
import net.minecraft.server.packs.repository.RepositorySource;
|
|
||||||
import net.minecraft.server.packs.resources.ResourceManager;
|
import net.minecraft.server.packs.resources.ResourceManager;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import static me.zacharias.speedometer.Speedometer.LOGGER;
|
|
||||||
import static me.zacharias.speedometer.Speedometer.MOD_ID;
|
|
||||||
|
|
||||||
public class SpeedometerFabric implements ModInitializer {
|
public class SpeedometerFabric implements ModInitializer {
|
||||||
@Override
|
@Override
|
||||||
public void onInitialize() {
|
public void onInitialize() {
|
||||||
|
|||||||
@@ -21,9 +21,9 @@
|
|||||||
"depends": {
|
"depends": {
|
||||||
"fabricloader": ">=0.15.11",
|
"fabricloader": ">=0.15.11",
|
||||||
"minecraft": ">=1.21",
|
"minecraft": ">=1.21",
|
||||||
"architectury": ">=13.0.1"
|
"architectury": ">=13.0.5"
|
||||||
},
|
},
|
||||||
"suggests": {
|
"suggests": {
|
||||||
"cloth-config1": ">=15.0.127"
|
"cloth-config1": ">=15.0.140"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
{
|
{
|
||||||
"homepage": "https://modrinth.com/mod/speedometer/versions",
|
"homepage": "https://modrinth.com/mod/speedometer/versions",
|
||||||
|
"1.17.1": {
|
||||||
|
"6.2.4": "Backport by request from issue #3"
|
||||||
|
},
|
||||||
"1.20.6": {
|
"1.20.6": {
|
||||||
"1.0": "First version",
|
"1.0": "First version",
|
||||||
"2.0": "Made the speedometer text movable, added debug data display, added visual speedometer",
|
"2.0": "Made the speedometer text movable, added debug data display, added visual speedometer",
|
||||||
@@ -9,7 +12,8 @@
|
|||||||
"4.0": "Removed the Size part of the position string, combined the visual and text location strings, updated config version to 3, fixed bug where the text would start to drift of screen if you where too fast",
|
"4.0": "Removed the Size part of the position string, combined the visual and text location strings, updated config version to 3, fixed bug where the text would start to drift of screen if you where too fast",
|
||||||
"5.0": "Visual speed display has been added",
|
"5.0": "Visual speed display has been added",
|
||||||
"5.1": "Added second speed display",
|
"5.1": "Added second speed display",
|
||||||
"5.2": "Fixed issue #1"
|
"5.2": "Fixed issue #1",
|
||||||
|
"5.2.1": "Fixed issue #3"
|
||||||
},
|
},
|
||||||
"1.20.5": {
|
"1.20.5": {
|
||||||
"1.0": "First version",
|
"1.0": "First version",
|
||||||
@@ -20,7 +24,8 @@
|
|||||||
"4.0": "Removed the Size part of the position string, combined the visual and text location strings, updated config version to 3, fixed bug where the text would start to drift of screen if you where too fast",
|
"4.0": "Removed the Size part of the position string, combined the visual and text location strings, updated config version to 3, fixed bug where the text would start to drift of screen if you where too fast",
|
||||||
"5.0": "Visual speed display has been added",
|
"5.0": "Visual speed display has been added",
|
||||||
"5.1": "Added second speed display",
|
"5.1": "Added second speed display",
|
||||||
"5.2": "Fixed issue #1"
|
"5.2": "Fixed issue #1",
|
||||||
|
"5.2.1": "Fixed issue #3"
|
||||||
},
|
},
|
||||||
"1.20.4": {
|
"1.20.4": {
|
||||||
"1.0": "First version",
|
"1.0": "First version",
|
||||||
@@ -31,7 +36,8 @@
|
|||||||
"4.0": "Removed the Size part of the position string, combined the visual and text location strings, updated config version to 3, fixed bug where the text would start to drift of screen if you where too fast",
|
"4.0": "Removed the Size part of the position string, combined the visual and text location strings, updated config version to 3, fixed bug where the text would start to drift of screen if you where too fast",
|
||||||
"5.0": "Visual speed display has been added",
|
"5.0": "Visual speed display has been added",
|
||||||
"5.1": "Added second speed display",
|
"5.1": "Added second speed display",
|
||||||
"5.2": "Fixed issue #1"
|
"5.2": "Fixed issue #1",
|
||||||
|
"5.2.1": "Fixed issue #3"
|
||||||
},
|
},
|
||||||
"1.20.3": {
|
"1.20.3": {
|
||||||
"1.0": "First version",
|
"1.0": "First version",
|
||||||
@@ -42,7 +48,8 @@
|
|||||||
"4.0": "Removed the Size part of the position string, combined the visual and text location strings, updated config version to 3, fixed bug where the text would start to drift of screen if you where too fast",
|
"4.0": "Removed the Size part of the position string, combined the visual and text location strings, updated config version to 3, fixed bug where the text would start to drift of screen if you where too fast",
|
||||||
"5.0": "Visual speed display has been added",
|
"5.0": "Visual speed display has been added",
|
||||||
"5.1": "Added second speed display",
|
"5.1": "Added second speed display",
|
||||||
"5.2": "Fixed issue #1"
|
"5.2": "Fixed issue #1",
|
||||||
|
"5.2.1": "Fixed issue #3"
|
||||||
},
|
},
|
||||||
"1.20.2": {
|
"1.20.2": {
|
||||||
"1.0": "First version",
|
"1.0": "First version",
|
||||||
@@ -53,7 +60,8 @@
|
|||||||
"4.0": "Removed the Size part of the position string, combined the visual and text location strings, updated config version to 3, fixed bug where the text would start to drift of screen if you where too fast",
|
"4.0": "Removed the Size part of the position string, combined the visual and text location strings, updated config version to 3, fixed bug where the text would start to drift of screen if you where too fast",
|
||||||
"5.0": "Visual speed display has been added",
|
"5.0": "Visual speed display has been added",
|
||||||
"5.1": "Added second speed display",
|
"5.1": "Added second speed display",
|
||||||
"5.2": "Fixed issue #1"
|
"5.2": "Fixed issue #1",
|
||||||
|
"5.2.1": "Fixed issue #3"
|
||||||
},
|
},
|
||||||
"1.20.1": {
|
"1.20.1": {
|
||||||
"1.0": "First version",
|
"1.0": "First version",
|
||||||
@@ -64,7 +72,8 @@
|
|||||||
"4.0": "Removed the Size part of the position string, combined the visual and text location strings, updated config version to 3, fixed bug where the text would start to drift of screen if you where too fast",
|
"4.0": "Removed the Size part of the position string, combined the visual and text location strings, updated config version to 3, fixed bug where the text would start to drift of screen if you where too fast",
|
||||||
"5.0": "Visual speed display has been added",
|
"5.0": "Visual speed display has been added",
|
||||||
"5.1": "Added second speed display",
|
"5.1": "Added second speed display",
|
||||||
"5.2": "Fixed issue #1"
|
"5.2": "Fixed issue #1",
|
||||||
|
"5.2.1": "Fixed issue #3"
|
||||||
},
|
},
|
||||||
"1.20": {
|
"1.20": {
|
||||||
"1.0": "First version",
|
"1.0": "First version",
|
||||||
@@ -75,7 +84,8 @@
|
|||||||
"4.0": "Removed the Size part of the position string, combined the visual and text location strings, updated config version to 3, fixed bug where the text would start to drift of screen if you where too fast",
|
"4.0": "Removed the Size part of the position string, combined the visual and text location strings, updated config version to 3, fixed bug where the text would start to drift of screen if you where too fast",
|
||||||
"5.0": "Visual speed display has been added",
|
"5.0": "Visual speed display has been added",
|
||||||
"5.1": "Added second speed display",
|
"5.1": "Added second speed display",
|
||||||
"5.2": "Fixed issue #1"
|
"5.2": "Fixed issue #1",
|
||||||
|
"5.2.1": "Fixed issue #3"
|
||||||
},
|
},
|
||||||
"promos": {
|
"promos": {
|
||||||
"1.20.6-latest": "5.2",
|
"1.20.6-latest": "5.2",
|
||||||
@@ -97,6 +107,9 @@
|
|||||||
"1.20.1-recommended": "5.2",
|
"1.20.1-recommended": "5.2",
|
||||||
|
|
||||||
"1.20-latest": "5.2",
|
"1.20-latest": "5.2",
|
||||||
"1.20-recommended": "5.2"
|
"1.20-recommended": "5.2",
|
||||||
|
|
||||||
|
"1.17.1-latest": "6.2.4",
|
||||||
|
"1.17.1-recommended": "6.2.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,19 +1,29 @@
|
|||||||
org.gradle.jvmargs=-Xmx8G
|
org.gradle.jvmargs=-Xmx8G
|
||||||
|
|
||||||
minecraft_version=1.21.1
|
minecraft_version=1.21.6
|
||||||
|
|
||||||
archives_base_name=speedometer
|
archives_base_name=speedometer
|
||||||
mod_version=6.2
|
mod_version=6.3.0
|
||||||
maven_group=me.zacharias
|
maven_group=me.zacharias
|
||||||
|
|
||||||
architectury_version=13.0.8
|
# https://modrinth.com/mod/architectury-api/versions
|
||||||
|
architectury_version=17.0.6
|
||||||
|
|
||||||
fabric_loader_version=0.16.5
|
# https://modrinth.com/mod/cloth-config/versions
|
||||||
fabric_api_version=0.105.0+1.21.1
|
cloth_config_version = 19.0.147
|
||||||
|
|
||||||
neoforge_version = 21.1.66
|
# NeoForged Only
|
||||||
|
# https://neoforged.net/
|
||||||
|
neoforge_version = 21.6.12-beta
|
||||||
|
|
||||||
cloth_config_version = 15.0.140
|
# Fabric Only
|
||||||
|
# https://fabricmc.net/develop/
|
||||||
|
fabric_loader_version=0.16.14
|
||||||
|
fabric_api_version=0.127.1
|
||||||
|
|
||||||
|
# Fabric Only
|
||||||
|
# https://modrinth.com/mod/modmenu/versions
|
||||||
|
modmenu_version = 15.0.0-beta.3
|
||||||
|
|
||||||
# Version of the org.json json library
|
# Version of the org.json json library
|
||||||
json_version = 20240303
|
json_version = 20240303
|
||||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
|||||||
#Fri Jun 21 10:45:53 CEST 2024
|
#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-8.8-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
@@ -2,18 +2,7 @@ package me.zacharias.speedometer.forge;
|
|||||||
|
|
||||||
import com.mojang.datafixers.util.Unit;
|
import com.mojang.datafixers.util.Unit;
|
||||||
import me.zacharias.speedometer.Speedometer;
|
import me.zacharias.speedometer.Speedometer;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.server.packs.AbstractPackResources;
|
|
||||||
import net.minecraft.server.packs.PackLocationInfo;
|
|
||||||
import net.minecraft.server.packs.PackResources;
|
|
||||||
import net.minecraft.server.packs.PackType;
|
|
||||||
import net.minecraft.server.packs.repository.KnownPack;
|
|
||||||
import net.minecraft.server.packs.repository.Pack;
|
|
||||||
import net.minecraft.server.packs.repository.PackSource;
|
|
||||||
import net.minecraft.server.packs.resources.IoSupplier;
|
|
||||||
import net.minecraft.server.packs.resources.PreparableReloadListener;
|
|
||||||
import net.minecraft.server.packs.resources.ResourceManager;
|
import net.minecraft.server.packs.resources.ResourceManager;
|
||||||
import net.minecraft.server.packs.resources.SimplePreparableReloadListener;
|
import net.minecraft.server.packs.resources.SimplePreparableReloadListener;
|
||||||
import net.minecraft.util.profiling.ProfilerFiller;
|
import net.minecraft.util.profiling.ProfilerFiller;
|
||||||
@@ -23,21 +12,12 @@ import net.neoforged.bus.api.SubscribeEvent;
|
|||||||
import net.neoforged.fml.common.EventBusSubscriber;
|
import net.neoforged.fml.common.EventBusSubscriber;
|
||||||
import net.neoforged.fml.common.Mod;
|
import net.neoforged.fml.common.Mod;
|
||||||
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
|
import net.neoforged.fml.event.lifecycle.FMLClientSetupEvent;
|
||||||
import net.neoforged.neoforge.client.ClientNeoForgeMod;
|
import net.neoforged.neoforge.client.event.AddClientReloadListenersEvent;
|
||||||
import net.neoforged.neoforge.client.event.RegisterClientReloadListenersEvent;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import net.neoforged.neoforge.common.NeoForge;
|
|
||||||
import net.neoforged.neoforge.resource.ResourcePackLoader;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import java.io.InputStream;
|
import static me.zacharias.speedometer.Speedometer.MOD_ID;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
import java.util.concurrent.Executor;
|
|
||||||
|
|
||||||
import static me.zacharias.speedometer.Speedometer.*;
|
@Mod(MOD_ID)
|
||||||
|
|
||||||
@Mod(Speedometer.MOD_ID)
|
|
||||||
public class SpeedometerNeoForge {
|
public class SpeedometerNeoForge {
|
||||||
public SpeedometerNeoForge(IEventBus eventBus) {
|
public SpeedometerNeoForge(IEventBus eventBus) {
|
||||||
// Submit our event bus to let architectury register our content on the right time
|
// Submit our event bus to let architectury register our content on the right time
|
||||||
@@ -47,25 +27,25 @@ public class SpeedometerNeoForge {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventBusSubscriber(modid = Speedometer.MOD_ID, bus = EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
|
@EventBusSubscriber(modid = MOD_ID,/* bus = EventBusSubscriber.Bus.MOD, */value = Dist.CLIENT)
|
||||||
class EventHandler
|
class EventHandler
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Register the reload listener for the speedometers
|
* Register the reload listener for the speedometers
|
||||||
* This is required since i havent found how to put this in the Architecture Abstraction layer(Common module)
|
* This is required since i haven't found how to put this in the Architecture Abstraction layer(Common module)
|
||||||
* TODO: Find a way to put this in the Abstraction layer
|
* TODO: Find a way to put this in the Abstraction layer
|
||||||
* @param event The event that is fired when the client reloads resources
|
* @param event The event that is fired when the client reloads resources
|
||||||
*/
|
*/
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
private static void onResourceReload(RegisterClientReloadListenersEvent event) {
|
private static void onResourceReload(AddClientReloadListenersEvent event) {
|
||||||
event.registerReloadListener(new SimplePreparableReloadListener<Unit>() {
|
event.addListener(ResourceLocation.fromNamespaceAndPath(MOD_ID, "reload_listener"), new SimplePreparableReloadListener<Unit>() {
|
||||||
@Override
|
@Override
|
||||||
protected Unit prepare(ResourceManager arg, ProfilerFiller arg2) {
|
protected @NotNull Unit prepare(@NotNull ResourceManager arg, @NotNull ProfilerFiller arg2) {
|
||||||
return Unit.INSTANCE;
|
return Unit.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void apply(Unit object, ResourceManager resourceManager, ProfilerFiller arg2) {
|
protected void apply(@NotNull Unit object, @NotNull ResourceManager resourceManager, @NotNull ProfilerFiller arg2) {
|
||||||
Speedometer.loadSpeedometers(resourceManager);
|
Speedometer.loadSpeedometers(resourceManager);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -82,12 +82,12 @@ Just displaying your speed
|
|||||||
[[dependencies.speedometer]]
|
[[dependencies.speedometer]]
|
||||||
modId="architectury"
|
modId="architectury"
|
||||||
mandatory=true
|
mandatory=true
|
||||||
versionRange="[13.0.1,)"
|
versionRange="[13.0.5,)"
|
||||||
ordering="NONE"
|
ordering="BEFORE"
|
||||||
side="CLIENT"
|
side="CLIENT"
|
||||||
[[dependencies.speedometer]]
|
[[dependencies.speedometer]]
|
||||||
modId="cloth_config"
|
modId="cloth_config"
|
||||||
mandatory=false
|
type="optional"
|
||||||
versionRange="[15.0.127,)"
|
versionRange="[15.0.140,)"
|
||||||
ordering="NONE"
|
ordering="BEFORE"
|
||||||
side="CLIENT"
|
side="CLIENT"
|
||||||
@@ -4,10 +4,24 @@
|
|||||||
"6.0": "Lost support for Forge and gain NeoForge support",
|
"6.0": "Lost support for Forge and gain NeoForge support",
|
||||||
"6.0.1": "Small bug fix in Parser",
|
"6.0.1": "Small bug fix in Parser",
|
||||||
"6.1": "Small bug fix in Parser",
|
"6.1": "Small bug fix in Parser",
|
||||||
"6.2": "Making speedometer and pointer resource pack based"
|
"6.2": "Making speedometer and pointer resource pack based",
|
||||||
|
"6.2.1": "Fixed issue #3",
|
||||||
|
"6.2.2": "Fixed issue with multi digit position in the parser",
|
||||||
|
"6.2.3": "Fixed crash issue from 6.2.2 when playing in 1.21.4",
|
||||||
|
"6.2.4": "updated to 1.21.5",
|
||||||
|
"6.3.0": "updated to 1.21.6, Fixed bug in tokenizer"
|
||||||
},
|
},
|
||||||
"promos": {
|
"promos": {
|
||||||
"1.21-latest": "6.1",
|
"1.21-latest": "6.2.2",
|
||||||
"1.21-recommended": "6.1"
|
"1.21-recommended": "6.2.2",
|
||||||
|
|
||||||
|
"1.21.4-latest": "6.2.3",
|
||||||
|
"1.21.4-recommended": "6.2.3",
|
||||||
|
|
||||||
|
"1.21.5-latest": "6.2.4",
|
||||||
|
"1.21.5-recommended": "6.2.4",
|
||||||
|
|
||||||
|
"1.21.6-latest": "6.3.0",
|
||||||
|
"1.21.6-recommended": "6.3.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
# Speedometer
|
# Speedometer
|
||||||
This is a simple mod for forge and fabric that displays your current speed
|
This is a simple mod for Forge, Fabric, and NeoForged that displays your current speed
|
||||||
|
|
||||||
## Credits to
|
## Credits to
|
||||||
[org.json](https://www.json.org/json-en.html) *Included due to problems whit ForgeGradle*
|
[org.json](https://www.json.org/json-en.html) *Included due to problems whit Gradle and building*
|
||||||
|
|
||||||
## Compile your own version?
|
## Compile your own version?
|
||||||
1. Download source code
|
1. Download source code
|
||||||
@@ -13,8 +13,12 @@ This is a simple mod for forge and fabric that displays your current speed
|
|||||||
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)
|
||||||
4. the compiled version will be in
|
4. the compiled version will be in
|
||||||
* Fabic: `fabric/build/libs`
|
* Fabic: `fabric/build/libs`
|
||||||
|
* NeoForge: `neoforged/build/libs`
|
||||||
* Forge: `forge/build/libs`
|
* Forge: `forge/build/libs`
|
||||||
|
|
||||||
|
## Forge Support Transition
|
||||||
|
As of version 1.21 I chose to no longer support Forge in fevour of NeoForged
|
||||||
|
|
||||||
|
|
||||||
# This mod is a newer version of [speedometer-forge](https://github.com/zaze06/speedometer-forge)
|
# This mod is a newer version of [speedometer-forge](https://github.com/zaze06/speedometer-forge)
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,13 @@ This feature is supported in
|
|||||||
## `pack.mcmeta`
|
## `pack.mcmeta`
|
||||||
The mcmeta file has no differences just make sure it's a valid pack_format for the version
|
The mcmeta file has no differences just make sure it's a valid pack_format for the version
|
||||||
- 1.21.x: `"pack_format": 34`
|
- 1.21.x: `"pack_format": 34`
|
||||||
|
- I recommend adding this, so that you don't need to update the format since the only real requirement is using version 6.2 or newer of this mod
|
||||||
|
```jsonc
|
||||||
|
"supported_formats": {
|
||||||
|
"min_inclusive": 34,
|
||||||
|
"max_inclusive": 57 // This needs to be the leatest pack_format
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## File Locations
|
## File Locations
|
||||||
So the speedometer is built upon 2 main things
|
So the speedometer is built upon 2 main things
|
||||||
@@ -33,7 +40,7 @@ base
|
|||||||
```
|
```
|
||||||
|
|
||||||
## `speedometer.json` example *Standard speedometer.json file*
|
## `speedometer.json` example *Standard speedometer.json file*
|
||||||
```
|
```json
|
||||||
{
|
{
|
||||||
"background": "speedometer:meter/speedometer.png",
|
"background": "speedometer:meter/speedometer.png",
|
||||||
"start": -45,
|
"start": -45,
|
||||||
@@ -64,7 +71,7 @@ base
|
|||||||
This boolean is false if the pointer locks at the `end` angle when the speed exceeds `maxSpeed`.
|
This boolean is false if the pointer locks at the `end` angle when the speed exceeds `maxSpeed`.
|
||||||
- pointer
|
- pointer
|
||||||
This defines properties of the pointer.
|
This defines properties of the pointer.
|
||||||
- color *not required, but if not present then `ìmage` most be*
|
- color *not required, but if not present then `image` most be*
|
||||||
The color value should be a hexadecimal RGB code, e.g., #b00219, where # is followed by six characters representing red, green, and blue values (00-FF for each component).
|
The color value should be a hexadecimal RGB code, e.g., #b00219, where # is followed by six characters representing red, green, and blue values (00-FF for each component).
|
||||||
- length *not required if `image` is not defined*
|
- length *not required if `image` is not defined*
|
||||||
The length in picture based on the original size of the background.
|
The length in picture based on the original size of the background.
|
||||||
@@ -78,3 +85,10 @@ base
|
|||||||
The scale of how to modify the speed as a power, this is the speed that `maxSpeed` is based of. the way the speed passed to `maxSpeed` is calculated is `baseSpeed^scale`.
|
The scale of how to modify the speed as a power, this is the speed that `maxSpeed` is based of. the way the speed passed to `maxSpeed` is calculated is `baseSpeed^scale`.
|
||||||
- name
|
- name
|
||||||
A string that is the name of this speedometer. *This is just used to send a log message about the speedometer*
|
A string that is the name of this speedometer. *This is just used to send a log message about the speedometer*
|
||||||
|
|
||||||
|
## JSON formating help
|
||||||
|
I have created a JSON schema for this that is available at [speedometer_config_schema.json](https://github.com/zaze06/Speedometer/blob/master/schemas/speedometer_config_schema.json), please refer to your Advanced Text Editor on how to add a schema, if your editor supports the `$schema` feature then add
|
||||||
|
```json
|
||||||
|
"$schema": "https://raw.githubusercontent.com/zaze06/Speedometer/refs/heads/master/schemas/speedometer_config_schema.json",
|
||||||
|
```
|
||||||
|
in the root object, and the schema should apply, else if your editor supports it you can add the schema to all `speedometer.json` files
|
||||||
|
|||||||
Reference in New Issue
Block a user