Exception in entities_in_radius() barking about entities in different worlds
LadyCailinBot opened this issue ยท 4 comments
CMDHELPER-2885 - Reported by CyaNox
The following code:
{code:title=MobSpawning.ms}
export('mobspawning.mobs.hostile', array('WITCH', 'CREEPER', 'SKELETON', 'SPIDER', 'ZOMBIE', 'SLIME', 'GHAST', 'PIG_ZOMBIE', 'ENDERMAN', 'CAVE_SPIDER', 'SILVERFISH', 'BLAZE', 'MAGMA_CUBE'))
export('mobspawning.mobs.passive', array('PIG', 'SHEEP', 'COW', 'CHICKEN', 'WOLF', 'MUSHROOM_COW', 'OCELOT', 'HORSE'))
{code:title=MobSpawning.msa}
/nbe3 = >>>
@s = nano_time()
foreach(all_players(), @pl){
@p = entities_in_radius(ploc(@pl), 96, import('mobspawning.mobs.passive'))
@h = entities_in_radius(ploc(@pl), 96, import('mobspawning.mobs.hostile'))
@a = entities_in_radius(ploc(@pl), 96, 'BAT')
@w = entities_in_radius(ploc(@pl), 96, 'SQUID')
console(@pl . ': p: ' . array_size(@p) . ' h: ' . array_size(@h) . ' a: ' . array_size(@a) . ' w: ' . array_size(@w))
}
console('All entities retrieved in ' . sprintf('%.3f', (nano_time() - @s) / 1000000) . 'ms.')
<<<
Produces the following trace but only in certain situations. Which situations are unclear to me but at least you need a player in the nether and one in the overworld.
{code:title=console}
[13:44:17 ERROR]: Uh oh! You've found an error in CommandHelper. This is an error caused by your code, so you may be able to find a workaround, but is ultimately an error in CommandHelper itself. The line of code that caused the error was this:
entities_in_radius({0: -3722.1080638918625, 1: 54.0, 2: 1040.2940657111562, 3: world, 4: 178.9834747314453, 5: 35.69990158081055, pitch: 35.69990158081055, world: world, x: -3722.1080638918625, y: 54.0, yaw: 178.9834747314453, z: 1040.2940657111562}, 96, {PIG, SHEEP, COW, CHICKEN, WOLF, MUSHROOM_COW, OCELOT, HORSE})
on or around /srv/mc/live/survival/plugins/CommandHelper/LocalPackages/shared/MobSpawning/MobSpawning.msa:113.
Please report this error to the developers, and be sure to include the version numbers: Server version: 1.7.2-R0.3-SNAPSHOT; CommandHelper version: 3.3.1-SNAPSHOT:2522-a8e1e6c,master. Here's the stacktrace:
java.lang.IllegalArgumentException: Cannot measure distance between world_nether and world
at org.bukkit.Location.distanceSquared(Location.java:448)
at org.bukkit.Location.distance(Location.java:431)
at com.laytonsmith.abstraction.bukkit.BukkitMCLocation.distance(BukkitMCLocation.java:54)
at com.laytonsmith.core.functions.EntityManagement$entities_in_radius.exec(EntityManagement.java:770)
at com.laytonsmith.core.Script.eval(Script.java:308)
at com.laytonsmith.core.Script.eval(Script.java:270)
at com.laytonsmith.core.Script.eval(Script.java:270)
at com.laytonsmith.core.functions.DataHandling$foreach.execs(DataHandling.java:569)
at com.laytonsmith.core.Script.eval(Script.java:260)
at com.laytonsmith.core.Script.eval(Script.java:270)
at com.laytonsmith.core.MethodScriptCompiler.execute(MethodScriptCompiler.java:1592)
at com.laytonsmith.core.MethodScriptCompiler.execute(MethodScriptCompiler.java:1552)
at com.laytonsmith.core.Script.run(Script.java:162)
at com.laytonsmith.core.AliasCore.alias(AliasCore.java:166)
at com.laytonsmith.commandhelper.CommandHelperServerListener.onServerCommand(CommandHelperServerListener.java:41)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:425)
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62)
at org.bukkit.plugin.TimedRegisteredListener.callEvent(TimedRegisteredListener.java:30)
at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:482)
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:467)
at net.minecraft.server.v1_7_R1.DedicatedServer.aw(DedicatedServer.java:305)
at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:274)
at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:540)
at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java:446)
at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:617)
Comment by VergilPrime
I assume entities_in_radius is looking for entities in the world you are running the command in in a radius around a player in the nether. Interesting.
Comment by CyaNox
Actually I was running it from the console in this particular instance.
Comment by PseudoKnight
Not sure this is actually a CH issue so much as a Minecraft storage issue (that CH may need to workaround), where an entity is stored in one region file but it's location is actually in another. I could be wrong, but I get problems that look like this sometimes when pasting a schematic with entities or I think maybe when an entity goes through a portal.
When using all_entities(), I get the entity and try and immediately remove it, only to get an error (not the same one). I just have to use try() any time I work on all_entities() return data. entities_in_radius automatically does calculations on resulting entities, so I imagine you can't workaround that problem using that function. It would need a catch in CH.