Solved Block data not updating?

Discussion in 'Plugin Development' started by timmaker, Aug 16, 2017.

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

    timmaker

    Hey, this might be a really stupid question or just something i'm over looking but when i set the data of a block using Block#setData(byte) the block doesn't update. This is my code:

    Code:
    if (inHand.getItemMeta().getDisplayName().equals("All bark Birch log")) {
                        event.getBlockPlaced().setData((byte) 14);
    }
    I'm sure this code is being executed. I've done some testing on this aleady.

    Any help is apreciated :)
     
  2. Offline

    Zombie_Striker

    @timmaker
    Does setData work at all for the placed block? What happens if you try to set the value to 0 (oak log)? Does this change the birtch block to an oak block? If so, the issue may have something to do with the exact value of 14. If not, then the issue is with calling the setData method on the placed block, in which case, you may have to wait one tick before changing the value.
     
  3. Offline

    timmaker

    Okay turns out it was indeed a really stupid mistake, i forgot i used ChatColor.RESET in the name so the 2 didn't match completely, changed it to contains and evrything was fine
     
  4. Offline

    Luke_Lax

    You should youse ChatColor.stripColor() which returns 'A copy of the input string, without any coloring'
    Code:
    if (ChatColor.stripColor(inHand.getItemMeta().getDisplayName()).equals("All bark Birch log")) {
                        event.getBlockPlaced().setData((byte) 14);
    }
     
Thread Status:
Not open for further replies.

Share This Page