EntityType.ENDERMAN cannot be resolved to a type

Discussion in 'Spigot Help' started by DenDennisCool, Jul 5, 2021.

  1. Hey, I want to check if entity type is enderman. the error i get: EntityType.ENDERMAN cannot be resolved to a type.

    The code below the enderman works just fine

    Code (Java):

    @EventHandler
        public void onDeath(EntityDeathEvent e) {
           

           
            Location loc = e.getEntity().getLocation();
            World world = loc.getWorld();
            double x = loc.getX();
            double y = loc.getY();
            double z = loc.getZ();
           
            EntityType deadentity = e.getEntity().getType();
           
            if(deadentity instanceof EntityType.ENDERMAN) {
                world.dropItem(loc, new ItemStack(Material.ENDER_PEARL, 2));
            }
           
            if(e.getEntity() instanceof Monster) {
            world.dropItem(loc, new ItemStack(Material.DIAMOND));
            ((ExperienceOrb)world.spawn(loc, ExperienceOrb.class)).setExperience(2);
            }
           
        }
     
     
  2. I recommend completing some sort of free java school from internet, it will help alot.
    Always check and know the types you are using/comparing/getting

    You could do:
    Code (Java):
    e.getEntity() instanceof Enderman
    or deadentity == EntityType.ENDERMAN
     
    • Useful Useful x 1
  3. Thank you!
     
    • Friendly Friendly x 1