Auto block placer

Discussion in 'Plugin Development' started by benthomas7777, Jun 24, 2013.

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

    benthomas7777

    Hey, I was playing in survival and wanted a plugin that would auto place blocks. The block I wanted to place was saplings. Is there a plugins that does this. If not then can you give me help to make it so that when you place a custom dropper it will place the block it contains when it receives redstone signal. Thanks for help, but I am new to programming and plugin dev, so the more help the better.
     
  2. Offline

    valon750

    Hmm, well I'd assume you could maybe check for an event when redstone powers a block? not sure if one exists, should do...

    then get if it's a dropper... get the direction it's facing... then set the block based on it's direction plus 1?

    It's late and I've not had a cup of tea all day, so that's the most detailed I can get in to right now, sorry about that.
     
  3. Offline

    toughenough6


    In addition to that be sure to check whether or not that block above is air, just saying. Don't want to go replacing blocks, do we?
     
  4. Offline

    valon750

    toughenough6

    Running low on brain power, fetch me a cup of tea and I'll be at full working order again!
     
  5. Offline

    benthomas7777

    I think I can work out how to place the block, check droppers inventory, but not the first things. Like how to create a new crafting recipe for a new block, then check if that block is powered, get the direction. So any more help at some point would be helpful.
     
  6. Offline

    valon750

    benthomas7777

    Luckily my friend, making a custom recipe couldn't be easier!

    Now, issue is that when you place / break a block, it will lose things such as lore or display name, I THINK you could use something like a HashMap, but I'm afraid someone else would need to help with that as I'm god awful at those.
     
  7. Offline

    benthomas7777

    Hi,can someone provide me with the code for when the block is crafted, when it is destroyed, when it is placed and when it receives a redstone signal so I can put the code in, i am really bad with hash maps. It would be very helpful! Thanks

    valon750 Do you know the code or could help me with code for what I said above, please?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 2, 2016
  8. Offline

    MehrPvM

    benthomas7777 For the block being broke it would be this event:
    Code:java
    1. public void onSaplingBreak(BlockBreakEvent event){
    2. float x = event.getBlock().getX();
    3. float y = event.getBlock().getY();
    4. float z = event.getBlock().getZ();
    5. World world = event.getBlock().getWorld();
    6. if (event.getBlock() == Block.SAPLING ){
    7. Location blockloc = (new Location(world, x, y, z));
    8. /*
    9. location of the block is now blockloc so you can set it or whatever
    10. also, anything within here is always refered to if the block broke is a sappling
    11. */
    12.  
    13. }else{
    14. /*
    15. Anything here is what's done if it's not a sapling You can leave blank if you want it to do nothing
    16. */
    17. }
    18.  
    19.  
    20. }
     
  9. Offline

    chasechocolate

    MehrPvM yes, except change the x, y and z variables to ints because Location takes ints instead of floats as constructor parameters.
     
Thread Status:
Not open for further replies.

Share This Page