Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
192735d352
|
|||
|
216a498d72
|
|||
|
|
d7dbf65446 | ||
|
|
3e282612a3 | ||
| 1a59e3dc2a | |||
| 1fc71a34a9 | |||
|
|
d1e5ef63ee | ||
|
|
32b6198f71 | ||
|
|
5c95f394a8 |
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": 57
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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 {
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class Client {
|
|||||||
);
|
);
|
||||||
|
|
||||||
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(){
|
public static void init(){
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ public class Client {
|
|||||||
}
|
}
|
||||||
else if(Minecraft.getInstance().player != null)
|
else if(Minecraft.getInstance().player != null)
|
||||||
{
|
{
|
||||||
Minecraft.getInstance().player.sendSystemMessage(
|
Minecraft.getInstance().player.displayClientMessage(
|
||||||
Component
|
Component
|
||||||
.translatable("speedometer.error.missing_cloth")
|
.translatable("speedometer.error.missing_cloth")
|
||||||
.withColor(new Color(190, 0, 0).getRGB())
|
.withColor(new Color(190, 0, 0).getRGB())
|
||||||
@@ -68,7 +68,7 @@ public class Client {
|
|||||||
.literal("Open Config")
|
.literal("Open Config")
|
||||||
.withStyle(ChatFormatting.UNDERLINE)
|
.withStyle(ChatFormatting.UNDERLINE)
|
||||||
.withStyle((style) -> style.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, Config.getConfigPath())))
|
.withStyle((style) -> style.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_FILE, Config.getConfigPath())))
|
||||||
));
|
), false);
|
||||||
LOGGER.warn(Component.translatable("speedometer.error.missing_cloth").getString());
|
LOGGER.warn(Component.translatable("speedometer.error.missing_cloth").getString());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -91,39 +91,6 @@ public class Client {
|
|||||||
ClientGuiEvent.RENDER_HUD.register(Client::render);
|
ClientGuiEvent.RENDER_HUD.register(Client::render);
|
||||||
|
|
||||||
LOGGER.info("Finished loading speedometer");
|
LOGGER.info("Finished loading speedometer");
|
||||||
|
|
||||||
/*((IPackRepository) Minecraft.getInstance().getResourcePackRepository()).addSource(new RepositorySource() {
|
|
||||||
@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) {
|
private static void render(GuiGraphics graphics, DeltaTracker deltaTracker) {
|
||||||
@@ -178,8 +145,8 @@ public class Client {
|
|||||||
default -> 0;
|
default -> 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
int yPos = getPos(graphics, width, Config.getYPosition(), false);
|
int yPos = getPosImp(graphics, width, Config.getYPosition(), false);
|
||||||
int xPos = getPos(graphics, width, Config.getXPosition(), true);
|
int xPos = getPosImp(graphics, width, Config.getXPosition(), true);
|
||||||
|
|
||||||
int lineHeight = Minecraft.getInstance().font.lineHeight;
|
int lineHeight = Minecraft.getInstance().font.lineHeight;
|
||||||
|
|
||||||
@@ -189,42 +156,6 @@ public class Client {
|
|||||||
|
|
||||||
BufferedImage img = ImageHandler.scale(ICON.getSpeedometerIcon(speedTypeSpeed), Config.getImageSize(), Config.getImageSize());
|
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 x1 = 0; x1 < img.getWidth(); x1++){
|
||||||
for(int y1 = 0; y1 < img.getHeight(); y1++){
|
for(int y1 = 0; y1 < img.getHeight(); y1++){
|
||||||
int x2 = x1 + xPos - img.getWidth();
|
int x2 = x1 + xPos - img.getWidth();
|
||||||
@@ -268,8 +199,8 @@ public class Client {
|
|||||||
" Total: " + lSpeed + "\n" +
|
" Total: " + lSpeed + "\n" +
|
||||||
"Velocity total average: " + speed + "\n" +
|
"Velocity total average: " + speed + "\n" +
|
||||||
"Velocity total in " + speedType.name() + ": " + speedTypeSpeed + "\n" +
|
"Velocity total in " + speedType.name() + ": " + speedTypeSpeed + "\n" +
|
||||||
"Endpoint position: (" + Debuger.x + ", " + Debuger.y + ")\n" +
|
"Endpoint position: (" + Debugger.x + ", " + Debugger.y + ")\n" +
|
||||||
"Percentage point of visual speedometer: " + Debuger.angle + "\n" +
|
"Percentage point of visual speedometer: " + Debugger.angle + "\n" +
|
||||||
(Config.getVisualSpeedometer()?"Visual Size: "+Config.getImageSize():"Textual display");
|
(Config.getVisualSpeedometer()?"Visual Size: "+Config.getImageSize():"Textual display");
|
||||||
|
|
||||||
Color color = new Color(255, 255, 255);
|
Color color = new Color(255, 255, 255);
|
||||||
@@ -292,42 +223,57 @@ public class Client {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int getPosImp(GuiGraphics event, int width, String input, boolean isXPosition){
|
||||||
|
input = input.trim();
|
||||||
|
input = input
|
||||||
|
.replaceAll("(W+)|(H+)", String.valueOf(isXPosition?event.guiWidth():event.guiHeight()))
|
||||||
|
.replaceAll("(w+)|(h+)", String.valueOf(isXPosition?event.guiWidth()/2:event.guiHeight()/2))
|
||||||
|
.replaceAll("(S+)|(s+)", String.valueOf(width));
|
||||||
|
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(DEBUG): {}\n{}\n\n\n", isXPosition, input);
|
||||||
|
Config.addCounter();
|
||||||
|
}
|
||||||
|
return getPos(event, width, input, isXPosition);
|
||||||
|
}
|
||||||
|
|
||||||
private static int getPos(GuiGraphics event, int width, String input, boolean isXPosition) {
|
private static int getPos(GuiGraphics event, int width, String input, boolean isXPosition) {
|
||||||
ArrayList<String> passerPose = new ArrayList<>();
|
ArrayList<String> passerPose = new ArrayList<>();
|
||||||
final char[] s = input.toCharArray();
|
final char[] s = input.toCharArray();
|
||||||
|
|
||||||
try{
|
try{
|
||||||
for(int i = 0; i <s.length; i++){
|
for(int i = 0; i <s.length; i++){
|
||||||
if(s[i] == 'W' || s[i] == 'H'){
|
char c = s[i];
|
||||||
|
if(c == 'W' || c == 'H'){
|
||||||
if(isXPosition) passerPose.add(String.valueOf(event.guiWidth()));
|
if(isXPosition) passerPose.add(String.valueOf(event.guiWidth()));
|
||||||
else passerPose.add(String.valueOf(event.guiHeight()));
|
else passerPose.add(String.valueOf(event.guiHeight()));
|
||||||
}else if(s[i] == 'h' || s[i] == 'w'){
|
}
|
||||||
|
else if(c == 'h' || c == 'w'){
|
||||||
if(isXPosition) passerPose.add(String.valueOf(event.guiWidth() / 2));
|
if(isXPosition) passerPose.add(String.valueOf(event.guiWidth() / 2));
|
||||||
else passerPose.add(String.valueOf(event.guiHeight() / 2));
|
else passerPose.add(String.valueOf(event.guiHeight() / 2));
|
||||||
}else if(s[i] == 'S' || s[i] == 's'){
|
}
|
||||||
|
else if(c == 'S' || c == 's'){
|
||||||
passerPose.add(String.valueOf(width));
|
passerPose.add(String.valueOf(width));
|
||||||
}else if(s[i] == '+'){
|
}
|
||||||
passerPose.add("+");
|
else if(c == '+' ||
|
||||||
}else if(s[i] == '-'){
|
c == '-' ||
|
||||||
passerPose.add("-");
|
c == '*' ||
|
||||||
}else if(s[i] == '*'){
|
c == '/'){
|
||||||
passerPose.add("/");
|
passerPose.add(Character.toString(c));
|
||||||
}else if(s[i] == '/'){
|
}
|
||||||
passerPose.add("/");
|
else if(Character.isDigit(c)){
|
||||||
}else if(Character.isDigit(s[i])){
|
int lastIndex = i - 1;
|
||||||
try{
|
if(lastIndex > 0 && passerPose.get(lastIndex).matches("^[0-9]+$")) {
|
||||||
if(i-1 > 0 && passerPose.get(i - 1).matches("^[0-9]+$")) {
|
passerPose.add(passerPose.removeLast() + c);
|
||||||
Integer.parseInt(passerPose.get(i - 1));
|
|
||||||
passerPose.add(i - 1, passerPose.get(i - 1) + s[i]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
passerPose.add(Character.toString(s[i]));
|
|
||||||
}
|
|
||||||
}catch (NumberFormatException e){
|
|
||||||
passerPose.add(Character.toString(s[i]));
|
|
||||||
}
|
}
|
||||||
}else{
|
else
|
||||||
|
{
|
||||||
|
passerPose.add(Character.toString(c));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
throw new Exception();
|
throw new Exception();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -342,6 +288,7 @@ public class Client {
|
|||||||
try{
|
try{
|
||||||
position = Integer.parseInt(passerPose.getFirst());
|
position = Integer.parseInt(passerPose.getFirst());
|
||||||
}catch (NumberFormatException e){
|
}catch (NumberFormatException e){
|
||||||
|
passerPose.clear();
|
||||||
defaultValues(event, isXPosition, passerPose);
|
defaultValues(event, isXPosition, passerPose);
|
||||||
position = Integer.parseInt(passerPose.getFirst());
|
position = Integer.parseInt(passerPose.getFirst());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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));
|
||||||
|
|||||||
@@ -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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,25 +85,25 @@
|
|||||||
"5.2.1": "Fixed issue #3"
|
"5.2.1": "Fixed issue #3"
|
||||||
},
|
},
|
||||||
"promos": {
|
"promos": {
|
||||||
"1.20.6-latest": "5.2.1",
|
"1.20.6-latest": "5.2",
|
||||||
"1.20.6-recommended": "5.2.1",
|
"1.20.6-recommended": "5.2",
|
||||||
|
|
||||||
"1.20.5-latest": "5.2.1",
|
"1.20.5-latest": "5.2",
|
||||||
"1.20.5-recommended": "5.2.1",
|
"1.20.5-recommended": "5.2",
|
||||||
|
|
||||||
"1.20.4-latest": "5.2.1",
|
"1.20.4-latest": "5.2",
|
||||||
"1.20.4-recommended": "5.2.1",
|
"1.20.4-recommended": "5.2",
|
||||||
|
|
||||||
"1.20.3-latest": "5.2.1",
|
"1.20.3-latest": "5.2",
|
||||||
"1.20.3-recommended": "5.2.1",
|
"1.20.3-recommended": "5.2",
|
||||||
|
|
||||||
"1.20.2-latest": "5.2.1",
|
"1.20.2-latest": "5.2",
|
||||||
"1.20.2-recommended": "5.2.1",
|
"1.20.2-recommended": "5.2",
|
||||||
|
|
||||||
"1.20.1-latest": "5.2.1",
|
"1.20.1-latest": "5.2",
|
||||||
"1.20.1-recommended": "5.2.1",
|
"1.20.1-recommended": "5.2",
|
||||||
|
|
||||||
"1.20-latest": "5.2.1",
|
"1.20-latest": "5.2",
|
||||||
"1.20-recommended": "5.2.1"
|
"1.20-recommended": "5.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,19 +1,29 @@
|
|||||||
org.gradle.jvmargs=-Xmx8G
|
org.gradle.jvmargs=-Xmx8G
|
||||||
|
|
||||||
minecraft_version=1.21.1
|
minecraft_version=1.21.4
|
||||||
|
|
||||||
archives_base_name=speedometer
|
archives_base_name=speedometer
|
||||||
mod_version=6.2.1
|
mod_version=6.2.3
|
||||||
maven_group=me.zacharias
|
maven_group=me.zacharias
|
||||||
|
|
||||||
architectury_version=13.0.8
|
# https://modrinth.com/mod/architectury-api/versions
|
||||||
|
architectury_version=15.0.3
|
||||||
|
|
||||||
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 = 17.0.144
|
||||||
|
|
||||||
neoforge_version = 21.1.66
|
# NeoForged Only
|
||||||
|
# https://neoforged.net/
|
||||||
|
neoforge_version = 21.4.123
|
||||||
|
|
||||||
cloth_config_version = 15.0.140
|
# Fabric Only
|
||||||
|
# https://fabricmc.net/develop/
|
||||||
|
fabric_loader_version=0.16.10
|
||||||
|
fabric_api_version=0.119.2
|
||||||
|
|
||||||
|
# Fabric Only
|
||||||
|
# https://modrinth.com/mod/modmenu/versions
|
||||||
|
modmenu_version = 13.0.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"
|
||||||
@@ -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,7 +13,10 @@ 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`
|
||||||
* Forge: `forge/build/libs`
|
* Forge: `neoforged/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.
|
||||||
@@ -77,4 +84,11 @@ base
|
|||||||
- scale
|
- 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`.
|
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