RealFluids

Discussion in 'WIP and Development Status' started by mindless728, Feb 22, 2011.

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

    mindless728

    This is a plugin trying to change fluids to be a bit more realistic
    updated to demo-0.7
    FluidPumps updated to demo-0.5

    BlockStorage is a required prerequisite for RealFluids that allows for extra data to be stored for each block in the storage and keeping memory usage down by using a LRU (Least Recently Used) table

    FluidPumps allows the use of colored cloth to pump fluids from one direction to another or using Blue/Red to act as a Water/Lava source respectively

    Download: RealFluids
    Source Code: RealFluids GitHub
    Prerequisites: BlockStorage
    Optional: FluidPumps

    Notes:
    • Fluids will try to fill out an area
    • Fluids go downhill
    • If the fluid is spread out too far, it will disappear
    • Backup your world before use, i make no promises on a demo version
    • Can cause lag if a lot of water is flowing, the plugin is limited to 25ms of run time per tick, which is roughly a half tick
    • Uses a lot of memory at this point (every fluid level stays in memory)
    • After the re-code, it uses more cpu and memory so beware, actually not so bad anymore
    • The block flowing is event driven and can be caught by other plugins!
    • No longer causes horrendous lag when starting a server or exploring a new area
    • added pumps via a new plugin - FluidPumps
    Done:
    • Basically a demo
    • More realistic water flow
    • Sponges soak up water/lava, might be bugged at the moment!
    • Recode the entire plugin (make it event driven)
    • Add lava
    • Persistent data (stone with BlockStorage)
    • Save flow events when world gets saved (done with BlockStorage)
    • Add configuration file
    • Dropping/Destroying certain blocks (think flowers/mushrooms/snow)
      • done via configuration file
    • Add Black Wool as a super sponge to FluidPumps
    • Save FluidPumps between server restarts
    • Buckets are working in a limited fashion
    TODO:
    • Buckets - keep track of fluid levels in them
    • Save Fluidflows between server restarts
    • Add Redstone for FluidPumps
    • Add configuration file support to FluidPumps (for redstone activation)
    • Stop FluidPumps from starting on fire
    the configuration file for RealFluids
    Code:
    WaterStartLevel: 200
    LavaStartLevel: 100
    MinimumDifferenceLevelFraction: 0.05
    RepeatRate: 2
    MaxFlowTimePerRepeat: 25000000
    SimsPerRepeatFraction: 0.5
    FlowDownFraction: 0.5
    ChunkCacheSize: 1024
    WaterOverwriteList: 0 false
    LavaOverwriteList: 0 false
    Definitions:
    WaterStartLevel: the amount of fluid a single water block has
    LavaStartLevel: the amount of fluid a single lava block has
    MinimumDifferenceLevelFraction: the minimum amount, in a fraction, before fluid is allowed to flow, if under this fractional amount flow will not happen, the larger this fraction is the less precise the flow will be
    RepeatRate: the number of server ticks that the running code repeats in, 1 is every tick, 2 is every other, ...
    MaxFlowTimePerRepeat: the maximum amount of time that the running code will run per server tick, this value is in nano seconds
    SimsPerRepeatFraction: the maximum amount of repeats in a server tick, so the fluids don't flow too fast
    FlowDownFraction: the maximum amount of fluid will try to flow straight down in a simulation
    ChunkCacheSize: the amount of chunk caches fluid levels to keep in memory at a time, low values will cause many reads/writes from/to the disk, a large amount will use a lot of memory
    WaterOverwriteList: the list of block id's that water can overwrite, the boolean after each value is whether or not to drop the item associated with the block
    LavaOverwriteList: same as the WaterOverwriteList but with lava instead of water

    About Fluid Pumps: Oh god don't use them for the love of god, extremely broken
    • Uses colored cloth to pump real fluids in directions and allow water/lava sources, the actual pump colors (not sources) can be chained to make pipes
    • NOW SAVES THE PUMPS BETWEEN SERVER RESETS!!!!
    • Blue Cloth - Water Source
    • Red Cloth - Lava Source
    • Orange Cloth - Pumps fluids from south to north
    • Green Cloth - Pumps fluids from north to south
    • Yellow Cloth - Pumps fluids from west to east
    • Purple Cloth - Pumps fluids from east to west
    • Light Gray Cloth - Pumps fluids from below to above (ie up)
    • Gray Cloth - Pumps fluids from above to below (ie down)
    • Black Cloth - Super Sponge!!!!!
     
  2. Offline

    RchGrav

    I have experimented with this plugin and I must say its makes water almost real... (Which could be bad, lol.. but VERY cool...)

    I think one of the main differences between this and "Classic Water" is that classic water can spread out forever, whereas this one has volumetric tracking...

    I know some of the inspiration comes from a tech demo called "Liquid Cubed" seen here..

    http://www.youtube.com/watch?v=y6J_YcfmEqY&feature=iv&annotation_id=annotation_538254

    Really cool stuff... :)

    I hope development carries on for this one...

    If you have a test system you should download it and check it out.

    Rich
     
  3. Offline

    nossr50

    Could we get a youtube video of this plugin?
     
  4. Offline

    RchGrav

    I don't have anything setup to capture with, or I would.. maybe
    Ok.. I made a (very short) one using the free version of fraps... it must be limited on how long the video can capture, since its only 30 seconds... Sorry so short.... consider it a teaser. This is running on the latests builds of CraftBukkit 432+. I haven't had any memory issues using this.. but then again I have my Java memory set pretty high...

    It would be a really neat thing to have on a server if it could be controlled as to who can use it, and where.

    Enjoy!

    http://www.youtube.com/watch?v=qYFJRlVsfgM
     
  5. Offline

    nossr50

    Wow that looked cool.. seemed to travel a bit fast though.
     
  6. Offline

    RchGrav

    Yeah.. real fluids do... haha.. The fast part of the water is what I think is cool...

    It seems as if water puddles it will stay, but water flowing on a surface "Evaporates".....

    If you have a "waterfall" flowing down and you "release" the water by breaking a block at the bottom, it then becomes a "Real Fluid" where it will flow across the map, make a huge amount of water, but the "source" block will actually get sucked into the water flow and disappear.... and eventually the water that doesn't puddle "Evaporates"...

    This plugin needs some adjustments before it becomes "safe"... maybe some kind of permissions can be implemented, or maybe it could even become a "Spell" of some sort.

    Please if someone else has a paid version of FRAPS, I would encourage them to post another video on this thread... I would like to see some other "water" experiments.

    Also give your input to mindless to find a way to make this a "safe" and "real" plugin for our servers. I'm sure he has his own ideas, but thats just my take on it.

    If mindless is deciding to make the source available I would love to see this be even more "flushed" (get it) out.

    Rich

    EDIT: I'll buy a copy of fraps for $37 to make a better video.... but please post your own videos of this plugin... (btw... I had a squid "get annoyed" at me and my Real Fluids fun... he decided to "fly out of the water" and into the air, when I climbed up to him he flew away, like a bird, into the sunset!? haha weird.
     
  7. Offline

    mindless728

    making it safe wouldn't be too hard for water placement, it is block destruction that causes FlowEvents that might be a bit of a problem

    though this plugin needs a lot of work still as it has no persistent data and needs some form of small garbage collection (i was thinking a RealFluidsBlockPool) as the memory can climb if you put a sponge into the ocean

    keep in mind:
    1) This plugin generates custom events that can be listened for
    2) i plan on making another plugin that turns colored wool into fluid pumps
     
  8. Offline

    RchGrav

    AMAZING!!! Good work... your getting me wet just thinking about it..
    (sorry I wasn't going to go there, but did, lol)
    --- merged: Feb 24, 2011 6:53 PM ---
    Scary.... now I AM afraid of this plugin, lol.
     
  9. Offline

    mindless728

    actually very scary, it goes as fast as water, just not as far
    EDIT: so mining near lava is extra dangerous
    --- merged: Feb 24, 2011 7:25 PM ---
    this seems to happen even without this plugin apparently, though the plugin just makes it easier for the AI to do it
     
  10. Offline

    RchGrav

    So I just bought FRAPS just to make to make a nicer video for this plugin.. It is uploading and will take a while..
    I'll post the link when its done.


    oh, btw.. have you tested yet with Buckets? They don't work.. the water just disappears.
     
  11. Offline

    mindless728

    oops, forgot to add that to the todo list
     
  12. Offline

    RchGrav

  13. Offline

    mindless728

    awesome job on the vid!!

    on another note, i am probably pushing a new version this week, probably another rewrite for internal API reasons and for data retention reasons

    secondly, i have started some concept code for using wool blocks of different colors for fluid pumps and fluid sources, though with the re-write i don't want to push it until there is a better working version of RealFluids
    --- merged: Mar 1, 2011 5:07 AM ---
    Updated to demo-0.4

    next on my list is keeping track of bukkits and the volume they are carrying then i am going to work on a save format (i am thinking something similar to the world save) and have some persistence between restarts then ...... release?
    --- merged: Mar 1, 2011 5:25 AM ---
    Whoops, broke sponges, i see how to fix it though that will happen tomorrow as i am tired and need some sleep
    --- merged: Mar 1, 2011 2:40 PM ---
    okay, sponges should be fixed as well as some other bugs going from onBlockFlow to onBlockDamage to check when a fluid should flow
     
  14. Offline

    Tylerjd

    Maybe it should also work with water that comes from buckets... Otherwise, i love the plugin.
     
  15. Offline

    mindless728

    i plan on it, when i get the data storage tested and integrated with this plugin then i will work on bukkits
     
  16. Offline

    RchGrav


    This is going to become something really cool....

    In order for this to be used safely, and actually have running on an actual server it has to be carefully controlled but also be super easy and fun for the users.

    I hope you figure out a way to account for conservation of fluids, and for the plugin to only effect water that has been placed by someone as a Real Fluid... all other water should remain standard... I dont know if this is possible or not.

    Would it be possible to select the type of water you are placing before you dump the bucket?
    Ie.. Regular Water or Real Fluids? Something like having a list of Real Fluid Blocks that is held in memory, or possibly in a table someplace that is only referenced when water is acted upon, otherwise it is just setting dormant?

    This way the server would act like it had regular water.. unless the block being acted upon was in the RFB table..

    I like the idea that you are finding a way to track the volume of water in a single block, but I think this is also really useful for other things too... I picture this plugin being used to make water dams that burst, amazing lava based traps (that don't destroy the map as the current lava does and actually kinda clean up after themselves), etc.

    Another point I thought of.

    Volume of the water placed should be no larger than the number of buckets a user can carry... If you choose to place a real fluid on the map, it always uses all of your water buckets you have on your player. That is what determines the volume. If you just place it as normal, it becomes regular old minecraft water, using 1 bucket, the rest of the buckets remain, otherwise the plugin should replace them with empty buckets.

    A single block of water could possibly be "more dense than it appears" up to the number of blocks a user can carry.... I mean it already seems as though a single block can release a ton more water than it appears to be.

    Regardless, If you can achieve the following three things, you have a winner, V1.0 needs, Stability to the server, Safety of the map data, and not ruin the core game mechanics. (most people hate that)


    So far I think he has done an amazing job, and I look forward to seeing how far he is able to take it.

    I'd love to have a chance to test the RC version before you post the binary. :) Let me know when you are getting close.



    Rich


    PS.. I have been wondering about realism of the demo, and water volumes. Is it possible to count the number of new water blocks and make those also be "real fluid" with proper water volumes?
     
  17. Offline

    JedMyre

    Just gave 0.4 a shot.. water grows to huge proportions and takes quite a while to dissipate... I went up to a high spot and placed one water it literally was like Noahs flood.. tidal wave of water was created and spread out looks like the whole chunk...bogged down my computer monsters were laggy I could still move around all right tho... still an extra blanket of water over the lower levels 10 minutes and going lol
     
  18. Offline

    mindless728

    really? shouldn't be that bad mine dissipates in less than 5s, unless you tried to drain a small lake, which can do this, i will post the version i am currently running as i put a time limiter on the flowing per server tick so it can't cause lag on the server but just causes the fluids to slow down

    carefully controlling this is not easy, maybe not allow a majority of people to use bukkits or when they destroy blocks only certain people can cause RealFluids behavior

    conservation of fluids is already there except when a fluid evaporates because it spreads too thin, water that hasn't been affected by a RealFluid stays normal until it becomes affected or a block is broken next to it and it becomes a RealFluid

    I was thinking making this affect the whole server where water either behaves as a RealFluid (with the plugin enabled) or works like Beta water like normal

    see above, i explained this

    With the FluidPumps plugin i am creating you can pump water into a small container which when broken fluids with higher than normal density will flow out and if the top is broken will flow out the top, though i am thinking of a max density where the fluid will start to destroy blocks around it and eventually destroy the container so you can't store as much as you want and cause horrible lag when the container is broken

    i was just going for simple where when you pick up water the plugin tracks how much fluid the bucket picked up then when you place it it places that much

    i know that a single block of water makes more appear, if i could change the height of the blocks it would look a lot better since it would look like it would be getting lower as it flowed out, but i have tested this and the client doesn't allow this (the water just disappears)


    Yeah it has come pretty far in a short amount of time, and sure i will PM you the RC before i post the plugin submission, though i think i will be releasing another few demo versions (maybe 2) with my BlockStorage plugin that allows storing extra data with individual blocks

    I have though about instead of averaging the fluids to use fluid groups to track how this runs, but that would take a lot more processing power IMO, averaging tends to be easier and faster
     
  19. Offline

    Maskur

    This looks interresting, to bad I'm to scared to break my world when trying this. I may setup another server on my local machine to give it a try :p

    Edit: Just gave it a try on a test-server.

    It was fun to mess with :)

    Some things I want to mention

    1.) I really like to make waterfalls, which as far as my testing goes wouldn't be possible with your plugin?

    2.) The water needs a volume calculation. I set a larg area under water with a water sea of 4x4x1 Blocks.

    3.) As stated by yourselve, the performance is very bad :/

    I'm looking forward how this plugin will evolve :)
     
  20. Offline

    JedMyre

    OK my issue has something to do with EssentialsProtect which is odd cause I've only change the fire-spread setting all the other settings for that plugin are the default, will have to take a closer look.
     
  21. Offline

    RchGrav

    I think the plugin could be made to be a LOT more safe if it could be specifically deployed, not just automatically happen when a block is broken next to existing water.

    The ability to control when and where this happens is crucial.

    Is this a possibility?

    Rich
     
  22. Offline

    Shadus

    I really hope this plugin keeps getting work. This is one of my great pet peeves with minecraft... water... it acts stupid in classic and stupid in beta.
     
  23. Offline

    mindless728

    i am working on it, just school is kicking my ass this quarter
     
  24. Offline

    RchGrav

    mindless,

    When you have time (school comes first), take a moment to consider the implications of not (eventually) coming up with some way to define when the plugin effects water. Just keep it in mind, so you don't eliminate the possibility of adding it later.

    To be a production plugin, fluids should act as normal. By being able to define a block as real fluid you will be able to let the server operator / trusted players configure how the plugin effects the world. I'm not saying your shouldn't refine the mechanics, but under controlled circumstances the plugin could be made safe, even in its existing form.

    Rich
     
  25. Offline

    mindless728

    i know, at the same time the way it is written i can cancel flow events for this plugin (i wrote custom event and listener) so i could refine the mechanics in this plugin then create a management plugin for it
     
  26. Offline

    Raphfrk

    This isn't true.

    For example, this code will cause 3x3 water blocks to be placed at the player's feet and they will change level.

    However, it is highly inefficient, since it sends the entire chunk data. Also, if the 3x3 grid crosses a chunk boundary, then only the blocks that are in the same chunk as the centre will be updated.

    Code:
        void water(Player player, World world, int x, int y, int z, int level, int steps) {
    
            if(steps <= 0) {
                return;
            }
    
            final Player finalPlayer = player;
            final World finalWorld = world;
            final int finalX = x;
            final int finalY = y;
            final int finalZ = z;
            final int finalLevel = level;
            final int finalSteps = steps;
    
            p.getServer().getScheduler().scheduleSyncDelayedTask(p, new Runnable() {
    
                public void run() {
    
                    finalPlayer.sendMessage("Changing level to " + finalLevel + " " + finalSteps + " steps left");
    
                    for(int x = finalX-1;x<=finalX+1;x++) {
                        for(int z = finalZ-1;z<=finalZ+1;z++) {
                            finalWorld.getBlockAt(x, finalY, z).setTypeIdAndData(9, (byte)finalLevel, false);
                        }
                    }
    
                    finalWorld.refreshChunk(finalX>>4, finalZ>>4);
    
                    water(finalPlayer, finalWorld, finalX, finalY, finalZ, (finalLevel + 1)%8, finalSteps-1);
    
                }
    
            }, 20);
    
        }
    
    
    [MERGETIME="1299965788"][/MERGETIME]
    Looks like the problem is a Bukkit issue. I submitted a pull request that fixes it and removes the need to do refresh chunk.
     
  27. Offline

    Vlyn91

    It's really nice, sometimes a lil bit buggy and really laggy, but nice.

    Wouldn't it lag so much, I would use it for my server ^^
     
  28. Offline

    mindless728

    the lag should be fixed or the next dev snapshot and so is the memory footprint (about 3MiB for the fluid levels, though the queue of events is still going to grow), and the lag from having lots of water spread will be fixed but this is done by limiting how much time is allowed per server tick is allocated to running the fluid flow which when in high demand will cause the fluid to stop spreading as fast
     
  29. Offline

    Vlyn91

    At the moment I'm using the plugin on my liveserver, it's fun :D

    Some things don't look so good though:
    - When you place water/lava with a bucket, it doesn't update (only when you place a block next to it)
    - When there was a little flood there are often single waterblocks around waiting for an update :(
    - Water swims _around_ torches (A torch makes an air chamber and can be placed underwater now)
    - Snow + Water doesn't melt the snow, it creates snow tiles (Snow items) -> really really laggy when there are suddenly lying 1000 snow tiles on the ground!
    - Redstone builds airpockets too instead of getting washed away :(

    Could you also make lava a lil bit slower? It's too dangerous for my players atm (And not real, lava isn't that fast)

    Thanks!
     
  30. Offline

    mindless728

    wow, used on a live server, i will re-iterate that is probably a bad idea, though on to the issues
    - Buckets stopped working when i changed the code to get rid of lag from fluids flowing underground (there was a lot)
    - yeah this happens and will more than likely get worse the more code gets added as it takes so much time to calculate the flowing of water, i am thinking about making all of the fluid flow be done in separate threads (probably configurable amount) and the updated to the server
    - Next version will have a configuration file that can change what blocks are overwritten and which ones drop items when there are overwritten
    - the snow + fluid dropping items was just a test with the functions to make it easier to overwrite blocks and drop items, this will change to using the configuration file as opposed to just snow tiles (so yes, this was on purpose)
    - again, the configuration will allow customization of the blocks to be overwritten and dropped

    i have though about making the fluids move at different speeds and don't know how much i like that

    i guess i have some code to work on, as this has to have a bit re-written to allow for my BlockStorage plugin to be used so i don't keep all of the fluid levels in memory and kill servers that way
     
Thread Status:
Not open for further replies.

Share This Page