net.minecraft.entity.monster.EntityMob Java Examples

The following examples show how to use net.minecraft.entity.monster.EntityMob. 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: EntityLivingBaseHook.java    From SkyblockAddons with MIT License 6 votes vote down vote up
public static void onResetHurtTime(EntityLivingBase entity) {
    if (entity == Minecraft.getMinecraft().thePlayer) {
        SkyblockAddons main = SkyblockAddons.getInstance();
        if (!main.getUtils().isOnSkyblock() || !main.getConfigValues().isEnabled(Feature.COMBAT_TIMER_DISPLAY)) {
            return;
        }

        Minecraft mc = Minecraft.getMinecraft();
        List<Entity> nearEntities = mc.theWorld.getEntitiesWithinAABB(Entity.class,
                new AxisAlignedBB(mc.thePlayer.posX - 3, mc.thePlayer.posY - 2, mc.thePlayer.posZ - 3, mc.thePlayer.posX + 3, mc.thePlayer.posY + 2, mc.thePlayer.posZ + 3));
        boolean foundPossibleAttacker = false;

        for (Entity nearEntity : nearEntities) {
            if (nearEntity instanceof EntityMob || nearEntity instanceof EntityWolf || nearEntity instanceof IProjectile) {
                foundPossibleAttacker = true;
                break;
            }
        }

        if (foundPossibleAttacker) {
            SkyblockAddons.getInstance().getUtils().setLastDamaged(System.currentTimeMillis());
        }
    }
}
 
Example #2
Source File: LivingTickHandler.java    From SimplyJetpacks with MIT License 6 votes vote down vote up
@SubscribeEvent
public void mobUseJetpack(LivingUpdateEvent evt) {
    if (!evt.entityLiving.worldObj.isRemote && evt.entityLiving instanceof EntityMob) {
        ItemStack armor = evt.entityLiving.getEquipmentInSlot(3);
        if (armor != null && armor.getItem() instanceof ItemJetpack) {
            ItemJetpack jetpackItem = (ItemJetpack) armor.getItem();
            Jetpack jetpack = jetpackItem.getPack(armor);
            if (jetpack != null) {
                if (jetpack instanceof JetpackPotato || MathHelper.RANDOM.nextInt(3) == 0) {
                    jetpack.setMobMode(armor);
                    jetpack.flyUser(evt.entityLiving, armor, jetpackItem, false);
                }
            }
            if (evt.entityLiving.posY > evt.entityLiving.worldObj.getActualHeight() + 10) {
                evt.entityLiving.attackEntityFrom(DamageSource.generic, 80);
            }
        }
    }
}
 
Example #3
Source File: MoCEntityAmbient.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
public boolean entitiesToIgnore(Entity entity)
{

	return ((!(entity instanceof EntityLiving)) 
	        || (entity instanceof EntityMob) 
	        || (entity instanceof EntityPlayer && this.getIsTamed()) 
	        || (entity instanceof MoCEntityKittyBed) 
	        || (entity instanceof MoCEntityLitterBox) 
	        || (this.getIsTamed() && (entity instanceof MoCEntityAnimal && ((MoCEntityAnimal) entity).getIsTamed())) 
	        || ((entity instanceof EntityWolf) && !(MoCreatures.proxy.attackWolves)) 
	        || ((entity instanceof MoCEntityHorse) && !(MoCreatures.proxy.attackHorses)) 
	        || (entity.width > this.width && entity.height > this.height)
	        || (entity instanceof MoCEntityEgg)

	);
}
 
Example #4
Source File: MoCEntityAnimal.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
public boolean entitiesToIgnore(Entity entity)
{

	return ((!(entity instanceof EntityLiving)) 
	        || (entity instanceof EntityMob) 
	        || (entity instanceof EntityPlayer && this.getIsTamed()) 
	        || (entity instanceof MoCEntityKittyBed) 
	        || (entity instanceof MoCEntityLitterBox) 
	        || (this.getIsTamed() && (entity instanceof MoCIMoCreature && ((MoCIMoCreature) entity).getIsTamed())) 
	        || ((entity instanceof EntityWolf) && !(MoCreatures.proxy.attackWolves)) 
	        || ((entity instanceof MoCEntityHorse) && !(MoCreatures.proxy.attackHorses)) 
	        || (entity.width >= this.width || entity.height >= this.height)
	        || (entity instanceof MoCEntityEgg)

	);
}
 
