1.16.5 ArmorStand

Discussion in 'Spigot Plugin Development' started by Bosternike, Jun 3, 2021.

Thread Status:
Not open for further replies.
  1. How to make ArmorStand receiving Damage but not breaking?
     
  2. On EntityDamageEvent, check if your armorstand is damaged, then set the final damage to 0.001d.
    with/or/and
    Increase ArmorStand max health using Attribute.GENERIC_MAX_HEALTH.
    or
    On EntityDamageEvent, check if your armorstand is damaged, if so, heal the armorstand on next tick.
     
  3. Code (Java):
        @EventHandler
        public void entityDamage(EntityDamageEvent event) {
            if (event.getEntity() instanceof ArmorStand) {
                new BukkitRunnable() {
                    @Override
                    public void run() {
                        ArmorStand armorStand = ((ArmorStand) event.getEntity());
                        armorStand.setHealth(armorStand.getMaxHealth());
                    }
                }.runTaskLater(YourMainClass.getInstance(), 1L);
            }
        }
    Should work
     
    • Like Like x 1
  4. No, it doesn't work :(
    I still can break the ArmorStand on double click
     
  5. You can cancel the event and play the entity effect ARMOR_STAND_HIT.

    Code (Java):

    event.setCancelled(true);
    event.getEntity().playEffect(EntityEffect.ARMOR_STAND_HIT);
     
     
    • Like Like x 1
  6. Yeah, It works! It's definitely that I want!
    Thank you so much!
     
Thread Status:
Not open for further replies.