So, I was going through Bukkit's various built-in methods to see what it was capable of and noticed that many take a double for input. What would happen if I were to use Double.POSITIVE_INFINITY or Float.POSITIVE_INFINITY for these? for example these few: Code:java Player player = null; //Assume I have a playerplayer.setMaxHealth(Double.POSITIVE_INFINITY);player.teleport(new Location(player.getWorld(), Double.POSITIVE_INFINITY, player.getWorld().getMaxHeight(), Double.POSITIVE_INFINITY));player.setHealth(player.getMaxHealth()); //Since the max health is infiniteplayer.setExp(Float.POSITIVE_INFINITY);player.setExhaustion(Float.POSITIVE_INFINITY);player.setSaturation(Float.POSITIVE_INFINITY);player.setWalkSpeed(Float.POSITIVE_INFINITY);
JRL1004 My guess is that a lot of stuff might break. The max health might be fine, but the location and walkspeed would either glitch out the player or just break the player's screen(for the walkspeed). Note, these are just guesses, might need to look into the code to see how it handles extremely large numbers such as these.
xTigerRebornx I'm tempted to test it but I made this post because I don't want to hurt my computer too bad by forcing it to process that (my computer is about as powerful as a TI-26)
JRL1004 I want to test it to, but then again, my computer has the processing power of a cardboard box, so yeah. The results would be interesting tho...
A lot of those values are probably sanity checked. I know walk speeds of more than like 1.8 will be rejected, for instance.
NathanWolf Pfft, Infinity is completely sane! I mean, really, there is nothing more sane than an unachievable value. EDIT: Please post the results here Wizehh
Edit: This is what happened Edit 2: Noooo! PHP: [18:44:09 ERROR]: nullorg.bukkit.command.CommandException: Unhandled exception executing command 'yolo' in plugin McTribes v0.5 at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:196) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at org.bukkit.craftbukkit.v1_7_R1.CraftServer.dispatchCommand(CraftServer.java:542) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at net.minecraft.server.v1_7_R1.PlayerConnection.handleCommand(PlayerConnection.java:932) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at net.minecraft.server.v1_7_R1.PlayerConnection.a(PlayerConnection.java:814) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at net.minecraft.server.v1_7_R1.PacketPlayInChat.a(PacketPlayInChat.java:28) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at net.minecraft.server.v1_7_R1.PacketPlayInChat.handle(PacketPlayInChat.java:47) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at net.minecraft.server.v1_7_R1.NetworkManager.a(NetworkManager.java:146) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at net.minecraft.server.v1_7_R1.ServerConnection.c(SourceFile:134) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:655) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:250) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:545) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java:457) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:617) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]Caused by: java.lang.IllegalArgumentException: Infinity is too high at org.bukkit.craftbukkit.v1_7_R1.entity.CraftPlayer.validateSpeed(CraftPlayer.java:1034) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at org.bukkit.craftbukkit.v1_7_R1.entity.CraftPlayer.setWalkSpeed(CraftPlayer.java:1013) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at cc.crafty.mctribes.commands.Yolo.onCommand(Yolo.java:43) ~[?:?] at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] ... 13 more[18:44:09 ERROR]: Encountered an unexpected exceptionnet.minecraft.server.v1_7_R1.ReportedException: Exception ticking world at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:633) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at net.minecraft.server.v1_7_R1.DedicatedServer.u(DedicatedServer.java:250) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at net.minecraft.server.v1_7_R1.MinecraftServer.t(MinecraftServer.java:545) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java:457) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:617) [craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]Caused by: java.util.NoSuchElementException at org.bukkit.craftbukkit.v1_7_R1.util.LongObjectHashMap$ValueIterator.next(LongObjectHashMap.java:331) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at org.bukkit.craftbukkit.v1_7_R1.util.LongObjectHashMap$KeyIterator.next(LongObjectHashMap.java:351) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at org.bukkit.craftbukkit.v1_7_R1.util.LongObjectHashMap$KeyIterator.next(LongObjectHashMap.java:335) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at net.minecraft.server.v1_7_R1.SpawnerCreature.spawnEntities(SpawnerCreature.java:100) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at net.minecraft.server.v1_7_R1.WorldServer.doTick(WorldServer.java:187) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] at net.minecraft.server.v1_7_R1.MinecraftServer.u(MinecraftServer.java:629) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.2-b2974jnks] ... 4 more[18:44:09 ERROR]: This crash report has been saved to: crash-2014-01-10_18.44.09-server.txt>
Wizehh Got it, so don't use infinity. Also, I'm not funding house or computer repairs. EDIT: Yolo? Good choice for a command name.
The actual defined values of infinity are probably just really, really, really big numbers and not actually infinity. Something like 2^64 or some odd. I'd guess either Minecraft deals with this already by normalizing the numbers, or something crazy happens. I have to go with the latter.