Skip to content

Commit

Permalink
Fix #66
Browse files Browse the repository at this point in the history
  • Loading branch information
LunNova committed Jun 20, 2017
1 parent 2e2fcf3 commit f129b68
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import lombok.val;
import net.minecraft.entity.Entity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ITickable;
import net.minecraft.world.World;
import net.minecraft.world.WorldProvider;
import net.minecraft.world.WorldServer;
Expand Down Expand Up @@ -63,20 +62,7 @@ private static String niceName(Class<?> clazz) {
}

@UsedByPatch("entityhook.xml")
public static void profileEntity(World w, Entity entity) {
long start = System.nanoTime();
w.updateEntity(entity);
record(entity, System.nanoTime() - start);
}

@UsedByPatch("entityhook.xml")
public static void profileTickable(ITickable tickable) {
long start = System.nanoTime();
tickable.update();
record(tickable, System.nanoTime() - start);
}

private static void record(Object o, long time) {
public static void record(Object o, long time) {
if (time < 0) {
time = 0;
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/entityhook.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
updateEntities
</insertCodeBefore>
<replaceMethodCall method="^method:ITickable/update^"
code="org.minimallycorrect.tickprofiler.minecraft.profiling.EntityProfiler.profileTickable($0);">
code="{ long start = System.nanoTime(); $proceed($$); org.minimallycorrect.tickprofiler.minecraft.profiling.EntityProfiler.record($0, System.nanoTime() - start); }">
updateEntities_withProfiling
</replaceMethodCall>
<replaceMethodCall methodPrefix="redirect$onUpdateTileEntities$"
code="org.minimallycorrect.tickprofiler.minecraft.profiling.EntityProfiler.profileTickable($1);">
code="{ long start = System.nanoTime(); $proceed($$); org.minimallycorrect.tickprofiler.minecraft.profiling.EntityProfiler.record($1, System.nanoTime() - start); }">
updateEntities_withProfiling
</replaceMethodCall>
<replaceMethodCall method="^method:World/updateEntity^"
code="org.minimallycorrect.tickprofiler.minecraft.profiling.EntityProfiler.profileEntity(this, $1);">
code="{ long start = System.nanoTime(); $proceed($$); org.minimallycorrect.tickprofiler.minecraft.profiling.EntityProfiler.record($1, System.nanoTime() - start); }">
updateEntities_withProfiling
</replaceMethodCall>
</class>
Expand Down

0 comments on commit f129b68

Please sign in to comment.