Skip to content

Commit 5df61e2

Browse files
committed
[Gui] Added more info to InfoHud
- Changed DesyncMonitor values from relative to absolute - Added hash to build - Added version to hud
1 parent b54196a commit 5df61e2

File tree

5 files changed

+45
-42
lines changed

5 files changed

+45
-42
lines changed

build.gradle

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,16 @@ plugins {
33
id 'fabric-loom' version "${loom_version}"
44
// legacy looming (loom plugin improvements)
55
id 'legacy-looming' version "${loom_version}"
6+
id 'com.palantir.git-version' version '3.1.0'
67
}
78

89

910
// set basic properties
10-
version = project.version
11+
def hash = ""
12+
if(project.release=="false") {
13+
hash = "_"+versionDetails().gitHash.substring(0,5)
14+
}
15+
version = project.version+hash
1116
group = project.group
1217

1318
// compile for java 8
@@ -18,7 +23,6 @@ loom {
1823
accessWidenerPath = file('src/main/resources/tasmod.accesswidener')
1924
// add log4jconfig
2025
log4jConfigs.from(file('src/main/resources/log4j.xml'))
21-
2226
}
2327

2428
// dependency repositories
@@ -52,8 +56,6 @@ dependencies {
5256
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.0'
5357
}
5458

55-
56-
5759
// task for downloading KillTheRng
5860
//task downloadKTRNG(type: Copy) {
5961
//group 'tasmod'
@@ -70,7 +72,7 @@ compileJava{
7072
processResources {
7173
inputs.property "version", project.version
7274
inputs.property "mcversion", project.minecraft_version
73-
75+
7476
filesMatching("fabric.mod.json") {
7577
expand 'mod_url': project.mod_url, 'name': project.mod_name, 'mod_version': project.version, 'mod_description': project.mod_description, 'mod_sources': project.mod_sources, 'mod_email': project.mod_email
7678
}

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ [email protected]
1717
group=com.minecrafttas
1818
artifact=TASmod-1.12.2
1919
version=Beta1.0-SNAPSHOT
20+
release=false

src/main/java/com/minecrafttas/tasmod/TASmod.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import com.minecrafttas.tasmod.util.Scheduler;
3939

4040
import net.fabricmc.api.ModInitializer;
41+
import net.fabricmc.loader.api.FabricLoader;
4142
import net.fabricmc.loader.impl.FabricLoaderImpl;
4243
import net.minecraft.server.MinecraftServer;
4344

@@ -48,10 +49,12 @@
4849
*/
4950
public class TASmod implements ModInitializer, EventServerInit, EventServerStop {
5051

51-
private static MinecraftServer serverInstance;
52-
5352
public static final Logger LOGGER = LogManager.getLogger("TASmod");
5453

54+
public static String version = "dev";
55+
56+
private static MinecraftServer serverInstance;
57+
5558
public static PlaybackControllerServer playbackControllerServer = new PlaybackControllerServer();;
5659

5760
public static SavestateHandlerServer savestateHandlerServer;
@@ -82,6 +85,12 @@ public void onInitialize() {
8285

8386
LOGGER.info("Initializing TASmod");
8487

88+
String modVersion = FabricLoader.getInstance().getModContainer("tasmod").get().getMetadata().getVersion().getFriendlyString();
89+
90+
if (!"${mod_version}".equals(modVersion)) {
91+
version = modVersion;
92+
}
93+
8594
// Start ticksync
8695
ticksyncServer = new TickSyncServer();
8796

src/main/java/com/minecrafttas/tasmod/gui/InfoHud.java

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,7 @@ public void onDrawHotbar() {
509509
}
510510
ScaledResolution scaled = new ScaledResolution(Minecraft.getMinecraft());
511511
drawCenteredString(Minecraft.getMinecraft().fontRenderer, "TASmod is still in development! Major issues may arise!", scaled.getScaledWidth() / 2, scaled.getScaledHeight() - 50, 0xFF8400);
512+
drawString(Minecraft.getMinecraft().fontRenderer, TASmod.version, scaled.getScaledWidth() - Minecraft.getMinecraft().fontRenderer.getStringWidth(TASmod.version) - 2, scaled.getScaledHeight() - 10, 0xFFFFFF);
512513
// drawCenteredString(Minecraft.getMinecraft().fontRenderer, Float.toString(TASmod.tickratechanger.ticksPerSecond), scaled.getScaledWidth() / 2, scaled.getScaledHeight() - 36, 0xFFFFFF);
513514
}
514515

@@ -523,27 +524,29 @@ private void drawRectWithText(String text, int x, int y, boolean rect) {
523524
}
524525

525526
private String keystrokes() {
526-
if (Display.isActive()) {
527-
String out1 = "" + ChatFormatting.WHITE;
528-
for (String mouse : TASmodClient.virtual.getCurrentMousePresses()) {
529-
out1 = out1.concat(mouse + " ");
530-
}
527+
528+
String out1 = "" + ChatFormatting.WHITE;
529+
for (String mouse : TASmodClient.virtual.getCurrentMousePresses()) {
530+
out1 = out1.concat(mouse + " ");
531+
}
532+
if (Display.isActive() || TASmodClient.controller.isPlayingback()) {
531533
out1 = out1.concat("" + ChatFormatting.GREEN);
532534
for (String mouse : TASmodClient.virtual.getNextMousePresses()) {
533535
out1 = out1.concat(mouse + " ");
534536
}
537+
}
535538

536-
String out2 = "" + ChatFormatting.WHITE;
537-
for (String key : TASmodClient.virtual.getCurrentKeyboardPresses()) {
538-
out2 = out2.concat(key + " ");
539-
}
539+
String out2 = "" + ChatFormatting.WHITE;
540+
for (String key : TASmodClient.virtual.getCurrentKeyboardPresses()) {
541+
out2 = out2.concat(key + " ");
542+
}
543+
if (Display.isActive() || TASmodClient.controller.isPlayingback()) {
540544
out2 = out2.concat("" + ChatFormatting.GREEN);
541545
for (String key : TASmodClient.virtual.getNextKeyboardPresses()) {
542546
out2 = out2.concat(key + " ");
543547
}
544-
return out1 + out2;
545548
}
546-
return "";
549+
return out1 + out2;
547550
}
548551

549552
private Pair<Integer, Integer> getScreenOffset(int x, int y, InfoLabel label) {

src/main/java/com/minecrafttas/tasmod/playback/filecommands/integrated/DesyncMonitorFileCommandExtension.java

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -173,19 +173,13 @@ public String getStatus(EntityPlayerSP player) {
173173

174174
public String getPos() {
175175
if (currentValues != null && !TASmodClient.controller.isNothingPlaying()) {
176-
EntityPlayerSP player = Minecraft.getMinecraft().player;
176+
// EntityPlayerSP player = Minecraft.getMinecraft().player;
177177
String[] values = new String[3];
178-
values[0] = getFormattedString(player.posX - currentValues.values[0]);
179-
values[1] = getFormattedString(player.posY - currentValues.values[1]);
180-
values[2] = getFormattedString(player.posZ - currentValues.values[2]);
181-
182-
String out = "";
183-
for (String val : values) {
184-
if (val != null) {
185-
out += val + " ";
186-
}
187-
}
188-
lastPos = out;
178+
values[0] = getFormattedString(/*player.posX - */currentValues.values[0]);
179+
values[1] = getFormattedString(/*player.posY - */currentValues.values[1]);
180+
values[2] = getFormattedString(/*player.posZ - */currentValues.values[2]);
181+
182+
lastPos = String.join(" ", values);
189183
}
190184
return lastPos;
191185
}
@@ -194,19 +188,13 @@ public String getPos() {
194188

195189
public String getMotion() {
196190
if (currentValues != null && !TASmodClient.controller.isNothingPlaying()) {
197-
EntityPlayerSP player = Minecraft.getMinecraft().player;
191+
// EntityPlayerSP player = Minecraft.getMinecraft().player;
198192
String[] values = new String[3];
199-
values[0] = getFormattedString(player.motionX - currentValues.values[3]);
200-
values[1] = getFormattedString(player.motionY - currentValues.values[4]);
201-
values[2] = getFormattedString(player.motionZ - currentValues.values[5]);
202-
203-
String out = "";
204-
for (String val : values) {
205-
if (val != null) {
206-
out += val + " ";
207-
}
208-
}
209-
lastMotion = out;
193+
values[0] = getFormattedString(/*player.motionX - */currentValues.values[3]);
194+
values[1] = getFormattedString(/*player.motionY - */currentValues.values[4]);
195+
values[2] = getFormattedString(/*player.motionZ - */currentValues.values[5]);
196+
197+
lastMotion = String.join(" ", values);
210198
}
211199
return lastMotion;
212200
}

0 commit comments

Comments
 (0)