Mycelium/Grass Changes

Discussion in 'Plugin Development' started by cadika_orade, Oct 4, 2012.

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

    cadika_orade

    I am looking to modify the growth behavior of mycelium blocks.

    Specifically, I would like them to follow their existing growth patterns but do so faster and consuming grass blocks, logs, planks, and pretty much any other organic blocks they come across.

    As a bonus, it would be nice if they would automatically change the biome to Mushroom as they grow, and have a small chance of spawning a giant mushroom, but that's a later goal.

    I'm new to listeners and such, and all my plugins so far have been simple commands. Does anyone have any ideas of what I can look at to get an example of how to do what I'm trying to do? I'm not asking anyone to write my plugin for me, but something remotely similar to dissect would be appreciated.
     
  2. Offline

    nathanaelps

    I wonder if this thread would spark any great thoughts:
    http://forums.bukkit.org/threads/grass-blocks-are-the-bane-of-my-existence.75048/

    Besides digging through all of that, I think BlockSpreadEvent would be interesting to you. Make it so that any time mycelium blocks spread, they would replace touching (grass, plank, log, etc) with dirt, as well as:

    Code:
    location.getBlock().getRelative(i, 0, j).setBiome(biome);
    int x = location.getChunk().getX();
    int z = location.getChunk().getZ();
    location.getWorld().refreshChunk(x, z);
    
    to update the biome.

    That doesn't speed the spread up, but it does make it *able* to eat everything else. I don't know of any other way to do that.
     
  3. Offline

    hawkfalcon

    A well spoken person! Welcome to the forums!
     
  4. Offline

    Woobie

    Both of them joined about 1 year ago, who are you talking to? :eek:
     
  5. Offline

    hawkfalcon

    cadika_orade
    Messages: 16 Likes Received: 1
     
  6. Offline

    cadika_orade

    Fantastic! Learning Java in 4 hours was easy. The hard part is finding out what Bukkit is capable of, and what functions I use for each kind of task.

    I feel quite welcome, thanks! To explain my still being new after a year, I created an account here to request a plugin, but it never got made. :/

    After hiring three programmers and having every one of them flake out on me, I decided to learn Bukkit myself.

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

    The_Coder

    Sorry to hear that, we programers are very busy people sometime and forget about plugin requests sometimes.
     
  8. Offline

    cadika_orade

    As a (non-Java) programmer myself, I can understand that. But being hired to make a plugin for a server and then just flaking out? That's different.
     
  9. Offline

    The_Coder

    Yes that is different
     
  10. Offline

    cadika_orade

    Alright. It isn't working and I'm probably missing something obvious.

    So far I have:

    Code:
    public void onBlockSpread (BlockSpreadEvent event)
        { 
            if (event.getSource().getTypeId() == 110)
            {
                int targetId = event.getBlock().getTypeId();
                Block target = event.getBlock();
               
                if (targetId == 2 || targetId == 3 || targetId == 5 || targetId == 17 || targetId == 60 || targetId == 9) 
                {
                    target.setTypeId(110);
                }
            }
        }
    And in my Main:

    Code:
    public void onEnable()
        {
            PluginManager pm = getServer().getPluginManager();
            pm.registerEvents(new FungusBlockListener(), this);
        }
    But the result is that mycelium still only grows on to dirt.

    If I had to hazard a guess, I'd say the issue lies in onBlockSpread, and my general ignorance of how the BlockSpreadEvent functions. I'm guessing that this event is applied to every growing block, grass or mycelium. I'm also guessing that the target block is a random adjacent block.

    I'm also guessing that I'm guessing wrong.

    In case it isn't obvious right away from looking at my code, I'm making mycelium into something of a doomsday block. Placing a single block will set off a chain reaction transforming dirt, grass, logs, planks, farmland, and even water (still debating on that one) into mycelium. Forests and jungles will die. Buildings will be ruined. Whole biomes will be uninhabitable. A single block of mycelium will create a cancer of the Earth more dangerous than any fire.

    This will not only help discourage settlement on mushroom islands, but also create a new, devastating threat for those lucky players on my server who have made mycelium-lined pens to make they mooshrooms feel at home.

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

    nathanaelps

    That, my friend, is one chestnut I haven't cracked yet. But I did tinker about, and this is what I've come up with:

    https://github.com/nathanaelps/Mush...ushroomislandspread/MushroomIslandSpread.java

    And get the plugin here, just to check it out.

    This was extremely fun to thinker with. Extremely.

    And in regard to BlockSpreadEvent, I *believe* that event.sourceBlock() will always be either Grass or Mycelium, and that event.targetBlock() will always be dirt. I don't think you can change what it targets... it's further up the chain, in Places that I Dare Not Tread... Yet. Which is why I turned the blocks around the mycelium into dirt, which could then spread.

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

    cadika_orade

    Well, I'm thinking of doing either that or simply turning the adjecent blocks into mycelium directly. I'll try your method first. Thanks!

    EDIT: I didn't see your first post there. Thank you for going to so much trouble for me. xD

    Wow. Your handing me a bunch of code (Java? Bukkit?) that I've never seen before. Dissecting it now. I find that this is the fastest way for me to learn anything. If I hit anything I can't figure out I'll ask. :3

    Thanks!

    Okay... confused...

    Couldn't understand why nothing I tried worked, then I tried dropping in your plugin and nothing happened.

    EDIT: Apologies. It seems that it doesn't work until I restart the whole server, as opposed to a simple /reload. Now ti figure out what I was doing wrong. XD

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

    nathanaelps

    Hm. And I'll try to figure out why it doesn't /reload for you... I ran into that the other day and just wrote it off as "feature"...

    Also, I'll see if I can add some comments, 'cause... I'm needing to practice "commenting code".

    Mkay. The github repo should have the comments built in. I'll update the .jar file later.

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

    nathanaelps

  15. Offline

    cadika_orade

    This is brilliant. I feel bad that you have pretty much written the whole thing for me, but it is good because I learn best by example. Direct instruction is wasted on me.

    Sorry I've been off. I really appreciate all your help, but college is more important. I'll have more time this weekend. :3

    Oh, and the Github link from before doesn't work.

    Is there a new one?

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

    nathanaelps

  17. Offline

    cadika_orade

    Unfortunately, I had to stop using your plugin. It seems to place red and brown mushrooms on the ground which pop off instantly. This makes for hundreds of items just laying around, which creates vast amounts of server and client rendering lag.

    I tried to edit your code to remove the lines I *thought* caused it, but instead it just broke the entire plugin completely.

    Sorry to reply a month later, but I've been so swamped I can barely think, much less think about Bukkit. :/
     
Thread Status:
Not open for further replies.

Share This Page