Blocks aren't Replaced

Discussion in 'Plugin Development' started by WeaselBuilds, Apr 12, 2014.

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

    WeaselBuilds

    Hi there! I have been trying to crack my problem for days now, and it seems that whenever I call a block to be set to something, it isn't replaced. I know it sounds fairly simple, but I need some help.

    SOME (I said some. Just ask for more) Code:
    Code:java
    1. for (Block blk : blocks) {
    2. if(!blk.getType().equals(Material.AIR)) {
    3. blk.setType(Material.AIR); //Doesn't work, but doesn't throw an error :S
    4. }
    5. }


    I would be very thankful if anyone can help. Thanks
    ~Weasel
     
  2. Offline

    WhatAaCow

    i think you need to add
    Code:java
    1. blk.getState().update(true);

    in your if
     
  3. Offline

    St3venAU

    That code looks fine, assuming "blocks" actually contains a list of blocks. I'd say the problem may be with that part of the code that creates the list of blocks.
     
  4. Offline

    WeaselBuilds

    Ok I will try that. Thanks for the quick response!

    I'll check that too. I know it gets the correct blocks because I actually put some code to where that it broadcasts the block type and location (and it lagged the crap outta me). Thanks!

    St3venAU I tried changing the type of list of the blocks (really didn't matter because it was an ArrayList of Blocks)

    And WhatAaCow I tried adding that line, but didn't help.

    Sorry I double posted, but it won't let me edit my previous post in Firefox :S

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
Thread Status:
Not open for further replies.

Share This Page