Test for a block by a block

Discussion in 'Plugin Development' started by Ward1246, Mar 5, 2015.

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

    Ward1246

    This sounds a little confusing, but i am trying to test a block by a block. Specifically, i am trying to test if fire is near redstone dust. Open the spoiler below to get good detail of what i mean (it's in a spoiler because it's very long)

    Show Spoiler

    Ok, so we are looking if redstone dust is anywhere in the world and then we look if fire is right next to it, if this is true it makes the redstone near it become fire screenshots for example:

    Redstone is found, code is still false, there is no fire
    [​IMG]

    The code is true, there is redstone with fire near it (the redstone gets set to fire, that's what this is intended to do)
    [​IMG]
    Code true as well
    [​IMG]
    Code still true
    [​IMG]
    Code still true
    [​IMG]

    The code is meant to find the redstone, and make it fire. The code will only fire *Ha get it?* if they are like in the image, the code will not fire if it's diagonal. However, it can still fire if its up/down a block. See this screenshot/gif:

    [​IMG]

    I only need 2 codes, and that's to test if a block is near a block, and getting that block and making it fire. I added the screenshots to shot exactly what i am going to do to try and help you understand what is going on. I can't use a radius, like i said it cannot be diagonal.


    I hope this isn't to confusing and thank you for any help.
     
  2. Offline

    pie_flavor

    @Ward1246 Well, since redstone dust can be placed but fire can be placed, spawned with a flint'n'steel, or spread, you should check for a BlockSpreadEvent and a BlockPlaceEvent, check everywhere you plan on checking relative to the block, and set the block to fire. Also probably throw another BlockSpreadEvent.
     
  3. Offline

    mine-care

    You can also us BlockFace of the redstone placed. Check south,north,east,west and so on this way you will find the cross pattern seen in your screenies, and not the diagonal parts.
    PS nice joke "event FIRES" xD xD
     
  4. Offline

    Ward1246

    I see, but i am not sure how to test for the block, but i see how to test for the block
    if (Block?.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() == Material.FIRE)) {
    How should i signal that i am testing for redstone? Thanks, and i'm glad you liked the joke :D

    Also, would it be something like this? *Except get block somehow*
    public void Block(*SomethingEvent* event) {
     
  5. Offline

    mine-care

    Yep, you need an event. In BlockPlaceEvent check if placed block is redstone and of so, use the if you have above.
     
  6. Offline

    Hex_27

    @Ward1246 Try block.getRelative(x, y, z). Then check for each direction if its Material.FIRE. If it is, then run your code.

    Or you could use BlockSpreadEvent or something like that to check fire spreading and check the nearby blocks if theres redstone.
     
  7. Offline

    Ward1246

    Still not working
     
    Last edited: Apr 21, 2015
  8. Offline

    SirMonkeyFood

    Probably not the most efficient way of doing it, but I've always used this:
    Code:
    Location loc1 = click.getClickedBlock().getLocation();
            loc1.setX(loc1.getX() -1);
            
     
Thread Status:
Not open for further replies.

Share This Page