Solved Pressure Plate activates Item

Discussion in 'Plugin Development' started by Script1996, Jul 19, 2014.

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

    Script1996

    Hey guys,

    which things I have to add into my if-clause, that my item doesn't get activated if it's in my hand and I'm walking over a pressure plate ?
     
  2. Offline

    endoml

    Script1996 Your question is a bit vague, but if your asking what I think your asking, use BlockRedstoneEvent.
     
  3. Offline

    Drew1080

    Script1996,
    Please show us some code that you have attempted to solve this issue. I'll give you a hint. For detecting when a player interacts with a pressure plate use the PlayerInteractEvent.
    What exactly do you mean by "that my item doesn't get activated if it's in my hand"?
     
  4. Offline

    Script1996

    My code in a PlayerInteractEvent is

    Code:
    if (is.hasItemMeta() && Spieler.getItemInHand().getItemMeta().getDisplayName().equals("testpotion")) {
     
                    int amount = Spieler.getItemInHand().getAmount();
                   
                    if (amount > 1){
                    Spieler.getItemInHand().setAmount(amount - 1);
                        Spieler.setItemInHand(Spieler.getItemInHand());
                        Spieler.updateInventory();
     
                    Spieler.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 600, 1));
                    Spieler.addPotionEffect(new PotionEffect(PotionEffectType.FAST_DIGGING, 600, 3));
                    Spieler.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 600, 1));
    And if I step on a pressure plate and wear the item "inHand" it gets activated without clicking mousebutton

    greetings,
    me
     
  5. Offline

    endoml

    Script1996 You could use BlockFace to get the block the player is above and Player.isOnGround() to check if they are standing on a pressure plate
     
  6. Offline

    Script1996

    isn't a player "OnGround" if he stands on a plate?

    do I just have to add "&& Player.isOnGround()" to my if clause ?
     
  7. Offline

    bobacadodl

    In your playerInteractEvent add a check for

    if(event.getAction() != Action.PHYSICAL) {

    }
     
    Script1996 likes this.
  8. Offline

    Drew1080

    Script1996
    Use the Action.PHYSICAL in your player interact event to see if they stepped on a pressure plate.
    Edit: ninja'd by bobacadodl
     
    Script1996 likes this.
  9. Offline

    FabeGabeMC

    Drew1080

    Not really, "!". It would have been == if it were Action.PHYSICAL.
     
    Script1996 likes this.
  10. Offline

    Drew1080

    FabeGabeMC
    Yeah I see that now. When I edited my post it was right after I posted and saw the post above mine using Action.Physical in it. Then after I edited my post I left the thread and really didn't bother to see what else he wrote.
     
  11. Offline

    Script1996

    Woah I love YOU GUYS ! :))

    Now the eatinganimation is showing too :))

    thank you sooo so much :)
     
  12. Offline

    FabeGabeMC

    Script1996 No problem, bud! Have a great time!
     
Thread Status:
Not open for further replies.

Share This Page