Example #5
Source File: AuraEffects.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean isEntityApplicable(Entity e) {
    if(e instanceof EntityMob) {
        EntityMob mob = (EntityMob) e;
        if(mob.getEntityAttribute(EntityUtils.CHAMPION_MOD).getAttributeValue() < 0
                && mob.getEntityAttribute(SharedMonsterAttributes.maxHealth).getBaseValue() >= 10.0D) {
            boolean whitelisted = false;
            for (Class clazz : ConfigEntities.championModWhitelist.keySet()) {
                if (clazz.isAssignableFrom(e.getClass())) {
                    whitelisted = true;
                }
            }
            return whitelisted;
        }
    }
    return false;
}
 
Example #6
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 #7
Source File: EntityGuard.java    From ToroQuest with GNU General Public License v3.0 6 votes vote down vote up
protected void initEntityAI() {
	areaAI = new EntityAIMoveIntoArea(this, 0.5D, 30);
	tasks.addTask(0, new EntityAISwimming(this));
	tasks.addTask(2, new EntityAIAttackMelee(this, 0.6D, false));
	tasks.addTask(4, areaAI);
	tasks.addTask(7, new EntityAIWander(this, 0.35D));
	tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
	tasks.addTask(8, new EntityAILookIdle(this));

	targetTasks.addTask(2, new EntityAINearestAttackableCivTarget(this));
	targetTasks.addTask(3, new EntityAINearestAttackableTarget<EntityMob>(this, EntityMob.class, 10, false, false, new Predicate<EntityMob>() {
		@Override
		public boolean apply(EntityMob target) {
			return !(target instanceof EntityCreeper);
		}
	}));
}
 
Example #8
Source File: EntityBackupZombie.java    From Wizardry with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void applyEntityAI() {
	this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true, EntityPigZombie.class));
	this.targetTasks.addTask(4, new EntityAITargetFiltered<>(this, EntityMob.class, false, new Predicate<Entity>() {
		public boolean apply(@Nullable Entity entity) {
			if (entity == null) return false;
			if (entity.getDataManager().getAll() == null) return false;

			boolean success = false;
			for (EntityDataManager.DataEntry<?> entry : entity.getDataManager().getAll()) {
				if (entry.getKey().equals(OWNER)) {
					success = true;
					break;
				}
			}
			if (!success) return false;

			UUID theirOwner = null;
			Object ownerObj = entity.getDataManager().get(OWNER);
			if (ownerObj != null && ownerObj instanceof Optional && ((Optional<?>) ownerObj).isPresent() && ((Optional<?>) ownerObj).get() instanceof UUID)
				theirOwner = entity.getDataManager().get(OWNER).orNull();

			return !(theirOwner != null && getDataManager().get(OWNER).isPresent() && theirOwner.equals(getDataManager().get(OWNER).get()));
		}
	}));
}
 
Example #9
Source File: MoCTools.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
public static void repelMobs(Entity entity1, Double dist, World worldObj)
{
    List list = worldObj.getEntitiesWithinAABBExcludingEntity(entity1, entity1.boundingBox.expand(dist, 4D, dist));
    for (int i = 0; i < list.size(); i++)
    {
        Entity entity = (Entity) list.get(i);
        if (!(entity instanceof EntityMob))
        {
            continue;
        }
        EntityMob entitymob = (EntityMob) entity;
        entitymob.setAttackTarget(null);
        //entitymob.entityToAttack = null;
        entitymob.setPathToEntity(null);
    }
}
 
