Search in sources :

Example 1 with EntityAISleep

use of com.lying.variousoddities.entity.ai.EntityAISleep in project VariousOddities by Lyinginbedmon.

the class VOBusServer method addEntityBehaviours.

@SubscribeEvent
public static void addEntityBehaviours(EntityJoinWorldEvent event) {
    Entity theEntity = event.getEntity();
    if (theEntity instanceof LivingEntity && !theEntity.getEntityWorld().isRemote) {
        LivingData data = LivingData.forEntity((LivingEntity) theEntity);
        if (data != null && !theEntity.getEntityWorld().isRemote)
            PacketHandler.sendToAll((ServerWorld) theEntity.getEntityWorld(), new PacketSyncLivingData(theEntity.getUniqueID(), data));
    }
    if (theEntity.getType() == EntityType.CAT || theEntity.getType() == EntityType.OCELOT) {
        MobEntity feline = (MobEntity) theEntity;
        if (ConfigVO.MOBS.aiSettings.isOddityAIEnabled(VOEntities.RAT))
            feline.targetSelector.addGoal(1, new NearestAttackableTargetGoal<EntityRat>(feline, EntityRat.class, true));
        if (ConfigVO.MOBS.aiSettings.isOddityAIEnabled(VOEntities.RAT_GIANT))
            feline.targetSelector.addGoal(1, new NearestAttackableTargetGoal<EntityRatGiant>(feline, EntityRatGiant.class, true));
    }
    // Add sleep AI to mobs
    if (theEntity instanceof MobEntity) {
        MobEntity living = (MobEntity) theEntity;
        living.goalSelector.addGoal(1, new EntityAISleep(living));
        if (living instanceof CreatureEntity)
            living.goalSelector.addGoal(1, new EntityAIFrightened((CreatureEntity) living));
    }
    // Spook worgs
    if (event.getEntity().getType() == EntityType.LIGHTNING_BOLT) {
        BlockPos pos = event.getEntity().getPosition();
        AxisAlignedBB bounds = new AxisAlignedBB(0, 0, 0, 1, 256, 1).offset(pos.getX(), 0, pos.getZ()).grow(128, 0, 128);
        for (EntityWorg worg : event.getEntity().getEntityWorld().getEntitiesWithinAABB(EntityWorg.class, bounds)) worg.spook();
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) FireballEntity(net.minecraft.entity.projectile.FireballEntity) CreatureEntity(net.minecraft.entity.CreatureEntity) MobEntity(net.minecraft.entity.MobEntity) Entity(net.minecraft.entity.Entity) PacketSyncLivingData(com.lying.variousoddities.network.PacketSyncLivingData) LivingData(com.lying.variousoddities.capabilities.LivingData) NearestAttackableTargetGoal(net.minecraft.entity.ai.goal.NearestAttackableTargetGoal) PacketSyncLivingData(com.lying.variousoddities.network.PacketSyncLivingData) CreatureEntity(net.minecraft.entity.CreatureEntity) EntityAISleep(com.lying.variousoddities.entity.ai.EntityAISleep) LivingEntity(net.minecraft.entity.LivingEntity) ServerWorld(net.minecraft.world.server.ServerWorld) EntityAIFrightened(com.lying.variousoddities.entity.ai.EntityAIFrightened) BlockPos(net.minecraft.util.math.BlockPos) MobEntity(net.minecraft.entity.MobEntity) EntityWorg(com.lying.variousoddities.entity.passive.EntityWorg) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Aggregations

LivingData (com.lying.variousoddities.capabilities.LivingData)1 EntityAIFrightened (com.lying.variousoddities.entity.ai.EntityAIFrightened)1 EntityAISleep (com.lying.variousoddities.entity.ai.EntityAISleep)1 EntityWorg (com.lying.variousoddities.entity.passive.EntityWorg)1 PacketSyncLivingData (com.lying.variousoddities.network.PacketSyncLivingData)1 CreatureEntity (net.minecraft.entity.CreatureEntity)1 Entity (net.minecraft.entity.Entity)1 LivingEntity (net.minecraft.entity.LivingEntity)1 MobEntity (net.minecraft.entity.MobEntity)1 NearestAttackableTargetGoal (net.minecraft.entity.ai.goal.NearestAttackableTargetGoal)1 PlayerEntity (net.minecraft.entity.player.PlayerEntity)1 ServerPlayerEntity (net.minecraft.entity.player.ServerPlayerEntity)1 FireballEntity (net.minecraft.entity.projectile.FireballEntity)1 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1 BlockPos (net.minecraft.util.math.BlockPos)1 ServerWorld (net.minecraft.world.server.ServerWorld)1 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)1