Solved Check if Entity is an instance of Zombie Pigman?

Discussion in 'Spigot Plugin Development' started by PinchCraft, Feb 26, 2020.

Thread Status:
Not open for further replies.
  1. For some reason, every other entity works fine - for example:

    Code (Text):
    if (entity instanceof Zombie)
    {
        // Blah
    }
    But for zombie pigman, it doesn't work.
    Code (Text):
    if (entity instanceof PigZombie)
    {
        // Blah
    }
    Doesn't detect in-game and IntelliJ says: Condition 'entity instanceof PigZombie' is always 'false'

    Any ideas? Thanks!
     
  2. It's a mistake in your own plugin then. The code in your method already guarantees entity isn't a PigZombie when it reaches that point. We can't tell the issue without the surrounding code.
     
    • Like Like x 1
  3. Figured it out, thanks!

    Apparently, PigZombie is a subclass of Zombie. Since I put it under Zombie in the list of else ifs, it would never be true as all pigzombies are zombies.
     
Thread Status:
Not open for further replies.