diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRecorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRecorder.java index 0fba6df0..fd0274fc 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRecorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceRecorder.java @@ -23,6 +23,7 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.tpslimit.TPSUtils; import de.steamwar.bausystem.region.Region; import de.steamwar.linkage.Linked; +import org.bukkit.Bukkit; import org.bukkit.block.Block; import org.bukkit.entity.TNTPrimed; import org.bukkit.event.EventHandler; @@ -32,6 +33,8 @@ import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntitySpawnEvent; import java.util.*; +import java.util.logging.Level; +import java.util.logging.Logger; @Linked public class TraceRecorder implements Listener { @@ -158,14 +161,24 @@ public class TraceRecorder implements Listener { List history = historyMap.getOrDefault(tntPrimed, new ArrayList<>()); // Failsave for tnt entering unloaded chunks - if (tntPrimed.isDead() || history.size() > 0 && history.get(history.size() - 1).getFuse() == tntPrimed.getFuseTicks()) { + if (tntPrimed == null || tntPrimed.isDead() || history.size() > 0 && history.get(history.size() - 1).getFuse() == tntPrimed.getFuseTicks()) { return null; } int tntID; if (history.size() == 0) { - historyMap.put(tntPrimed, history); + try { + historyMap.put(tntPrimed, history); + } + catch (NullPointerException e) { + Logger logger = Bukkit.getLogger(); + //TODO remove when no longer neccecary + logger.log(Level.WARNING, "Nullpointer thrown by historyMap"); + logger.log(Level.WARNING, "TNT History: " + history); + logger.log(Level.WARNING, "History Map: " + historyMap); + throw e; + } tntID = wrappedTrace.getNextOpenRecordIdAndIncrement(); } else { tntID = history.get(0).getTntId(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/rendering/ViewFlag.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/rendering/ViewFlag.java index 8702a607..9aa83f13 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/rendering/ViewFlag.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/rendering/ViewFlag.java @@ -34,6 +34,9 @@ import java.util.stream.Stream; * A settable flag that changes how a trace is rendered */ public abstract class ViewFlag { + public static final Vector GRAVATY = new Vector(0.0, -0.04, 0.0); + public static final Vector DRAG_FACTOR = new Vector(0.98, 0.98, 0.98); + /** * Static registry of static flags */ @@ -119,12 +122,11 @@ public abstract class ViewFlag { for (TraceEntity entity : entities) { TNTPoint representative = entity.getRecords().get(0); Optional prev = representative.getPrevious(); - if (prev.isEmpty()) continue; TNTPoint previous = prev.get(); - Location delta = representative.getLocation().clone().subtract(previous.getLocation()); + Vector previousVelocity = previous.isAfterFirstExplosion() ? previous.getVelocity() : delta.toVector().clone().divide(DRAG_FACTOR).subtract(GRAVATY); Location yLocation = previous.getLocation().clone().add(0, delta.getY(), 0); if (yLocation.distanceSquared(representative.getLocation()) >= 1.0 / 256.0 && yLocation.distanceSquared(previous.getLocation()) >= 1.0 / 256.0) { @@ -133,7 +135,7 @@ public abstract class ViewFlag { } Location secoundLocation; - if (delta.getX() >= delta.getZ()) { + if (previousVelocity.getX() >= previousVelocity.getZ()) { secoundLocation = previous.getLocation().clone().add(delta.getX(), delta.getY(), 0); } else { secoundLocation = previous.getLocation().clone().add(0, delta.getY(), delta.getZ()); diff --git a/build.gradle b/build.gradle index 5b8a3f12..57d533f8 100644 --- a/build.gradle +++ b/build.gradle @@ -16,6 +16,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ + plugins { // Adding the base plugin fixes the following gradle warnings in IntelliJ: //