Inactive [MECH] Self Planting v1.4 - self planting plants [1.2.5-R2.0]

Discussion in 'Inactive/Unsupported Plugins' started by CaiusTSM, Jul 17, 2011.

  1. Offline

    CaiusTSM

    Self Planting - self planting plants.
    Version: v1.4

    This plugin allows you to make saplings, cactus, and sugar cane automatically plant themselves after a certain amount of time. You can configure the planting time for each plant in the config file (default 30 seconds). If you set the plant time to zero, that plant will not plant itself.

    Note: Currently sugar cane requires a block of water next to it, not diagonal like normal sugar cane.

    Features:
    • Make saplings plant themselves.
    • Make cactus plant themselves.
    • Make sugar cane plant itself.
    • Make seeds plant themselves.
    • Configurable times for planting.
    • Configure which plant can plant itself.
    • Configurable how many plants can countdown at once. (plant limit)
    Download the jar:
    SelfPlanting.jar

    Movie--------------------------------------------------------------------------------------------------------


    Changelog:
    Version 1.0
    • plugin released!
    Version 1.1
    • added: seeds plant themselves.
    Version 1.2:
    • fixed errors.
    • code is more memory efficient.
    Version 1.3:
    • configurable how many saplings can be counting down at one time. Suggest leaving as default unless you have a great CPU.
    Version: 1.4:
    • re-coded plugin.
    • now supports different kinds of saplings.
    • plants now need a light level >= 9 to plant themselves.
    • bug fixes.
    To Do List:
    • Different types of trees.
    • Sugar cane can plant itself with water diagonal to it.
    • Spread Mode: trees over time die, and spread saplings (other plants too?).
    • Mushrooms plant themselves.
    • Flowers plant themselves.
    If you get any errors please tell me.

    My other plugins:
    Item Scanner:
    http://forums.bukkit.org/threads/me...t-collect-items-and-power-redstone-953.20375/
     
  2. Offline

    h0us3cat

    i hope this one works, all simular plugins that do this work like crap :)
     
  3. Offline

    CaiusTSM

    Tell me in what way the others work like crap, and I can see if I can make mine better.
     
  4. Offline

    h0us3cat

    they stop working randomly :)
    one (plantspreader) always worked but its dead
     
  5. Offline

    CaiusTSM

    I did not find any bugs, I tested it a lot. If you could test it more for me that would be useful.:)
    All other plugins that I could find similar to this one only planted plants after a event such as destroying a log etc. Mine in contrast always checks in a loop all plants on the map and plants them.
     
  6. Offline

    morizuki

    my seeds won't replant after I punch them..
     
  7. Thanks CaisusTSM for all your effort you have put in my request!
    Really Appreciated!!!
     
  8. Offline

    CaiusTSM

    If you just planted the seed it wont give you the seed back after you punch it (normally its like that too if you plant it yourself). You have to let it grow a bit and then it will give you the seed back, and if you let it grow all the way, it will give you wheat too.

    Edit: Or do you mean that you let it grow all the way and then punched it and seeds came out, and they did not replant themselves?
     
  9. Offline

    morizuki

    yep.. i've waited till it grows.. and punch it.. but didn't replant iself..
     
  10. Offline

    CaiusTSM

    when you punched it did the seed come out and sit on top of the soil or did you pick it up?
     
  11. Offline

    morizuki

    just pop out.. doing nothing, just laying there :( another is no seed came out just wheat
    ..
     
  12. Offline

    CaiusTSM

    Do you have any other plugins in use while testing? I am testing this seeds problem now.
     
  13. Offline

    morizuki

    yeah.. but i disable them all.. imma test it later again
     
  14. Offline

    CaiusTSM

    I just finished testing it, and it work fine (without any other plugins). Also, how long did you wait for the seed to plant itself? Maybe you should try changing the plant time to 2 seconds, and see if it plants.

    Note: crops sometimes do not drop seeds even when they are fully grown.
     
  15. Offline

    morizuki

    yeah i switched it to 2seconds..
     
  16. Offline

    CaiusTSM

    if you throw a seed onto some tilled soil, will it plant itself?

    Also are you using version 1.1 or 1.0?
     
  17. Offline

    sipeari

    yay, finally my trees can plant themselves :D
     
  18. Offline

    po5

    nice. can u make it so trees will randomly die? This will spawn more saplings and the forests will grow :)
     
  19. Offline

    CaiusTSM

    I thought about that, I was going to add that in the config as like: SpreadMode=true
     
  20. Offline

    po5

    sounds very nice. Ive been running this about an hour, saplings seem to replant themselves fine but i get this error in console once in a while

    Code:
    2011-07-25 16:17:04 [SEVERE] java.util.ConcurrentModificationException
    2011-07-25 16:17:04 [SEVERE]     at java.util.AbstractList$Itr.checkForComodification(AbstractList.java:372)
    2011-07-25 16:17:04 [SEVERE]     at java.util.AbstractList$Itr.next(AbstractList.java:343)
    2011-07-25 16:17:04 [SEVERE]     at org.bukkit.craftbukkit.CraftWorld.getEntities(CraftWorld.java:515)
    2011-07-25 16:17:04 [SEVERE]     at org.CaiusTSM.SelfPlanting.EntityScanner.run(EntityScanner.java:34)
    2011-07-25 16:17:04 [SEVERE]     at org.bukkit.craftbukkit.scheduler.CraftWorker.run(CraftWorker.java:34)
    2011-07-25 16:17:04 [SEVERE]     at java.lang.Thread.run(Thread.java:662)

    i also got this once, and just after decided to disable plugin :) The CPU load also seemed to be very high

    Code:
    2011-07-25 16:20:40 [SEVERE] java.lang.NullPointerException
    2011-07-25 16:20:40 [SEVERE]     at org.CaiusTSM.SelfPlanting.SelfPlanting.isOnList(SelfPlanting.java:131)
    2011-07-25 16:20:40 [SEVERE]     at org.CaiusTSM.SelfPlanting.EntityScanner.run(EntityScanner.java:42)
    2011-07-25 16:20:40 [SEVERE]     at org.bukkit.craftbukkit.scheduler.CraftWorker.run(CraftWorker.java:34)
    2011-07-25 16:20:40 [SEVERE]     at java.lang.Thread.run(Thread.java:662)
     
  21. Offline

    kasszz

    I have the same problem as po5, please fix it. I really like the mod :( but now I can't use it :(
     
  22. Offline

    Fluffgar

    Oh, I've been after something like this for ages! I use Nature Overhaul in singleplayer and have been hoping for the self-planting saplings for servers to be finished soon. I don't know if either of you would have the time to collaborate (or even want to) but it's an idea.
    Anyway going to try this plugin out. If I do find any bugs I'll report back. The more testers the better.
     
  23. Offline

    BlackNAvi

    Yes, I also use Nature Overhaul...great mod! Can you make this mod so trees drop apples and coacoa?
    EDIT: So far I tried seeds next to water and they did not replant. I tried sugar cane and it DID replant itself.
     
  24. Offline

    Allen Buckman

    a bug i found, saplings(probly all things but saplings in my case) don't always dissapear after planting a sapling and they seem to replicate themselves if they cant find a block to be planted on. it might be caused by a combination of plugins but this problem almost crashed my server :(.
     
  25. Offline

    pegasus

    Okay, so saplings seem to always plant generic trees, regardless of what kind of sapling they are. Kind of disappointing. Think that could be fixed? Also, CB1000 bitches very loudly when doing a /reload --

    It goes on for quite a bit. Even if it's just cosmetic, it'd be nice if the messages went away. If you need reproduction steps, let me know.
     
  26. Offline

    Steelstiletto

    Would you mind posting the source for this? I'm interested to see how you did it.
     
  27. Offline

    pegasus

    Further bug report: When breaking a self-planted sapling, it drops the sapling *and* does not break, leading to duplication. Breaking the sapling again will drop another sapling and break, making two dropped saplings, at least one of which will self-plant, allowing you to repeat the process and generate infinite dropped saplings.

    I would love to use this plugin. Please see if you can fix these problems.
     
  28. Offline

    pegasus

    Fixed your sapling type problem for you.

    In org/CaiusTSM/SelfPlanting/SelfPlanting.java:

    replace this:
    with this:
    That'll make birch saplings plant birches and redwood saplings plant redwoods. Tested working. I haven't figured out the duping error or the async task error yet. Publishing the source would probably help, so I don't have to mess with jad's screwy decompiled code. Although it actually did pretty well on this one.

    After spending quite a bit of time with the code base, I came to realize that the way this plugin goes about Entity tracking is all wrong. onPlayerPickupItem gets a PlayerPickupItemEvent, which does not contain an Entity object. It contains an Item object. They are not the same. An Entity is a specific instance of an Item. You need the Entity object to properly remove the specific Entity from the planting queue. Instead what this plugin does is removes the oldest Entity from the queue with the same Material type as what the player just picked up. Most of the time this isn't a problem, as the EntityScanner picks it up again. Except when there is a sapling floating on the ground, say in tall grass, or inside another planted sapling, or hanging off a ledge, and you pick up a different sapling, the picked-up sapling does not register as picked up. The floating one does. It's been in the queue longer. So the next plantAction pass plants the newer sapling -- the one you picked up -- instead. Then the EntityScanner comes along and picks up the old floater again. Repeat until your inventory is full of saplings.

    There are a mess of sanity checks in the code, and I couldn't for the life of me figure out why. Turns out they're there because of this. I think I can work out a way of doing this properly, but I've been banging on this all night, and it will have to wait until the morning. Notes for myself, though:

    1) track all created entities we're interested in. don't bother tracking their destruction.
    2) check that the entity still exists before planting, if so, plant-and-destroy it. if not, delete it from our list.

    The list will get relatively large and float around a lot, but I'm pretty sure this is the only way to actually do what this plugin is meant to do. Thanks to Caius for getting me started by writing this, but I'm pretty sure this implementation won't work. Bukkit just doesn't have the right data in the onPlayerPickupItem event.

    I may be able to tighten up the list in the EntityScanner by checking the isDead property, though. So that's what I'll be doing tomorrow. Unless I get distracted. I'm kind of a ferret that way.

    Good morning.

    http://pegasus.pimpninjas.org/minecraft/SelfPlanting.jar - v1.4 tested working in CB1038, no dupes, proper sapling type planted. Source included.

    That sorts out the last player-visible issue with this plugin. Now if someone could just tell me how to fix the async task reload problem...

    Also, Hi Fluffgar. Post something. :)

    EDIT: Oh yeah, I also forgot to mention, this one will properly plant sugar cane *DIAGONAL* to water, as well as *IN* water. So yeah. Free improvements with your bug fixes.

    EDIT3: Seems I can't plant sugar cane diagonally or in water in the vanilla game? So I changed it back to only beside water. Whatever. v1.4.1 Same URL.

    EDIT2: One last thing, I decreased the size of the tracking array by 1/3rd, and the size of the plugin by something like half (I didn't actually check). If you run a large multiplayer server or run with large planting delays (more than a second or two), increase the hell out of the PlantLimit or you'll have a lot of things not self-planting -- by design.

    Previously the PlantLimit wasn't even respected, so if you had no problem with it before, increase it to a ludicrous amount. Like 1024 or something.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 17, 2016
    Fluffgar likes this.
  29. Offline

    Fluffgar

    Could this plugin be the source of the strange "[WARNING] Can't keep up" style message I keep getting? It seems to happen randomly but borks my entire server world when it does. I'm the only one on it at the moment and the machine I'm using should be well capable of dealing with the needs of a small server.

    I didn't think it could be this mod (I don't have many) but @pegasus mentioned something about "entities" and it reminded me that just before server borking I get some error that mentions that. I hope it isn't this mod as I like saplings, etc. planting themselves and haven't spotted any other plugin that does this so far. If it is something to do with this mod I hope it can be fixed fairly simply and quickly.

    Thanks modders. We love your stuff :)

    I think this is the right bit, @pegasus (attached).
     

    Attached Files:

    Last edited by a moderator: May 18, 2016
  30. Offline

    pegasus

    That is a weird bug. That's apparently a glitch in Chunk.java -- in the actual server, unrelated to anything I've looked at, and triggered by an entity move event. SelfPlanting shouldn't be related to that at all. You are right, though, you're not running very many plugins at all. I don't have MineBackup, though. That's the one that I think would be most likely to be the culprit. You might try pulling that out and see if things improve. Also, try SelfPlanting 1.4.1, linked on the previous page. If nothing else, your plants will plant properly.

    After messing with the source for a bit longer, I've worked out that the async reload error is because apparently the runnable worker thread isn't terminating properly after finishing all its work. Program flow reaches the end of the (void) function, but then somehow hangs (on the final closing bracket, mind) or fails to be reaped or something. I don't see any methods in the Bukkit docs about forcibly terminating a worker thread, or anything about anything special that needs to be done to terminate a worker thread. So I'm at a loss. I need someone who's solved this in their plugin to give me a pointer here.

    In the meantime, the ActiveWorker pool is just going to grow and grow and grow... Not a good thing.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 17, 2016

Share This Page