Example #10
Source File: MoCEntityBunny.java    From mocreaturesdev with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void updateEntityActionState()
{
    if (onGround && ((motionX > 0.05D) || (motionZ > 0.05D) || (motionX < -0.05D) || (motionZ < -0.05D)))
    {
        motionY = 0.45000000000000001D;
    }
    if (!pickedUp)
    {
        super.updateEntityActionState();
    }
    else if (onGround && this.ridingEntity == null)
    {
        pickedUp = false;
        //System.out.println("pickedOff");
        worldObj.playSoundAtEntity(this, "rabbitland", 1.0F, ((rand.nextFloat() - rand.nextFloat()) * 0.2F) + 1.0F);
        List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.expand(12D, 12D, 12D));
        for (int k = 0; k < list.size(); k++)
        {
            Entity entity = (Entity) list.get(k);
            if (entity instanceof EntityMob)
            {
                EntityMob entitymob = (EntityMob) entity;
                entitymob.setAttackTarget(this);

            }
        }

    }
}
 
Example #11
Source File: MoCEntityMob.java    From mocreaturesdev with GNU General Public License v3.0 5 votes vote down vote up
public boolean entitiesToIgnore(Entity entity)
{
    return ((!(entity instanceof EntityLiving)) 
            || (entity instanceof EntityMob)
            || (entity instanceof MoCEntityEgg)
            || (entity instanceof EntityPlayer && this.getIsTamed()) 
            || (entity instanceof MoCEntityKittyBed) || (entity instanceof MoCEntityLitterBox) 
            || (this.getIsTamed() && (entity instanceof MoCEntityAnimal && ((MoCEntityAnimal) entity).getIsTamed())) 
            || ((entity instanceof EntityWolf) && !(MoCreatures.proxy.attackWolves)) 
            || ((entity instanceof MoCEntityHorse) && !(MoCreatures.proxy.attackHorses))

    );
}
 
Example #12
Source File: MoCEntityLitterBox.java    From mocreaturesdev with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onUpdate()
{
    super.onUpdate();
    if (onGround)
    {
        setPickedUp(false);
    }
    if (getUsedLitter() && MoCreatures.isServer())
    {
        littertime++;
        worldObj.spawnParticle("smoke", posX, posY, posZ, 0.0D, 0.0D, 0.0D);
        List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.expand(12D, 4D, 12D));
        for (int i = 0; i < list.size(); i++)
        {
            Entity entity = (Entity) list.get(i);
            if (!(entity instanceof EntityMob))
            {
                continue;
            }
            EntityMob entitymob = (EntityMob) entity;
            entitymob.setAttackTarget(this);
            if (entitymob instanceof EntityCreeper)
            {
                ((EntityCreeper) entitymob).setCreeperState(-1);
            }
            if (entitymob instanceof MoCEntityOgre)
            {
                ((MoCEntityOgre) entitymob).pendingSmashAttack = false;
                //((MoCEntityOgre) entitymob).attackTime = 20;
            }
        }

    }
    if (littertime > 5000 && MoCreatures.isServer())
    {
        setUsedLitter(false);
        littertime = 0;
    }
}
 
Example #13
Source File: MoCEntityAnimal.java    From mocreaturesdev with GNU General Public License v3.0 5 votes vote down vote up
public void repelMobs(Entity entity1, Double dist, World worldObj)
{
	List list = worldObj.getEntitiesWithinAABBExcludingEntity(entity1, entity1.boundingBox.expand(dist, 4D, dist));
	for (int i = 0; i < list.size(); i++)
	{
		Entity entity = (Entity) list.get(i);
		if (!(entity instanceof EntityMob))
		{
			continue;
		}
		EntityMob entitymob = (EntityMob) entity;
		entitymob.setAttackTarget(null);
		entitymob.setPathToEntity(null);
	}
}
 
Example #14
Source File: MoCEntityAnimal.java    From mocreaturesdev with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Called to make ridden entities pass on collision to rider
 */
