SteamWar/BauSystem2.0
Archiviert
12
0

Merge remote-tracking branch 'origin/master'
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
yoyosource 2024-07-17 14:04:03 +02:00
Commit 94958de2da
3 geänderte Dateien mit 21 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -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<TNTPoint> 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();

Datei anzeigen

@ -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<TNTPoint> 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());

Datei anzeigen

@ -16,6 +16,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
plugins {
// Adding the base plugin fixes the following gradle warnings in IntelliJ:
//