Solved Cannot change direction of tripwire hook

Discussion in 'Plugin Development' started by HamOmlet, Oct 28, 2012.

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

    HamOmlet

    I recently stumbled upon this particular thread detailing how to get a block's data during a block place event:

    http://forums.bukkit.org/threads/block-data-for-rotated-logs.90986/

    However, I'm having the same issue when trying to rotate a tripwire hook that is placed at a certain location. It might be worth mentioning that this bit of code is within a delayed task which deals with the block place event. This code is executed after some logic as well, but I figured another delayed task could remedy the problem.

    Here's the code:
    Code:
    bl.setType(Material.TRIPWIRE_HOOK);
    Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
      public void run() {
        ((TripwireHook)bl.getState().getData()).setFacingDirection(BlockFace.SOUTH);
      }
    });
    
    The direction always point west. I've tried numerous adjustments but they don't seem to work. It leaves me wondering if it's possible to rotate a placed tripwire hook at this point.
     
  2. Offline

    Vandrake

    to make a block change direction such as pistons and stuff you need to change the data.
    That's how I do it.
     
  3. Offline

    HamOmlet

    I do believe I fixed it. I was setting the MaterialData rather than the data itself. Below is how I fixed the issue:

    Instead of doing this:
    Code:
    e.getBlock().getState().getData().setData((byte) 3);
    Do this:
    Code:
    e.getBlock().setData((byte) 3);
    Everything seems to be working normally now. Thanks for your advice! ;)
     
    Vandrake likes this.
Thread Status:
Not open for further replies.

Share This Page