public void Riding()
{
	if ((riddenByEntity != null) && (riddenByEntity instanceof EntityPlayer))
	{
		EntityPlayer entityplayer = (EntityPlayer) riddenByEntity;
		List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.expand(1.0D, 0.0D, 1.0D));
		if (list != null)
		{
			for (int i = 0; i < list.size(); i++)
			{
				Entity entity = (Entity) list.get(i);
				if (entity.isDead)
				{
					continue;
				}
				entity.onCollideWithPlayer(entityplayer);
				if (!(entity instanceof EntityMob))
				{
					continue;
				}
				float f = getDistanceToEntity(entity);
				if ((f < 2.0F) && entity instanceof EntityMob && (rand.nextInt(10) == 0))
				{
					attackEntityFrom(DamageSource.causeMobDamage((EntityLiving) entity), ((EntityMob)entity).getAttackStrength(this));
				}
			}

		}
		if (entityplayer.isSneaking())
		{
			//if (!worldObj.isRemote)
			//{
				this.makeEntityDive();
				//entityplayer.mountEntity(null);
			//}
		}

	}
}
 
Example #15
Source File: MoCEntityAquatic.java    From mocreaturesdev with GNU General Public License v3.0 5 votes vote down vote up
public void Riding()
{
    if ((riddenByEntity != null) && (riddenByEntity instanceof EntityPlayer))
    {
        EntityPlayer entityplayer = (EntityPlayer) riddenByEntity;
        List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.expand(1.0D, 0.0D, 1.0D));
        if (list != null)
        {
            for (int i = 0; i < list.size(); i++)
            {
                Entity entity = (Entity) list.get(i);
                if (entity.isDead)
                {
                    continue;
                }
                entity.onCollideWithPlayer(entityplayer);
                if (!(entity instanceof EntityMob))
                {
                    continue;
                }
                float f = getDistanceToEntity(entity);
                if ((f < 2.0F) && (rand.nextInt(10) == 0))
                {
                    //attackEntityFrom(DamageSource.causeMobDamage((EntityLiving) entity),((EntityMob) entity).attackStrength);
                	attackEntityFrom(DamageSource.causeMobDamage((EntityLiving) entity), ((EntityMob)entity).getAttackStrength(this));
                }
            }

        }
        if (entityplayer.isSneaking())
        {
            //if (!worldObj.isRemote)
            //{
        	this.makeEntityDive();
            //entityplayer.mountEntity(null);
            //}
        }
    }
}
 
Example #16
Source File: EventHandlerPneumaticCraft.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@SideOnly(Side.CLIENT)
private void warnPlayerIfNecessary(LivingSetAttackTargetEvent event){
    EntityPlayer player = FMLClientHandler.instance().getClient().thePlayer;
    if(event.target == player && (event.entityLiving instanceof EntityGolem || event.entityLiving instanceof EntityMob)) {
        ItemStack helmetStack = player.getCurrentArmor(3);
        if(helmetStack != null && helmetStack.getItem() == Itemss.pneumaticHelmet && ((IPressurizable)helmetStack.getItem()).getPressure(helmetStack) > 0 && ItemPneumaticArmor.getUpgrades(ItemMachineUpgrade.UPGRADE_ENTITY_TRACKER, helmetStack) > 0 && GuiKeybindCheckBox.trackedCheckboxes.get("pneumaticHelmet.upgrade.coreComponents").checked && GuiKeybindCheckBox.trackedCheckboxes.get("pneumaticHelmet.upgrade." + EntityTrackUpgradeHandler.UPGRADE_NAME).checked) {
            HUDHandler.instance().getSpecificRenderer(EntityTrackUpgradeHandler.class).warnIfNecessary(event.entityLiving);
        }
    } else {
        HUDHandler.instance().getSpecificRenderer(EntityTrackUpgradeHandler.class).removeTargetingEntity(event.entityLiving);
    }
}
 
