Inactive [INACTIVE][WGEN] BananaImageToMap v3.1 - now with proper ores! [1000]

Discussion in 'Inactive/Unsupported Plugins' started by codename_B, Jun 22, 2011.

     
  1. Offline

    codename_B

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    BananaImageToMap
    turn any image into a world!

    Version 3.1
    Download Here
    Github


    Configuration options:
    • image to use
    This plugin allows you to turn any image into a world - this means it can be generated with, for example, BananaMapRender, and do stuff like this!



    That's right, heightmaps translated to maps in-game, for zero effort, just configure the worldname and the image and you're away!

    Remember:
    You need to configure your bukkit.yml correctly and start with a fresh world before using this or it will not work.
    Code:
    worlds:
          worldname:
                 generator: BananaImageToMap
    
    Includes:
    • CavePopulator
    • DesertPopulator
    • DungeonPopulator
    • FlowerPopulator
    • LakePopulator
    • Mushroom Populator
    • QuarryPopulator
    • Ruins Populator - thanks @Nightgunner5
    • Snow Populator
    • SpookyRoomPopulator
    • TorchPopulator - thanks @Nightgunner5
    • Tree Populator - thanks @heldplayer and @SpaceManiac
    • Ores! - thanks @Notch
    Fun extras:
    • Will generate a heightmap image if you don't specify any!
    Screenshots:
    [IMG]

    [IMG]

    Changelog:
    • v1 - released awesome plugins
    • v2 - added block populator for ores, thanks @Pandarr also added awesome cavegen, thanks me!
    • v3 - added fixed populators and cleaned up code, thanks @SpaceManiac (no extra configuration options this time - sorry) :p
    • v3.1 - re-added caves (minus the memory leak) - added proper ore population :D
    hammale, TAT, AS1LV3RN1NJA and 8 others like this.
  2.  
  3. Offline

    codename_B

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    outside the image generates simply flat water with stone.
  4. Offline

    codename_B

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    That would look absolutely terrible in-game.
  5. Offline

    DreadKyller

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    @codename_B no it would not, in fact it's been suggested like 8 times, to make a map that has different color values to define the top block type. If he's talking about a color map like using colors to define the heights and stuff just the lighter the color the higher and vis-versa
  6. Offline

    Shamebot

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Are you still interested in something like that?
  7. Offline

    codename_B

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Oh, if he means a color map - then that is already supported. Why not try it out first before judging? Just because other people haven't used a color map doesn't mean that this doesn't support it.
    VERY!
  8. Offline

    codename_B

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    @everyone - v2 is out
  9. Offline

    davr

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    If you wanted to allow any arbitrary block type, you could do something super simple like this:

    Code:
    Block getBlockFromColor(int color) {
    
      Block b = new Block();
    
      b.setType(color & 0xFFFF);
    
      b.setData((color >> 16) & 0xFF);
    
      return b;
    
    }
    Then the block type ID is specified by the green & blue components of the color, and block data is specified by the red component.

    If you actually want to match the block's appearance to be as close to the color of the pixel, then it's a little more complex. Check out this code for an example method (from the mxImgImport plugin)
  10. Offline

    codename_B

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Unless someone actually writes me a function that I can plug in a color and get out a blockID I'm not actually going to add it XD

    Those are my terms :p
  11. Offline

    davr

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    I wrote you one function already, the simple method. Here's the code copied & pasted out of the other plugin into a function for you as well. Note you cannot just use block ID, you need both ID and Data...since Data is what specifies the color for wool.

    This code only uses a limited set of materials, if people want more, you just need to add it to the list (the long lines of pBlockMap.put... etc)

    Code:
    class MatM
    {
        MatM(Material m, int s)
        {
            mat = m;
            ss = s;
        }
        
        Material mat;
        int ss;
    }
    
    class RGB
    {
        
        RGB(Color a)
        {
            r = a.getRed();
            g = a.getGreen();
            b = a.getBlue();
        }
        
        public RGB(int red, int green, int blue) {
            // TODO Auto-generated constructor stub
            r = red;
            g = green;
            b = blue;
        }
    
        int getRed(){
            return r;
        }
        
        int getGreen(){
            return g;
        }
        
        int getBlue(){
            return b;
        }
        
        int r;
        int g;
        int b;
    }
    
    float ColorDistance(RGB a, RGB b)
    {
        int most = 0;
        if (a.getRed() > a.getGreen() && a.getRed()>a.getBlue())
            most = 1;
        else if (a.getGreen() > a.getRed() && a.getGreen()>a.getBlue())
            most = 2;
        else    most = 3;
        
        RGB c = new RGB(b.getRed()-a.getRed(),b.getGreen()-a.getGreen(), b.getBlue()-a.getBlue());
        float clen = c.getRed()*c.getRed()*(most ==1?1:2)+c.getGreen()*c.getGreen()*(most ==2?1:2)+c.getBlue()*c.getBlue()*(most ==3?1:2);
    
        return clen;
    }
    
    @Override
    public Block getBlockFromColor(int pixel) {
        HashMap<RGB, MatM> pBlockMap = new HashMap<RGB, MatM>();
        pBlockMap.put(new RGB(160,160,160), new MatM(Material.STONE, 0));
        pBlockMap.put(new RGB(188,152,98), new MatM(Material.WOOD, 0));
        pBlockMap.put(new RGB(255,255,255), new MatM(Material.WOOL, 0));
        pBlockMap.put(new RGB(214,207,154),new MatM( Material.SANDSTONE, 0));
        pBlockMap.put(new RGB(196,86,205), new MatM(Material.WOOL,1));
        pBlockMap.put(new RGB(114,147,215), new MatM(Material.WOOL, 2));
        pBlockMap.put(new RGB(33,200,214), new MatM(Material.WOOL, 3));
        pBlockMap.put(new RGB(210,210,14),new MatM( Material.WOOL, 4));
        pBlockMap.put(new RGB(100,230,0),new MatM( Material.WOOL, 5));
        pBlockMap.put(new RGB(224,155,173),new MatM( Material.WOOL, 6));
        pBlockMap.put(new RGB(71,71,71),new MatM( Material.WOOL, 7));
        pBlockMap.put(new RGB(173,180,180),new MatM( Material.WOOL, 8));
        pBlockMap.put(new RGB(43,129,166),new MatM( Material.WOOL, 9));
        pBlockMap.put(new RGB(90,0,90),new MatM( Material.WOOL, 10));
        pBlockMap.put(new RGB(40,53,161),new MatM( Material.WOOL, 11));
        pBlockMap.put(new RGB(93,56,30),new MatM( Material.WOOL, 12));
        pBlockMap.put(new RGB(57,78,25),new MatM( Material.WOOL, 13));
        pBlockMap.put(new RGB(250,0,0),new MatM( Material.WOOL, 14));
        pBlockMap.put(new RGB(0,0,0),new MatM( Material.WOOL, 15));
        pBlockMap.put(new RGB(150,125,70),new MatM( Material.LOG, 0));
        pBlockMap.put(new RGB(57,46,28),new MatM( Material.LOG, 1));
        pBlockMap.put(new RGB(255,251,93),new MatM( Material.GOLD_BLOCK, 0));
        pBlockMap.put(new RGB(213,213,213),new MatM( Material.IRON_BLOCK, 0));
        pBlockMap.put(new RGB(176,176,176),new MatM( Material.DOUBLE_STEP, 0));
        pBlockMap.put(new RGB(46,46,61),new MatM( Material.OBSIDIAN, 0));
        pBlockMap.put(new RGB(120,108,30), new MatM(Material.CHEST, 0));
        //pBlockMap.put(new RGB(35,80,35),new MatM( Material.MOSSY_COBBLESTONE, 0));
        pBlockMap.put(new RGB(160,240,240),new MatM( Material.DIAMOND_BLOCK, 0));
    //        pBlockMap.put(new RGB(100,56,56),new MatM( Material.NETHERRACK, 0));
    //    pBlockMap.put(new RGB(200,0,200),new MatM( Material.GLOWSTONE, 0));
        
        
        int alpha = (pixel >> 24) & 0xff;
        int red = (pixel >> 16) & 0xff;
        int green = (pixel >> 8) & 0xff;
        int blue = (pixel) & 0xff;
    
        Block b = new Block();
    
        RGB c = new RGB(red, green, blue);
    
        Set<Entry<RGB, MatM>> pSet = pBlockMap.entrySet();
        Iterator<Entry<RGB, MatM>> It = pSet.iterator();
    
        float bestDist = 100000000;
        RGB col = null;
    
        while(It.hasNext())
        {
            Entry<RGB, MatM> Current = It.next();
            float dist = ColorDistance(c,(Current.getKey()));
    
            if (dist < bestDist)
            {
                bestDist = dist;
                col = Current.getKey();
            }
        }
            
        m_pUndoMap.put(curpos,new MatM(curpos.getBlock().getType(), curpos.getBlock().getData()));
    
        b.setType(pBlockMap.get(col).mat);
        b.setData((byte)pBlockMap.get(col).ss);
    
        return b;
    }
    
  12. Offline

    codename_B

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Ok, so how do I use it?

    EDIT: hmmmm, that would need a little changing but I'll try it.

    EDIT: that would need a lot of changing. There's several things in that that aren't related to anything. Write me a nice class, and I'll do it.
  13. Offline

    davr

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    It's your plugin, not mine...if I were to write a nice class I'd write my own plugin :p
  14. Offline

    codename_B

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Hey, it's simple as if people want the ability to draw an image in anything other than height - they need to write a function to transform a color into a block ID with a corresponding color. If noone does that, I won't add it as I have no desire to see that as a feature.
  15. Offline

    LanToaster

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Can you maybe Hook into the WorldGeneration and Generate stuff below the Heightmap?
  16. Offline

    codename_B

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    ?
    This IS a world generator - and it generates ores and stuff below the heightmap already :S
  17. Offline

    LanToaster

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    I Thought it was just the HeightMap, because it says "Coming Soon" for Trees and Ressources.
  18. Offline

    codename_B

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    If you look at version 2 (which only worked yesterday on a non-RB, it has it)
  19. Offline

    sfxworks

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    ...THIS will be EXTREMELY USEFUL
  20. Offline

    sfxworks

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Also, do I take any old image? Is it 1 pixed per block? Anyway to edit the amount of ore spawning? Tree spawning? Can a certain color be a certain biome? Does darker = Higher? Can I add custom trees and dungens using the BO2 populator?

    What you here THE TOOL I have been looking for. Im looking to make continents and oceans and this is A LOT easier than doing it by hand.
  21. Offline

    codename_B

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    It takes any old image: yes.
    It it one pixel per block? yes.
    No way currently, but I can add it for you easily.
    You can turn tree spawning on/off in the config.
    I tried the BO2 populator, but it's not working very well, once that is working better there is no reason I couldn't use it.
    The way the heightmap works is the way any heightmap works - white = highest, and for color, the height is a function of R+G+B.

    Any image at all :D ;) :O

    p.s. pm me about working on things for $$$.
  22. Offline

    LanToaster

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Iam Trying this out with a 2500X2500 Image. But the Plugin just says:
    So, it doesnt Create a World with the Name i Specified, or does use the Image if I create a World with Multiverse.

    Tried to set it to Default aswell.
    Hope you can tell me what i did wrong.
  23. Offline

    sfxworks

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Yo! I don't know if you received my pm. I would really like your help in modifying this plugin to fit my needs. Please email me at sfxworks@gmail.com if you are interested.
  24. Offline

    codename_B

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    I'm pretty sure it generated an world from the image you specified considering it loaded that successfully, I guess it's not 100% multiverse compatible or something - go post on their thread - I know for a FACT that this generates lovely worlds.
  25. Offline

    LanToaster

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    So, tested it Without any other Plugin:
    Config:
    ServerLog:
    And no world_ocean to be found.

    Also, it would be great if you could set the WaterLevel via ConfigFile.
    So i could raise the WaterLevel in my Ocean World.
  26. Offline

    Dinnerbone Bukkit Team Member Administrator

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Getting many concurrent modification exceptions while running this, but I do love the results. They seem to have a % of happening at any moment a new chunk is generated, with or without anyone online.

    Code:
    2011-06-26 04:41:49 [SEVERE] java.util.ConcurrentModificationException
    2011-06-26 04:41:49 [SEVERE]    at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:782)
    2011-06-26 04:41:49 [SEVERE]    at java.util.ArrayList$Itr.next(ArrayList.java:754)
    2011-06-26 04:41:49 [SEVERE]    at com.ubempire.map.FlatMapPopulator.populate(FlatMapPopulator.java:57)
    2011-06-26 04:41:49 [SEVERE]    at net.minecraft.server.ChunkProviderServer.getChunkAt(ChunkProviderServer.java:193)
    2011-06-26 04:41:49 [SEVERE]    at net.minecraft.server.ChunkProviderServer.getChunkAt(ChunkProviderServer.java:103)
    2011-06-26 04:41:49 [SEVERE]    at org.bukkit.craftbukkit.CraftWorld.getChunkAt(CraftWorld.java:92)
    2011-06-26 04:41:49 [SEVERE]    at org.bukkit.craftbukkit.CraftWorld.getBlockAt(CraftWorld.java:60)
    2011-06-26 04:41:49 [SEVERE]    at org.bukkit.craftbukkit.CraftWorld.getBlockAt(CraftWorld.java:461)
    2011-06-26 04:41:49 [SEVERE]    at com.ubempire.map.FlatMapPopulator.populate(FlatMapPopulator.java:70)
    2011-06-26 04:41:49 [SEVERE]    at net.minecraft.server.ChunkProviderServer.getChunkAt(ChunkProviderServer.java:193)
    2011-06-26 04:41:49 [SEVERE]    at net.minecraft.server.ChunkProviderServer.getChunkAt(ChunkProviderServer.java:111)
    2011-06-26 04:41:49 [SEVERE]    at org.bukkit.craftbukkit.CraftServer.createWorld(CraftServer.java:432)
    2011-06-26 04:41:49 [SEVERE]    at org.bukkit.craftbukkit.CraftServer.createWorld(CraftServer.java:375)
    2011-06-26 04:41:49 [SEVERE]    at com.ubempire.map.NoisyMap.onEnable(NoisyMap.java:45)
    2011-06-26 04:41:49 [SEVERE]    at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:126)
    2011-06-26 04:41:49 [SEVERE]    at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:857)
    2011-06-26 04:41:49 [SEVERE]    at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:264)
    2011-06-26 04:41:49 [SEVERE]    at org.bukkit.craftbukkit.CraftServer.loadPlugin(CraftServer.java:151)
    2011-06-26 04:41:49 [SEVERE]    at org.bukkit.craftbukkit.CraftServer.enablePlugins(CraftServer.java:136)
    2011-06-26 04:41:49 [SEVERE]    at net.minecraft.server.MinecraftServer.e(MinecraftServer.java:284)
    2011-06-26 04:41:49 [SEVERE]    at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:271)
    2011-06-26 04:41:49 [SEVERE]    at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:148)
    2011-06-26 04:41:49 [SEVERE]    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:335)
    2011-06-26 04:41:49 [SEVERE]    at net.minecraft.server.ThreadServerApplication.run(SourceFile:422)
  27. Offline

    TheBritishEditor

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    I'm looking to generate an oceanic-continental world, and to do so I'm editing a pre-generated minecraft cartograph with paint to create vast oceans. I then want to generate that world. Can you hook me up with something that'll allow me to convert this cartograph png into a heightmap? Thanks.
  28. Offline

    DreadKyller

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    as seing a cartograph usually has deeper oceans a deeper blue, then just using the colored map image should give some of the result, if not just more editors have a "Convert to black and white" use that, and that should give you a fairly decent hightmap
  29. Offline

    codename_B

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Thanks for the feedback db, I'll look into this and see if I can sort it, I have an idea of the code that could be causing that.
  30. Offline

    Dinnerbone Bukkit Team Member Administrator

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    (I fixed it myself by just making a copy of the snake list and working on that, while resetting the original)
  31. Offline

    DreadKyller

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    @codename_B if you don't know where it is the error shows the line. line 57 in FlatMapPopulator.java.
  32. Offline

    codename_B

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Would you mind posting your fix? :) It would save me a little bit of effort.
    P.S. glad you're finding this useful :D nice to know that even the bukkit admin team like a bit o' banana ;)

Share This Page