Storing data like every 100 milliseconds

Discussion in 'Plugin Development' started by duker02, Oct 26, 2013.

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

    duker02

    Alright, so I'm creating a minigame in Minecraft that is very simple (Cookie Clicker...).

    With the cookies being created at a rate of almost millions per second, how would I store the data?
    I haven't worked with any data storage, except MySQL, but I have no idea how to store so much data so often...

    Thanks for any replies :)

    (I intend on using scoreboards, so if there's a way to store it using that...)

    EDIT: It seems as if you guys are misunderstanding. I want to create THIS, but in a plugin form so I can add it to my server.
     
  2. Offline

    The_Doctor_123

    Umm.. I don't exactly get what you mean. "cookies being created at a rate of almost millions per second"?
     
  3. Offline

    duker02

    If you've played Cookie Clicker, you would know that it is possible to get so many machines/bots creating cookies that it can create almost millions of cookies per second. Check out Cookie Clicker first :)

    Thanks,
    Alex
     
  4. Offline

    calebbfmv

    Create a runnable that every time the timer is up, spawn a cookie, or 2, or 1000000.
     
  5. Offline

    The_Doctor_123

    duker02
    Okay, so, you want to spawn a million cookies?
    1. Impossible. You'd be stuck on that tick for an hour then pretty much destroy your world because it's so laggy.
    2. How does that involve storing data?
     
  6. Offline

    remremrem

    I am not the best person to answer this question, as I have never played CookieClicker, but here come some ideas anyways.

    Do not actually spawn all the cookies that are created. See sethbling's cookieclicker video (nvm you already have). Oncea certain limit is reached don't spawn cookies any faster. In fact, it may be faster to use "teleportation" to give the illusion that cookies are being spawned when really they are being "recycled".

    Tracking the amount of cookies "baked" should be as simple as a counter that increments every few ticks and multipliers or adders for the various upgrades. For example a "grandma" boosts production by 2000 cookies per second, so every second you add 2000 to the counter. If you outfit the grandma with a titanium rolling pin she can bake 25% faster so now you add 2000 X 1.25 every second.

    I can't think of a great reason to save the data to disk more than several times a minute, if that.
     
  7. Offline

    xTrollxDudex

    duker02
    If you can't store the data of that magnitude, pretty good chance minecraft nor the server will be able to keep track of that either...

    Best case scenario? Server crash.
     
  8. To answer the question "how to store data every 100 milliseconds"):

    You could store all the data in a java object (maybe a Map) and only write it to a file or a database when the game is over.
     
  9. Offline

    The_Doctor_123

    duker02
    You son of a gun.. Got me hooked on that Cookie Clicker! D:

    Whatever you people do, DO NOT click that link, there's no going back.
     
    Plo124 and NathanWolf like this.
  10. Offline

    xTrollxDudex

    Yeah... iPad users can't play that for some reason...
     
  11. Offline

    The_Doctor_123

    xTrollxDudex
    Oh dang.. and I was going to do that. I guess I'll have to use my remote computer app to use Cookie Clicker at school.
     
  12. Offline

    1Rogue

    Look into making a custom implementation of a BufferedWriter (BufferedCookieWriter?). Then you won't make as many I/O operations and it won't murder your computer.

    Show Spoiler
    [​IMG]
     
  13. Offline

    The_Doctor_123

    1Rogue
    That chrome?

    EDIT: I tested Cookie Clicker on my iPhone with plain old Safari and it worked!
     
    1Rogue likes this.
Thread Status:
Not open for further replies.

Share This Page