Example #17
Source File: PneumaticCraftUtils.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
private static boolean isEntityValidForName(String filter, Entity entity) throws IllegalArgumentException{
    if(filter.equals("")) {
        return true;
    } else if(filter.startsWith("@")) {//entity type selection
        filter = filter.substring(1); //cut off the '@'.
        Class typeClass = null;
        if(filter.equals("mob")) {
            typeClass = EntityMob.class;
        } else if(filter.equals("animal")) {
            typeClass = EntityAnimal.class;
        } else if(filter.equals("living")) {
            typeClass = EntityLivingBase.class;
        } else if(filter.equals("player")) {
            typeClass = EntityPlayer.class;
        } else if(filter.equals("item")) {
            typeClass = EntityItem.class;
        } else if(filter.equals("minecart")) {
            typeClass = EntityMinecart.class;
        } else if(filter.equals("drone")) {
            typeClass = EntityDrone.class;
        }
        if(typeClass != null) {
            return typeClass.isAssignableFrom(entity.getClass());
        } else {
            throw new IllegalArgumentException(filter + " is not a valid entity type.");
        }
    } else {
        try {
            String regex = filter.toLowerCase().replaceAll(".", "[$0]").replace("[*]", ".*");//Wildcard regex
            return entity.getCommandSenderName().toLowerCase().matches(regex);//TODO when player, check if entity is tamed by the player (see EntityAIAvoidEntity for example)
        } catch(PatternSyntaxException e) {
            return entity.getCommandSenderName().toLowerCase().equals(filter.toLowerCase());
        }
    }
}
 
Example #18
Source File: EntityJoinWorld.java    From minecraft-roguelike with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void OnEntityJoinWorld(EntityJoinWorldEvent event) {
	
	World world = event.getWorld();
	if(world.isRemote) return;
	
	Entity entity = event.getEntity();
	
	// slimes do not extend EntityMob for some reason
	if(!(entity instanceof EntityMob || entity instanceof EntitySlime)){
		return;
	}
	
	EntityLiving mob = (EntityLiving) entity;
	
	Collection<?> effects = mob.getActivePotionEffects();
	for(Object buff : effects){
		if(Potion.getIdFromPotion(((PotionEffect) buff).getPotion()) == 4){
			int level = ((PotionEffect) buff).getAmplifier();
			
			IEntity metaEntity = new MetaEntity((Entity)mob);
			MonsterProfile.equip(world, world.rand, level, metaEntity);
			if(entity.isDead) event.setCanceled(true);
			return;
		}
	}
}
 
Example #19
Source File: MoCEntityAmbient.java    From mocreaturesdev with GNU General Public License v3.0 5 votes vote down vote up
public void repelMobs(Entity entity1, Double dist, World worldObj)
{
	List list = worldObj.getEntitiesWithinAABBExcludingEntity(entity1, entity1.boundingBox.expand(dist, 4D, dist));
	for (int i = 0; i < list.size(); i++)
	{
		Entity entity = (Entity) list.get(i);
		if (!(entity instanceof EntityMob))
		{
			continue;
		}
		EntityMob entitymob = (EntityMob) entity;
		entitymob.setAttackTarget(null);
		entitymob.setPathToEntity(null);
	}
}
 
Example #20
Source File: MoCEntityAmbient.java    From mocreaturesdev with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Called to make ridden entities pass on collision to rider
 */
public void Riding()
{
	if ((riddenByEntity != null) && (riddenByEntity instanceof EntityPlayer))
	{
		EntityPlayer entityplayer = (EntityPlayer) riddenByEntity;
		List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.expand(1.0D, 0.0D, 1.0D));
		if (list != null)
		{
			for (int i = 0; i < list.size(); i++)
			{
				Entity entity = (Entity) list.get(i);
				if (entity.isDead)
				{
					continue;
				}
				entity.onCollideWithPlayer(entityplayer);
				if (!(entity instanceof EntityMob))
				{
					continue;
				}
				float f = getDistanceToEntity(entity);
				if ((f < 2.0F) && (rand.nextInt(10) == 0))
				{
					//TODO 4FIX
					//attackEntityFrom(DamageSource.causeMobDamage((EntityLiving) entity),((EntityMob) entity).attackStrength);
				}
			}

		}
		if (entityplayer.isSneaking())
		{
			if (!worldObj.isRemote)
			{
				entityplayer.mountEntity(null);
			}
		}

	}
}
 
