From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Phoenix616 Date: Mon, 20 Apr 2020 17:41:09 +0100 Subject: [PATCH] (Origami) Add timings for Behavior diff --git a/src/main/java/co/aikar/timings/WorldTimingsHandler.java b/src/main/java/co/aikar/timings/WorldTimingsHandler.java index c5f594d45012016d99b83a778a2b9d20a7c086ac..4ca89e5279f0a60d1a8cca7329ec4d70b6582525 100644 --- a/src/main/java/co/aikar/timings/WorldTimingsHandler.java +++ b/src/main/java/co/aikar/timings/WorldTimingsHandler.java @@ -140,4 +140,10 @@ public class WorldTimingsHandler { public static Timing getTickList(WorldServer worldserver, String timingsType) { return Timings.ofSafe(((WorldDataServer) worldserver.getWorldData()).getName() + " - Scheduled " + timingsType); } + + // Origami start - behavior timings + public static Timing getBehaviorTimings(String behaviourType) { + return Timings.ofSafe("Behavior - " + behaviourType); + } + // Origami end } diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/Behavior.java b/src/main/java/net/minecraft/world/entity/ai/behavior/Behavior.java index 717e5f71fb919ac8952a077714d7f4581d546a28..ed3a3593b417131837341784b09cb3f9f76a44be 100644 --- a/src/main/java/net/minecraft/world/entity/ai/behavior/Behavior.java +++ b/src/main/java/net/minecraft/world/entity/ai/behavior/Behavior.java @@ -13,6 +13,7 @@ public abstract class Behavior { protected final Map, MemoryStatus> a; private Behavior.Status b; public final Behavior.Status getStatus() { return this.b; } // Tuinity - OBFHELPER private long c; + co.aikar.timings.Timing timing; // Origami - behavior timing private final int d; private final int e; @@ -29,6 +30,10 @@ public abstract class Behavior { this.d = i; this.e = j; this.a = map; + String key = getClass().getSimpleName(); // Yatopia Compatible Fix + // Origami start - behavior timing + timing = co.aikar.timings.WorldTimingsHandler.getBehaviorTimings(key); + // Origami end } public Behavior.Status a() { @@ -41,7 +46,9 @@ public abstract class Behavior { int j = this.d + worldserver.getRandom().nextInt(this.e + 1 - this.d); this.c = i + (long) j; + timing.startTiming(); // Origami - behavior timing this.a(worldserver, e0, i); + timing.stopTiming(); // Origami - behavior timing return true; } else { return false;