From 504be7ca1d5027f6b091133f77387ebcdac27dc9 Mon Sep 17 00:00:00 2001 From: BlazingTwist Date: Sun, 28 Mar 2021 19:59:50 +0200 Subject: [PATCH] refactoring and improved fixed explosionTick detection --- build.gradle | 4 ++-- .../the_dark_jumper/cannontracer/Update.java | 2 +- .../configsaving/DataManager.java | 3 ++- .../settings/MultiPlayerSettings.java | 22 +++++++++---------- src/main/resources/META-INF/mods.toml | 2 +- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/build.gradle b/build.gradle index 081e89d..21912d9 100644 --- a/build.gradle +++ b/build.gradle @@ -13,7 +13,7 @@ apply plugin: 'net.minecraftforge.gradle' apply plugin: 'eclipse' apply plugin: 'maven-publish' -version = '1.1.3' +version = '1.1.4' group = 'blazingtwist.cannontracer' // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = 'cannontracer' @@ -108,7 +108,7 @@ dependencies { // The userdev artifact is a special name and will get all sorts of transformations applied to it. minecraft 'net.minecraftforge:forge:1.15.2-31.2.47' - provided name: 'JumperCommons', version: '1.1.0' + provided name: 'JumperCommons', version: '1.1.1' // You may put jars on which you depend on in ./libs or you may define them like so.. // compile "some.group:artifact:version:classifier" diff --git a/src/main/java/the_dark_jumper/cannontracer/Update.java b/src/main/java/the_dark_jumper/cannontracer/Update.java index b7f6699..724b165 100644 --- a/src/main/java/the_dark_jumper/cannontracer/Update.java +++ b/src/main/java/the_dark_jumper/cannontracer/Update.java @@ -18,7 +18,7 @@ public class Update { public static final String OUTDATED_MSG = "is outdated, please update using the button on the config screen!"; public static final String MOD_NAME = "CannonTracer "; - public static final String VERSION = "1.1.3"; + public static final String VERSION = "1.1.4"; public static void sendUpdateMessageIfNeeded() { if(checkUpdateAvailable()) { diff --git a/src/main/java/the_dark_jumper/cannontracer/configsaving/DataManager.java b/src/main/java/the_dark_jumper/cannontracer/configsaving/DataManager.java index a982fba..6cc37d6 100644 --- a/src/main/java/the_dark_jumper/cannontracer/configsaving/DataManager.java +++ b/src/main/java/the_dark_jumper/cannontracer/configsaving/DataManager.java @@ -212,7 +212,8 @@ public void load() { System.err.println("Collected lines to String: " + json); Path path = Paths.get(configPathGNS.get()); long size = Files.size(path); - System.err.println("Filesize is: " + size + " | at Path: " + path.toString()); + File configFile = new File(configPathGNS.get()); + System.err.println("Filesize is: " + size + " | at Path: " + path.toString() + " | exists? " + configFile.isFile()); ObjectMapper mapper = getObjectMapper(); //this.tracerConfig = mapper.readValue(json, TracerConfig.class); diff --git a/src/main/java/the_dark_jumper/cannontracer/settings/MultiPlayerSettings.java b/src/main/java/the_dark_jumper/cannontracer/settings/MultiPlayerSettings.java index 0c64b06..bbf7a17 100644 --- a/src/main/java/the_dark_jumper/cannontracer/settings/MultiPlayerSettings.java +++ b/src/main/java/the_dark_jumper/cannontracer/settings/MultiPlayerSettings.java @@ -2,6 +2,7 @@ import java.util.HashMap; import java.util.HashSet; +import java.util.Map; import jumpercommons.GetterAndSetter; import net.minecraft.client.Minecraft; import the_dark_jumper.cannontracer.Main; @@ -83,7 +84,7 @@ public void findPreviousDespawnTick(boolean b) { int max = main.moduleManager.getMaxDisplayTickMP(); int currentTick = startTick; while ((currentTick = currentTick - 1) != startTick) { - if(currentTick < 0){ + if (currentTick < 0) { currentTick = max; } if (despawnTicks.contains(currentTick)) { @@ -99,11 +100,10 @@ public HashSet getDespawnTicks() { HashSet result = new HashSet<>(); for (SingleTickMoveData moveData : main.entityTracker.tracingHistory) { for (HashMap tickData : moveData.tickData.values()) { - for (int key : tickData.keySet()) { - if (tickData.get(key)) { - result.add(key); - } - } + tickData.entrySet().stream() + .filter(Map.Entry::getValue) // filter for despawn ticks + .map(Map.Entry::getKey) // get ticks + .forEach(result::add); } } return result; @@ -114,27 +114,27 @@ public void showFirstTick(boolean b) { for (SingleTickMoveData singleTickMoveData : main.entityTracker.tracingHistory) { for (HashMap tickData : singleTickMoveData.tickData.values()) { int minTick = tickData.keySet().stream().min(Integer::compareTo).orElse(Integer.MAX_VALUE); - if(minTick < first){ + if (minTick < first) { first = minTick; } } } - if(first < main.moduleManager.getMaxDisplayTickMP()){ + if (first < main.moduleManager.getMaxDisplayTickMP()) { renderTickGNS.set(first); } } - public void showLastTick(boolean b){ + public void showLastTick(boolean b) { int last = Integer.MIN_VALUE; for (SingleTickMoveData singleTickMoveData : main.entityTracker.tracingHistory) { for (HashMap tickData : singleTickMoveData.tickData.values()) { int maxTick = tickData.keySet().stream().max(Integer::compareTo).orElse(Integer.MIN_VALUE); - if(maxTick > last){ + if (maxTick > last) { last = maxTick; } } } - if(last >= 0){ + if (last >= 0) { renderTickGNS.set(last); } } diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 916b8ee..3a3b57f 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -4,7 +4,7 @@ loaderVersion="[31,)" # A list of mods - how many allowed here is determined by the individual mod loader [[mods]] modId="cannontracer" -version="1.1.3" +version="1.1.4" displayName="Cannon Tracer" credits="Thanks for this mod goes to my no longer existing will to live" authors="The_Dark_Jumper"