Example #21
Source File: EntityUtils.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Adds the persistenceRequired flag to entities, if they need it in order to not despawn.
 * The checks are probably at most accurate for vanilla entities.
 * @param livingBase
 * @return
 */
public static boolean applyMobPersistence(EntityLiving living)
{
    if (living.isNoDespawnRequired() == false)
    {
        boolean canDespawn = ((living instanceof EntityMob) && living.isNonBoss()) ||
                              (living instanceof EntityWaterMob) ||
                              ((living instanceof EntityTameable) && ((EntityTameable)living).isTamed() == false);

        if (canDespawn == false)
        {
            try
            {
                canDespawn = (boolean) methodHandle_EntityLiving_canDespawn.invokeExact(living);
            }
            catch (Throwable t)
            {
                EnderUtilities.logger.warn("Error while trying to invoke EntityLiving.canDespawn() on entity '{}' via a MethodHandle", living, t);
            }
        }

        if (canDespawn)
        {
            // Sets the persistenceRequired boolean
            living.enablePersistence();
            living.getEntityWorld().playSound(null, living.getPosition(), Sounds.JAILER, SoundCategory.MASTER, 0.8f, 1.2f);

            return true;
        }
    }

    return false;
}
 
Example #22
Source File: AuraEffects.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void doEntityEffect(ChunkCoordinates originTile, Entity e) {
    if(e.worldObj.rand.nextInt(4) == 0) {
        EntityMob mob = (EntityMob) e;
        PotionEffect effect = mob.getActivePotionEffect(RegisteredPotions.ELDRITCH);

        if(effect != null && effect.getAmplifier() > 4) {
            EntityUtils.makeChampion(mob, false);
            mob.removePotionEffect(RegisteredPotions.ELDRITCH.getId());
        } else {
            mob.addPotionEffect(new PotionEffect(RegisteredPotions.ELDRITCH.getId(), MiscUtils.ticksForMinutes(1), effect == null ? 1 : effect.getAmplifier() + 1));
        }
    }
}
 
Example #23
Source File: CivilizationHandlers.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
private boolean isHostileMob(EntityLivingBase victim) {
	return victim instanceof EntityMob ||
			victim instanceof EntitySlime ||
			victim instanceof EntityMagmaCube ||
			victim instanceof EntityGhast ||
			victim instanceof EntityShulker;
}
 
Example #24
Source File: QuestEnemyEncampment.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
private int countEntities(final QuestData data) {
	Predicate<Entity> filter = new Predicate<Entity>() {
		public boolean apply(@Nullable Entity entity) {
			return entity.getTags().contains("encampment_quest") && entity.getTags().contains(data.getQuestId().toString());
		}
	};
	return data.getPlayer().world.getEntitiesWithinAABB(EntityMob.class, new AxisAlignedBB(getSpawnPosition(data)).expand(80, 40, 80), filter).size();
}
 
Example #25
Source File: EntitySentry.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
protected void initEntityAI() {
	tasks.addTask(0, new EntityAISwimming(this));
	tasks.addTask(2, new EntityAIAttackMelee(this, 0.5D, false));
	tasks.addTask(7, new EntityAIWander(this, 0.35D));
	tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
	tasks.addTask(8, new EntityAILookIdle(this));

	targetTasks.addTask(2, new EntityAINearestAttackableCivTarget(this));
	targetTasks.addTask(3, new EntityAINearestAttackableTarget<EntityMob>(this, EntityMob.class, 2, false, false, new Predicate<EntityMob>() {
		@Override
		public boolean apply(EntityMob target) {
			return !(target instanceof EntityCreeper);
		}
	}));
}
 
Example #26
Source File: ActivationRange.java    From Kettle with GNU General Public License v3.0 5 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) {
    // 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.WATER_CREATURE, false) || entity.isCreatureType(EnumCreatureType.AMBIENT, false)) {
        return 2; // Animal
        // Cauldron end
    } else {
        return 3; // Misc
    }
}
 
