Skip to content

Commit

Permalink
Check two levels of context for profiling, prevents mob spawning from…
Browse files Browse the repository at this point in the history
… trying to spawn thousnads of mobs while profiling.

Signed-off-by: Ross Allan <rallanpcl@gmail.com>
  • Loading branch information
LunNova committed May 29, 2013
1 parent 59e66ad commit 31493a5
Showing 1 changed file with 3 additions and 2 deletions.
Expand Up @@ -12,6 +12,7 @@
import me.nallar.tickprofiler.minecraft.commands.ProfileCommand;
import me.nallar.tickprofiler.minecraft.profiling.EntityTickProfiler;
import me.nallar.tickprofiler.util.contextaccess.ContextAccess;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.World;

/*
Expand Down Expand Up @@ -76,7 +77,7 @@ public void ensureCapacity(final int minCapacity) {

@Override
public int size() {
if (profilingState == ProfileCommand.ProfilingState.NONE || !World.class.isAssignableFrom(contextAccess.getContext(1))) {
if (profilingState == ProfileCommand.ProfilingState.NONE || !World.class.isAssignableFrom(contextAccess.getContext(1)) || !MinecraftServer.class.isAssignableFrom(contextAccess.getContext(2))) {
return innerList.size();
}
tick();
Expand Down Expand Up @@ -185,7 +186,7 @@ public ListIterator<T> listIterator() {

@Override
public Iterator<T> iterator() {
if (profilingState == ProfileCommand.ProfilingState.NONE || !World.class.isAssignableFrom(contextAccess.getContext(1))) {
if (profilingState == ProfileCommand.ProfilingState.NONE || !World.class.isAssignableFrom(contextAccess.getContext(1)) || !MinecraftServer.class.isAssignableFrom(contextAccess.getContext(2))) {
return innerList.iterator();
}
tick();
Expand Down

0 comments on commit 31493a5

Please sign in to comment.