From 29c3e954beea36832d137052750f39a33fbb139c Mon Sep 17 00:00:00 2001 From: jojo Date: Sun, 19 Jul 2020 16:38:47 +0200 Subject: [PATCH] Fix ArrayIndexOutOfBoundsException --- .../src/de/steamwar/bausystem/tracer/trace/TNTTrace.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/trace/TNTTrace.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/trace/TNTTrace.java index b20f6b5..212d6ec 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracer/trace/TNTTrace.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/tracer/trace/TNTTrace.java @@ -10,7 +10,7 @@ public class TNTTrace { private int uniqueID; private int index = 0; - private float[] positions = new float[243]; + private float[] positions = new float[240]; public TNTTrace(int uniqueID) { this.uniqueID = uniqueID; @@ -21,6 +21,9 @@ public class TNTTrace { } public void addLocation(double x, double y, double z) { + if (index >= positions.length) { + positions = Arrays.copyOf(positions, positions.length + 240); + } positions[index + 0] = (float)x; positions[index + 1] = (float)y; positions[index + 2] = (float)z;