Java Code Examples for net.minecraft.entity.Entity#isCreatureType()

The following examples show how to use net.minecraft.entity.Entity#isCreatureType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActivationRange.java    From Thermos with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Initializes an entities type on construction to specify what group this
 * entity is in for activation ranges.
 *
 * @param entity
 * @return group id
 */
public static byte initializeEntityActivationType(Entity entity)
{
    Chunk chunk = null;
    // Cauldron start - account for entities that dont extend EntityMob, EntityAmbientCreature, EntityCreature
    if ( entity instanceof EntityMob || entity instanceof EntitySlime || entity.isCreatureType(EnumCreatureType.monster, false)) // Cauldron - account for entities that dont extend EntityMob
    {
        return 1; // Monster
    } else if ( entity instanceof EntityCreature || entity instanceof EntityAmbientCreature || entity.isCreatureType(EnumCreatureType.creature, false) 
             || entity.isCreatureType(EnumCreatureType.waterCreature, false) || entity.isCreatureType(EnumCreatureType.ambient, false))
    {
        return 2; // Animal
    // Cauldron end
    } else
    {
        return 3; // Misc
    }
}
 
Example 2
Source File: FriendlyMob.java    From ForgeHax with MIT License 5 votes vote down vote up
@Override
public boolean isMobType(Entity entity) {
  return entity.isCreatureType(EnumCreatureType.CREATURE, false)
      || entity.isCreatureType(EnumCreatureType.AMBIENT, false)
      || entity.isCreatureType(EnumCreatureType.WATER_CREATURE, false)
      || entity instanceof EntityVillager
      || entity instanceof EntityGolem;
}
 
Example 3
Source File: EntityUtils.java    From ForgeHax with MIT License 5 votes vote down vote up
/**
 * If the mob is friendly (not aggressive)
 */
public static boolean isFriendlyMob(Entity entity) {
  return (entity.isCreatureType(EnumCreatureType.CREATURE, false)
      && !EntityUtils.isNeutralMob(entity))
      || (entity.isCreatureType(EnumCreatureType.AMBIENT, false) && !isBatsDisabled)
      || entity instanceof EntityVillager
      || entity instanceof EntityIronGolem
      || (isNeutralMob(entity) && !EntityUtils.isMobAggressive(entity));
}
 
Example 4
Source File: ActivationRange.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
/**
 * These entities are excluded from Activation range checks.
 *
 * @param entity
 * @param world
 * @return boolean If it should always tick.
 */
public static boolean initializeEntityActivationState(Entity entity, SpigotWorldConfig config)
{
    // Cauldron start - another fix for Proxy Worlds
    if (config == null && DimensionManager.getWorld(0) != null)
    {
        config = DimensionManager.getWorld(0).spigotConfig;
    }
    else
    {
        return true;
    }
    // Cauldron end

    if ( ( entity.activationType == 3 && config.miscActivationRange == 0 )
            || ( entity.activationType == 2 && config.animalActivationRange == 0 )
            || ( entity.activationType == 1 && config.monsterActivationRange == 0 )
            || (entity instanceof EntityPlayer && !(entity instanceof FakePlayer)) // Cauldron
            || entity instanceof EntityThrowable
            || entity instanceof EntityDragon
            || entity instanceof EntityDragonPart
            || entity instanceof EntityWither
            || entity instanceof EntityFireball
            || entity instanceof EntityWeatherEffect
            || entity instanceof EntityTNTPrimed
            || entity instanceof EntityFallingBlock // PaperSpigot - Always tick falling blocks
            || entity instanceof EntityEnderCrystal
            || entity instanceof EntityFireworkRocket
            || entity instanceof EntityVillager
            // Cauldron start - force ticks for entities with superclass of Entity and not a creature/monster
            || (entity.getClass().getSuperclass() == Entity.class && !entity.isCreatureType(EnumCreatureType.creature, false)
            && !entity.isCreatureType(EnumCreatureType.ambient, false) && !entity.isCreatureType(EnumCreatureType.monster, false)
            && !entity.isCreatureType(EnumCreatureType.waterCreature, false)))
    {
        return true;
    }

    return false;
}
 
Example 5
Source File: HostileMob.java    From ForgeHax with MIT License 4 votes vote down vote up
@Override
public boolean isMobType(Entity entity) {
  return entity.isCreatureType(EnumCreatureType.MONSTER, false);
}
 
Example 6
Source File: EntityUtils.java    From ForgeHax with MIT License 4 votes vote down vote up
/**
 * If the mob is hostile
 */
public static boolean isHostileMob(Entity entity) {
  return (entity.isCreatureType(EnumCreatureType.MONSTER, false)
      && !EntityUtils.isNeutralMob(entity))
      || EntityUtils.isMobAggressive(entity);
}