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;
}
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;
}
}
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();
}
}
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;
}
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;
}
Aggregations