Test block at entity

Discussion in 'Plugin Development' started by PikaThieme, Jan 23, 2017.

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

    PikaThieme

    So I need to know how to test if there is a block in an Entity.
    I don't know if I need to use an event (neither what) or something else.
    I only have this:
    as = armorstand :)

    Also, how to kill an armorstand if it has no equipment?
    Code:java
    1.  
    2. Location location = as.getLocation();
    3. int x = location.getBlockX();
    4. int y = location.getBlockY();
    5. int z = location.getBlockZ();
    6. World w = location.getWorld();
    7. Location loc = new Location(w, x, y, z);
    8. if (loc.getBlock().getType() == Material.WEB);
     
    Last edited by a moderator: Jan 23, 2017
  2. Offline

    Zombie_Striker

    @PikaThieme
    To test if an armourstand has no equipment, go through the hands and all armour slots and check if the item is null (if there are no items in those slots). If all of them are null, use the .remove() method to kill the armour stand.
     
  3. Offline

    timtower Administrator Administrator Moderator

    Moved to plugin development.
     
  4. Offline

    PikaThieme

    @Zombie_Striker can you also help me with my other question? :)
    Because I really don't know what event to use :/
     
  5. Offline

    Zombie_Striker

    @PikaThieme
    Well, when do you want it to be triggered, or do you not want there to be a trigger? By that I mean do you want it to happen only when something happens, or in repeating intervals (using repeating tasks.)
     
  6. Offline

    PikaThieme

    @Zombie_Striker I want to make it that if you place a cobweb in an ArmorStand that it removes a specific datatag
     
  7. Offline

    Zombie_Striker

    @PikaThieme
    Then Listen to either BlockPlaceEvent or PlayerInteractWithEntityEvent. If a block is actually placed, use BlockPlaceEvent. If it is just a player clicking an armor stand, then PIWEE.
     
  8. Offline

    PikaThieme

    How do I get the block that is placed in the ArmorStand? I know I have to use BlockPlaceEvent and something like this:
    Code:text
    1.  
    2. Location location = as.getLocation();
    3. int x = location.getBlockX();
    4. int y = location.getBlockY();
    5. int z = location.getBlockZ();
    6. World w = location.getWorld();
    7. Location loc = new Location(w, x, y, z);
    8. if (loc.getBlock().getType() == Material.WEB);
     
  9. Offline

    timtower Administrator Administrator Moderator

    Moved to plugin development
    @PikaThieme If it is about your own coding, always post there.
     
  10. Offline

    PikaThieme

  11. Offline

    timtower Administrator Administrator Moderator

    @PikaThieme Well, you just select a different section.

    Merged threads
     
Thread Status:
Not open for further replies.

Share This Page