1.8.8 Invisible armor stands are immune to explosion damage

Discussion in 'Spigot Plugin Development' started by SSPmrsomebody1, Feb 8, 2020.

  1. I'm creating invisible armor stands with blocks on their heads that detect when they're damaged and how much damage they've taken using the EntityDamageEvent. I used the invisible attribute to make them invisible, but I encountered a problem: they're immune to explosions, and as a result don't call EntityDamageEvent event handlers when they're blown up, which is a problem. There are no errors. Using /effect and giving them the invisibility effect doesn't seem to do anything; they're still visible. Does anyone here know of a solution, for example is it possible to trick the client into thinking the stands are invisible (with visible blocks on their heads) using packets? (Note: I think I would prefer to use ProtocolLib so my plugin's compatible with multiple versions.)

    I tried using pigs that were constantly teleported to the stands (the stands will change location) to detect explosions for the stands but they caused a bit of lag.

    By the way I did a little bit of googling and apparently there was a Minecraft bug from a 1.8 snapshot that made invisible armor stands invincible.

    I tested this on a clean install of a Spigot 1.8.8 server on my PC with only 1 plugin (the one made to test this) and this happened:

    When I punch a normal armor stand in survival mode and blow one up:
    Code (Text):
    [18:39:07 INFO]: <mrsomebody1> NORMAL
    [18:39:09 INFO]: DAMAGE CraftArmorStand ENTITY_ATTACK
    [18:39:10 INFO]: DAMAGE CraftArmorStand ENTITY_ATTACK
    [18:39:10 INFO]: DAMAGE CraftArmorStand ENTITY_ATTACK
    [18:39:18 INFO]: mrsomebody1 issued server command: /gamemode creative
    [18:39:18 INFO]: [mrsomebody1: Set own game mode to Creative Mode]
    [18:39:20 INFO]: mrsomebody1 issued server command: /summon PrimedTnt
    [18:39:20 INFO]: [mrsomebody1: Object successfully summoned]
    [18:39:20 INFO]: DAMAGE CraftZombie ENTITY_EXPLOSION
    [18:39:20 INFO]: DAMAGE CraftArmorStand ENTITY_EXPLOSION
    >
    When I punch an invisible armor stand in survival mode and blow one up:
    Code (Text):
    [18:52:42 INFO]: <mrsomebody1> INVIS
    [18:52:43 INFO]: DAMAGE CraftArmorStand ENTITY_ATTACK
    [18:52:43 INFO]: DAMAGE CraftArmorStand ENTITY_ATTACK
    [18:52:43 INFO]: DAMAGE CraftArmorStand ENTITY_ATTACK
    [18:52:44 INFO]: DAMAGE CraftArmorStand ENTITY_ATTACK
    [18:52:44 INFO]: DAMAGE CraftArmorStand ENTITY_ATTACK
    [18:52:44 INFO]: DAMAGE CraftArmorStand ENTITY_ATTACK
    [18:52:44 INFO]: DAMAGE CraftArmorStand ENTITY_ATTACK
    [18:52:49 INFO]: mrsomebody1 issued server command: /gamemode creative
    [18:52:49 INFO]: [mrsomebody1: Set own game mode to Creative Mode]
    [18:52:51 INFO]: mrsomebody1 issued server command: /summon PrimedTnt
    [18:52:51 INFO]: [mrsomebody1: Object successfully summoned]
    >
    The test plugin's code, excluding the package statement:
    Code (Java):

    import org.bukkit.Bukkit;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.EntityDamageEvent;
    import org.bukkit.plugin.java.JavaPlugin;

    public class SpigotTest extends JavaPlugin implements Listener{
        public void onEnable() {
            getServer().getPluginManager().registerEvents(this, this);
        }
        @EventHandler public void entityDamage(EntityDamageEvent e) {
            Bukkit.broadcastMessage("DAMAGE "+e.getEntity()+" "+e.getCause());
        }
    }
     
    Thanks in advance for helping!
     
  2. md_5

    Administrator Developer

    It's not a bug, from your link:
    • Resolution: Works As Intended
     
    • Funny Funny x 1
  3. You can probably check using this:
    Code (Text):
        @EventHandler
        public void onExplode(EntityExplodeEvent e) {
            if (e.getEntity() instanceof EntityTNTPrimed) {
                for (Entity entity : e.getEntity().getNearbyEntities(4, 4, 4)) {
                    if(entity instanceof ArmorStand || entity instanceof CraftArmorStand) {
                        Bukkit.broadcastMessage("DAMAGE "+entity + " With TNT");
                    }
                }
            }
        }
     
    • Useful Useful x 1
  4. I tested this in a singleplayer 1.8.8 world and invisible armor stands are also immune to attacks in survival mode in addition to TNT. Has the bug returned or am I missing something obvious?

    md_5, great work with BungeeCord by the way.

    Thank you for that, I would prefer not to have to handle the explosion damage myself but I'll use some of this code if I don't find another solution.