From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Phoenix616 <mail@moep.tv>
Date: Mon, 20 Apr 2020 17:41:09 +0100
Subject: [PATCH] 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 96aaaab5b7685c874463505f9d25e8a0a01a6e7c..5bcbf2e5ee02764425802a4113d28d03a2a49dc8 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/server/Behavior.java b/src/main/java/net/minecraft/server/Behavior.java
index 0b9d469a92decfb0632805791868ef7faa88c535..071ce4d470044b3cdf0ef150623f5366875b7e04 100644
--- a/src/main/java/net/minecraft/server/Behavior.java
+++ b/src/main/java/net/minecraft/server/Behavior.java
@@ -9,6 +9,7 @@ public abstract class Behavior<E extends EntityLiving> {
     protected final Map<MemoryModuleType<?>, 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;
 
@@ -25,6 +26,10 @@ public abstract class Behavior<E extends EntityLiving> {
         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() {
@@ -37,7 +42,9 @@ public abstract class Behavior<E extends EntityLiving> {
             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;
