Solved Detect String Activated

Discussion in 'Plugin Development' started by Klo1029, Oct 12, 2019.

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

    Klo1029

    In vanilla minecraft, observers, can detect when players stand on string - without tripwire hooks. If you face the observer into the string, then it works. Tripwire (placed string) has a "powered" data value - visible in F3.

    I want to detect the block update for when players stand on it - i have tried PlayerInteractEvent and BlockRedstoneEvent - neither of them fire for when players stand on the tripwire (without hooks). Is there an event that I can use to detect this?
     
  2. It should be handled with the PlayerInteractEvent. Check for a physical action and if the block is a string. Show your code if nothing happens
     
  3. Offline

    Klo1029

    @DerDonut

    Code:
    public class Plugin extends JavaPlugin implements Listener {
    
        public void onEnable() {
            Bukkit.getPluginManager().registerEvents(this, this);
        }
      
        @EventHandler
        public void onInteract(BlockRedstoneEvent event) {
            Bukkit.getLogger().log(Level.INFO, "test1");
            if (event.getBlock().getType() == Material.TRIPWIRE ||
                    event.getBlock().getType() == Material.STRING) {
                Bukkit.getLogger().log(Level.INFO, "test2");
            }
        }
      
        @EventHandler
        public void onInteract(PlayerInteractEvent event) {
            Bukkit.getLogger().log(Level.INFO, "test3");
            if (event.getMaterial() == Material.TRIPWIRE ||
                    event.getMaterial() == Material.STRING) {
                Bukkit.getLogger().log(Level.INFO, "test4");
            }
        }
      
    }
    When stepping on string none of the 4 activate
     
  4. Offline

    KarimAKL

    @Klo1029
    Check the block, not the item. (You can also check if the action is PHYSICAL first)
     
    DerDonut likes this.
  5. Offline

    Klo1029

    But "Test3" doesn't even fire when stepping on the string - what you suggested doesn't matter. PlayerInteractEvent doesn't fire when stepping on string without a tripwire hook. Im looking for the event that can detect that.

    @DerDonut
     
    Last edited: Oct 13, 2019
  6. Offline

    KarimAKL

    @Klo1029 Hmm.. That sounds pretty weird, it should work. Which version are you running & building for?
     
  7. Offline

    Strahan

    BlockPhysicsEvent will trigger if you walk on a tripwire that isn't using hooks.
     
  8. Offline

    Klo1029

    Thanks! that was the answer I was looking for!
     
Thread Status:
Not open for further replies.

Share This Page