Solved Increasing water level.

Discussion in 'Plugin Development' started by Wolfey, Dec 15, 2013.

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

    Wolfey

    Hello Bukkit,

    This is my first thread in the plugin development section, and I'm wondering on how to increase the Y. of water, basically making water go up. I was struggling on this for like 30 minutes, but no matter what I tried, I failed. I might also be overlooking something, but can't figure out what, so any help would be appreciated.
     
  2. Offline

    epicfacecreeper

    What exactly are you trying to do? Are you trying to move the water block up or increasing the sea level?
     
  3. Offline

    Wolfey

    Increasing sea level, basically I want to know how to make water go up by 1 block every x amount of seconds cause like I said, I was struggling a lot on this problem.
     
  4. Offline

    Ronbo

    Do you have a specific section of water you want this to happen to, or do you mean all the water in the world?

    If you have a list of the water blocks you want to check, you can probably check to see if the block above the water block is air, and replace it with water if it is.
     
  5. Offline

    Wolfey

    Ronbo, I mean the water goes 1 block up at x amount of time, if it was that simple, i wouldn't have posted this thread :p

    And I don't have a list of blocks, it's more like spawn a square area with water (which I have), and make the water's level go up by one at a time, but the thing is I don't know how.
     
  6. Offline

    Ronbo

    Wolfey
    Uhh... Sorry if you already know this too. But if you want to do something at x amount of time, you can use the scheduler to run a task every X ticks (1 tick = 50milliseconds).

    Code:text
    1. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
    2. public void run() {
    3. PlayerData pd = plugin.getPD(e2.getPlayer());
    4. if(pd != null)
    5. pd.updateArmorStats();
    6. }
    7. }, 1);


    The example above waits 1 tick before running the code in the run() method.

    There are other methods such as scheduleSyncRepeatingTask() (of which the last two arguments are 1) the delay to begin the first execution and 2) the delay between each execution).

    If you need it only up to a certain height or certain number of times, you can either store the ID of the task and cancel it when it's complete, or use a non-repeating task and just have it schedule another task in the run() if the water raising isn't complete yet.

    If you did know this already I'm not too sure what you're confused about since with tasks and what I said earlier you should be able to achieve this pretty easily o_o
     
    Wolfey likes this.
  7. Offline

    Wolfey

    Ronbo, my bad, yea, I knew about runnables, and was using them in my test command, but I was using a repeating task to keep on raising the level of the water, though I was failing on checking for the Y, but you helped me see something that I was missing, thanks!
     
  8. Offline

    RawCode

    tick is 50 ms (20 ticks formup second).

    you can't do this globally no server may handle soo large amount of chunk updates.

    if you want to just change water Y - you shoud play with custom chunk generators, since no code posted, there is nothing to fix or explain at this part.
     
  9. Offline

    Wolfey

    Sorry RawCode, the problem has already been resolved, as I looked over my code again, thanks to Ronbo, I realized where I went wrong, and fixed it.

    Thanks anyways. I'll set the tag to [Solved] for no more confusion.
     
Thread Status:
Not open for further replies.

Share This Page