Search in sources :

Example 1 with EntityWorg

use of com.lying.variousoddities.entity.passive.EntityWorg in project VariousOddities by Lyinginbedmon.

the class EntityAIGoblinWorgBreed method shouldExecute.

public boolean shouldExecute() {
    List<EntityWorg> eligibleWorgs = theWorld.<EntityWorg>getEntitiesWithinAABB(EntityWorg.class, theGoblin.getBoundingBox().grow(8), searchPredicate);
    if (eligibleWorgs.size() > 6)
        return false;
    // Find Worg A
    double minDist = Double.MAX_VALUE;
    for (EntityWorg worg : eligibleWorgs) {
        double distance = theGoblin.getDistanceSq(worg);
        Path path = theNavigator.getPathToEntity(worg, 10);
        if (distance < minDist && path != null) {
            worgA = worg;
            minDist = distance;
        }
    }
    eligibleWorgs.remove(worgA);
    if (worgA != null) {
        // Find Worg B
        minDist = Double.MAX_VALUE;
        for (EntityWorg worg : eligibleWorgs) {
            double distance = worgA.getDistanceSq(worg);
            Path path = worgA.getNavigator().getPathToEntity(worg, 10);
            if (distance < minDist && path != null) {
                worgB = worg;
                minDist = distance;
            }
        }
    }
    return worgA != null && worgB != null && theGoblin.getRNG().nextInt(500) == 0;
}
Also used : Path(net.minecraft.pathfinding.Path) EntityWorg(com.lying.variousoddities.entity.passive.EntityWorg)

Example 2 with EntityWorg

use of com.lying.variousoddities.entity.passive.EntityWorg in project VariousOddities by Lyinginbedmon.

the class EntityAIGoblinWorgTame method tick.

public void tick() {
    if (!targetWolf.isAlive()) {
        currentState = null;
        return;
    } else
        theGoblin.getLookController().setLookPositionWithEntity(targetWolf, (float) (theGoblin.getHorizontalFaceSpeed() + 20), (float) theGoblin.getVerticalFaceSpeed());
    switch(currentState) {
        case MOVING:
            if (targetWolf.getDistance(theGoblin) >= 1D) {
                if (theNavigator.noPath()) {
                    theNavigator.tryMoveToEntityLiving(targetWolf, 1.0D);
                    if (theNavigator.noPath())
                        currentState = null;
                }
            } else
                currentState = State.TAMING;
            break;
        case TAMING:
            // targetWolf.addPotionEffect(new PotionEffect(VOPotions.ENTANGLED, Reference.Values.TICKS_PER_SECOND * 5, 1, false, false));
            targetWolf.addPotionEffect(new EffectInstance(Effects.SLOWNESS, Reference.Values.TICKS_PER_SECOND * 5, 10, false, false));
            if (--tamingTimer <= 0) {
                // TODO Ensure goblin arm swing during worg taming
                theGoblin.swing(Hand.MAIN_HAND, true);
                EntityWorg theWorg = VOEntities.WORG.create(theWorld);
                theWorg.setHealth(targetWolf.getHealth());
                // theWorg.addPotionEffect(new EffectInstance(VOPotions.ENTANGLED, Reference.Values.TICKS_PER_SECOND * 5, 1, false, false));
                theWorg.addPotionEffect(new EffectInstance(Effects.SLOWNESS, Reference.Values.TICKS_PER_SECOND * 5, 10, false, false));
                if (targetWolf.hasCustomName())
                    theWorg.setCustomName(targetWolf.getCustomName());
                theWorg.setPositionAndRotation(targetWolf.getPosX(), targetWolf.getPosY(), targetWolf.getPosZ(), targetWolf.rotationYaw, targetWolf.rotationPitch);
                targetWolf.remove();
                theWorld.addEntity(theWorg);
                theWorld.setEntityState(theWorg, (byte) 7);
                currentState = null;
            } else if (tamingTimer % Reference.Values.TICKS_PER_SECOND == 0) {
                theGoblin.swing(Hand.MAIN_HAND, true);
                theWorld.setEntityState(targetWolf, (byte) 6);
            }
            break;
        default:
            currentState = null;
            return;
    }
}
Also used : EffectInstance(net.minecraft.potion.EffectInstance) EntityWorg(com.lying.variousoddities.entity.passive.EntityWorg)

Example 3 with EntityWorg

use of com.lying.variousoddities.entity.passive.EntityWorg 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)

Example 4 with EntityWorg

use of com.lying.variousoddities.entity.passive.EntityWorg in project VariousOddities by Lyinginbedmon.

the class EntityAIGoblinWorgFight method shouldExecute.

public boolean shouldExecute() {
    if (theGoblin.getAttackTarget() != null || !theGoblin.isViolent())
        return false;
    List<EntityWorg> worgs = theWorld.getEntitiesWithinAABB(EntityWorg.class, theGoblin.getBoundingBox().grow(8D, 1D, 8D), searchPredicate);
    if (worgs.isEmpty() || worgs.size() <= 2)
        return false;
    worgA = worgB = null;
    for (EntityWorg worg : worgs) {
        if (worgA == null)
            worgA = worg;
        else if (worgB == null && worg.getNavigator().getPathToEntity(worgA, 10) != null) {
            worgB = worg;
            break;
        }
    }
    return worgA != null && worgB != null && theGoblin.getRNG().nextInt(1000) == 0;
}
Also used : EntityWorg(com.lying.variousoddities.entity.passive.EntityWorg)

Example 5 with EntityWorg

use of com.lying.variousoddities.entity.passive.EntityWorg in project VariousOddities by Lyinginbedmon.

the class EntityAIGoblinWorgHeal method shouldExecute.

public boolean shouldExecute() {
    if (theGoblin.getAttackTarget() != null)
        return false;
    double minDist = Double.MAX_VALUE;
    for (EntityWorg worg : theWorld.getEntitiesWithinAABB(EntityWorg.class, theGoblin.getBoundingBox().grow(8), searchPredicate)) {
        double distance = worg.getDistanceSq(theGoblin);
        if (distance < minDist && theNavigator.getPathToEntity(worg, 10) != null) {
            minDist = distance;
            theWorg = worg;
        }
    }
    return theWorg != null;
}
Also used : EntityWorg(com.lying.variousoddities.entity.passive.EntityWorg)

Aggregations

EntityWorg (com.lying.variousoddities.entity.passive.EntityWorg)5 LivingData (com.lying.variousoddities.capabilities.LivingData)1 EntityAIFrightened (com.lying.variousoddities.entity.ai.EntityAIFrightened)1 EntityAISleep (com.lying.variousoddities.entity.ai.EntityAISleep)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 Path (net.minecraft.pathfinding.Path)1 EffectInstance (net.minecraft.potion.EffectInstance)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