Solved Detecting Item Frames, IMPOSSIBLE ?!

Discussion in 'Plugin Development' started by Sw_aG, Dec 20, 2019.

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

    Sw_aG

    Hi fellow devs !

    I'm trying to prevent explosions from killing an item frame (since its an entity and not a block).
    I've successfully blacklisted armor stands already, but the same code does not seem to apply with item frames for some reason, here's the code I use for the armor stands:

    Code:
        @EventHandler
        public void onHit(EntityDamageEvent e) {
           
           
            if(e.getEntity().getType().equals(EntityType.ARMOR_STAND)) {
                if(e.getCause().equals(DamageCause.BLOCK_EXPLOSION) || e.getCause().equals(DamageCause.ENTITY_EXPLOSION)) {
                    e.setCancelled(true);
                    System.out.print("Preveneted an explosion on an " + e.getEntity().getType());
                }
            }
    }

    Couldn't find anything online that worked and the current code doesn't give me any error at all.
    Thanks in advance for all the helpers !
     
  2. Offline

    timtower Administrator Administrator Moderator

  3. Offline

    Sw_aG

    timtower likes this.
Thread Status:
Not open for further replies.

Share This Page