Solved Infinity

Discussion in 'Plugin Development' started by JRL1004, Jan 10, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    JRL1004

    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
    1. Player player = null; //Assume I have a player
    2. player.setMaxHealth(Double.POSITIVE_INFINITY);
    3. player.teleport(new Location(player.getWorld(), Double.POSITIVE_INFINITY, player.getWorld().getMaxHeight(), Double.POSITIVE_INFINITY));
    4. player.setHealth(player.getMaxHealth()); //Since the max health is infinite
    5. player.setExp(Float.POSITIVE_INFINITY);
    6. player.setExhaustion(Float.POSITIVE_INFINITY);
    7. player.setSaturation(Float.POSITIVE_INFINITY);
    8. player.setWalkSpeed(Float.POSITIVE_INFINITY);
     
  2. Offline

    xTigerRebornx

    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.
     
  3. Offline

    JRL1004

    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)
     
  4. Offline

    xTigerRebornx

    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...
     
  5. Offline

    NathanWolf

    A lot of those values are probably sanity checked. I know walk speeds of more than like 1.8 will be rejected, for instance.
     
  6. Offline

    Wizehh

    I'll test.
    Quad i7, 3770k, 3.5 ghz
     
  7. Offline

    JRL1004

    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
     
  8. Offline

    Wizehh

    Edit: This is what happened :(
    [​IMG]
    Edit 2: Noooo!
    [​IMG]
    PHP:
    [18:44:09 ERROR]: null
    org
    .bukkit.command.CommandExceptionUnhandled 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-B
    ukkit
    -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-Bukk
    it
    -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-b
    2974jnks
    ]
            
    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 byjava.lang.IllegalArgumentExceptionInfinity 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 exception
    net
    .minecraft.server.v1_7_R1.ReportedExceptionException 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 byjava.util.NoSuchElementException
            at org
    .bukkit.craftbukkit.v1_7_R1.util.LongObjectHashMap$ValueIterator.next(LongObjectHashMap.java:331) ~[c
    raftbukkit
    .jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            
    at org.bukkit.craftbukkit.v1_7_R1.util.LongObjectHashMap$KeyIterator.next(LongObjectHashMap.java:351) ~[cra
    ftbukkit
    .jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            
    at org.bukkit.craftbukkit.v1_7_R1.util.LongObjectHashMap$KeyIterator.next(LongObjectHashMap.java:335) ~[cra
    ftbukkit
    .jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
            
    at net.minecraft.server.v1_7_R1.SpawnerCreature.spawnEntities(SpawnerCreature.java:100) ~[craftbukkit.jar:g
    it
    -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 tocrash-2014-01
    -10_18.44.09-server.txt
    >
     
    NathanWolf, swampshark19 and JRL1004 like this.
  9. Offline

    JRL1004

    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.
     
  10. Offline

    Wizehh

  11. Offline

    xTigerRebornx

    Wizehh Well, was nice knowing yah....Good luck with fixing this tho
     
  12. Offline

    Wizehh

  13. Offline

    Maurdekye

    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.
     
  14. Offline

    Wizehh

    Did you not see what happened to my house?
     
  15. Offline

    JRL1004

    Wizehh Next time, copy the third little pig and use bricks, they are much less flammable.
     
  16. Offline

    Wizehh

    too expensive
     
Thread Status:
Not open for further replies.

Share This Page