Example #27
Source File: ItemLungsUpgrade.java    From Cyberware with MIT License 4 votes vote down vote up
@SubscribeEvent
public void handleLivingUpdate(CyberwareUpdateEvent event)
{
	EntityLivingBase e = event.getEntityLiving();
	if (CyberwareAPI.isCyberwareInstalled(e, new ItemStack(this, 1, 0)))
	{
		ItemStack stack = CyberwareAPI.getCyberware(e, new ItemStack(this, 1, 0));
		int air = getAir(stack);
		if (e.getAir() < 300 && air > 0)
		{
			int toAdd = Math.min(300 - e.getAir(), air);
			e.setAir(e.getAir() + toAdd);
			CyberwareAPI.getCyberwareNBT(stack).setInteger("air", air - toAdd);
		}
		else if (e.getAir() == 300 && air < 900)
		{
			CyberwareAPI.getCyberwareNBT(stack).setInteger("air", air + 1);
		}
	}
	


	ItemStack test = new ItemStack(this, 1, 1);
	if (CyberwareAPI.isCyberwareInstalled(e, new ItemStack(this, 1, 1)))
	{
		if ((e.isSprinting() || e instanceof EntityMob) && !e.isInWater() && e.onGround)
		{
			boolean last = getLastOxygen(e);

			int ranks = CyberwareAPI.getCyberwareRank(e, test);
			test.stackSize = ranks;
			boolean powerUsed = e.ticksExisted % 20 == 0 ? CyberwareAPI.getCapability(e).usePower(test, getPowerConsumption(test)) : last;
			
			if (powerUsed)
			{
				e.moveRelative(0F, .2F * ranks, 0.075F);
			}
			
			lastOxygen.put(e.getEntityId(), powerUsed);
		}
	}
}
 
Example #28
Source File: MoCEntityHorseMob.java    From mocreaturesdev with GNU General Public License v3.0 4 votes vote down vote up
public void onLivingUpdate()
{

    super.onLivingUpdate();

    if (isOnAir() && isFlyer() && rand.nextInt(5) == 0)
    {
        wingFlapCounter = 1;
    }
    
    if (rand.nextInt(200)==0)
    {
        moveTail();
    }
    
    if (!isOnAir() && (this.riddenByEntity == null) && rand.nextInt(250)==0)
    {
        stand();
    }
    
    if ((getType() == 38) && (rand.nextInt(50) == 0) && !MoCreatures.isServer())
    {
        LavaFX();
    }
    
    if ((getType() == 23) && (rand.nextInt(50) == 0) && !MoCreatures.isServer())
    {
        UndeadFX();
    }
    
    
    
    if (MoCreatures.isServer())
        
    {
        if (isFlyer() && rand.nextInt(500) == 0)
        {
            wingFlap();
        }
        
        if (this.worldObj.isDaytime())
        {
            float var1 = this.getBrightness(1.0F);

            if (var1 > 0.5F && this.worldObj.canBlockSeeTheSky(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)) && this.rand.nextFloat() * 30.0F < (var1 - 0.4F) * 2.0F)
            {
                this.setFire(8);
            }
        }
        
        if (!isOnAir() && (this.riddenByEntity == null) && rand.nextInt(300)==0)
        {
            setEating();
        }
        

        
        
        
        
        
        
        if (this.riddenByEntity == null)
        {
        List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.expand(4D, 3D, 4D));
        for(int i = 0; i < list.size(); i++)
        {
            Entity entity = (Entity) list.get(i);
            if(!(entity instanceof EntityMob))
            {
                continue;
            }
            EntityMob entitymob = (EntityMob) entity;
            if(entitymob.ridingEntity == null && (entitymob instanceof EntitySkeleton || entitymob instanceof EntityZombie))
            {
                entitymob.mountEntity(this);
                break;
            }
        }
        }
    }

}
 
Example #29
Source File: CraftMonster.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@Override
public EntityMob getHandle() {
    return (EntityMob) entity;
}
 
Example #30
Source File: CraftMonster.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public CraftMonster(CraftServer server, EntityMob entity) {
    super(server, entity);
}