/** * 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 } }
@SubscribeEvent public void onDrops(LivingDropsEvent event) { World world = event.getEntity().getEntityWorld(); if (world.isRemote || !(event.getEntity() instanceof EntityCreature)) { return; } if (event.getSource() == null || event.getSource().getTrueSource() == null){ return; } if (!(event.getSource().getTrueSource() instanceof EntityPlayer)) { return; } if (event.getEntity().getTags().contains(NemesisSystem.TAG_NEMESIS)) { handleNemesisDrops(event.getDrops(), (EntityCreature) event.getEntity()); } }
private void buffMobInAroundNemeses(World world, EntityCreature entity) { if (!(entity instanceof EntityMob)) { return; } if (entity.getTags().contains(NemesisSystem.TAG_BUFF_MOB_REINFORCEMENT)) { return; } List<NemesisEntry> nemeses = NemesisRegistryProvider.get(world).list(); sortByHighestLevel(nemeses); for (NemesisEntry nemesis : nemeses) { if (buffEntity(entity, nemesis)) { return; } } }
private static void handleNemesisDeath(EntityCreature nemesisEntity, Entity attacker) { NemesisEntry nemesis = NemesisUtil.loadNemesisFromEntity(nemesisEntity); if (nemesis == null) { return; } if (attacker == null || !(attacker instanceof EntityLivingBase)) { return; } NemesisActions.demote(nemesisEntity.world, nemesis, attacker.getName()); NemesisUtil.findNemesisBodyGuards(nemesisEntity.world, nemesis.getId(), nemesisEntity.getPosition()) .forEach((EntityCreature guard) -> { guard.setAttackTarget(null); guard.getTags().add(TAG_RONIN); }); }
public EntityAIFindEntityNearest(EntityLiving p_i45884_1_, Class <? extends EntityLivingBase > p_i45884_2_) { this.field_179442_b = p_i45884_1_; this.field_179439_f = p_i45884_2_; if (p_i45884_1_ instanceof EntityCreature) { field_179444_a.warn("Use NearestAttackableTargetGoal.class for PathfinerMob mobs!"); } this.field_179443_c = new Predicate<EntityLivingBase>() { public boolean apply(EntityLivingBase p_apply_1_) { double d0 = EntityAIFindEntityNearest.this.func_179438_f(); if (p_apply_1_.isSneaking()) { d0 *= 0.800000011920929D; } return p_apply_1_.isInvisible() ? false : ((double)p_apply_1_.getDistanceToEntity(EntityAIFindEntityNearest.this.field_179442_b) > d0 ? false : EntityAITarget.isSuitableTarget(EntityAIFindEntityNearest.this.field_179442_b, p_apply_1_, false, true)); } }; this.field_179440_d = new EntityAINearestAttackableTarget.Sorter(p_i45884_1_); }
@SubscribeEvent public void onDeath(LivingDeathEvent event) { World world = event.getEntity().getEntityWorld(); if (world.isRemote) { return; } Entity slayer = event.getSource().getTrueSource(); if (event.getEntity() instanceof EntityPlayer && slayer instanceof EntityCreature) { handlePlayerDeath((EntityPlayer) event.getEntity(), (EntityCreature) slayer); return; } if (!(event.getEntity() instanceof EntityCreature)) { return; } if (event.getEntity().getTags().contains(NemesisSystem.TAG_NEMESIS)) { handleNemesisDeath((EntityCreature) event.getEntity(), slayer); } }
protected void alertOthers() { double d0 = this.getTargetDistance(); for (EntityCreature entitycreature : this.taskOwner.worldObj.getEntitiesWithinAABB(this.taskOwner.getClass(), (new AxisAlignedBB(this.taskOwner.posX, this.taskOwner.posY, this.taskOwner.posZ, this.taskOwner.posX + 1.0D, this.taskOwner.posY + 1.0D, this.taskOwner.posZ + 1.0D)).expand(d0, 10.0D, d0))) { if (this.taskOwner != entitycreature && entitycreature.getAttackTarget() == null && (!(this.taskOwner instanceof EntityTameable) || ((EntityTameable)this.taskOwner).getOwner() == ((EntityTameable)entitycreature).getOwner()) && !entitycreature.isOnSameTeam(this.taskOwner.getAITarget())) { boolean flag = false; for (Class<?> oclass : this.targetClasses) { if (entitycreature.getClass() == oclass) { flag = true; break; } } if (!flag) { this.setEntityAttackTarget(entitycreature, this.taskOwner.getAITarget()); } } } }
public EntityAIFindEntityNearest(EntityLiving mobIn, Class <? extends EntityLivingBase > p_i45884_2_) { this.mob = mobIn; this.classToCheck = p_i45884_2_; if (mobIn instanceof EntityCreature) { LOGGER.warn("Use NearestAttackableTargetGoal.class for PathfinerMob mobs!"); } this.predicate = new Predicate<EntityLivingBase>() { public boolean apply(@Nullable EntityLivingBase p_apply_1_) { double d0 = EntityAIFindEntityNearest.this.getFollowRange(); if (p_apply_1_.isSneaking()) { d0 *= 0.800000011920929D; } return p_apply_1_.isInvisible() ? false : ((double)p_apply_1_.getDistanceToEntity(EntityAIFindEntityNearest.this.mob) > d0 ? false : EntityAITarget.isSuitableTarget(EntityAIFindEntityNearest.this.mob, p_apply_1_, false, true)); } }; this.sorter = new EntityAINearestAttackableTarget.Sorter(mobIn); }
public EntityAIMoveThroughVillage(EntityCreature theEntityIn, double movementSpeedIn, boolean isNocturnalIn) { this.theEntity = theEntityIn; this.movementSpeed = movementSpeedIn; this.isNocturnal = isNocturnalIn; this.setMutexBits(1); if (!(theEntityIn.getNavigator() instanceof PathNavigateGround)) { throw new IllegalArgumentException("Unsupported mob for MoveThroughVillageGoal"); } }
public EntityAIMoveToBlock(EntityCreature creature, double speedIn, int length) { this.theEntity = creature; this.movementSpeed = speedIn; this.searchLength = length; this.setMutexBits(5); }
@SubscribeEvent public void onAttacked(LivingHurtEvent event) { World world = event.getEntity().getEntityWorld(); if (world.isRemote || !(event.getEntity() instanceof EntityCreature)) { return; } if (event.getEntity().getTags().contains(NemesisSystem.TAG_NEMESIS)) { orderGuardsToAttackAggressor((EntityCreature) event.getEntity(), event.getSource().getTrueSource()); } }
public EntityAIWander(EntityCreature creatureIn, double speedIn, int chance) { this.entity = creatureIn; this.speed = speedIn; this.executionChance = chance; this.setMutexBits(1); }
public void setTarget(LivingEntity target) { EntityCreature entity = getHandle(); if (target == null) { entity.entityToAttack = null; } else if (target instanceof CraftLivingEntity) { entity.entityToAttack = ((CraftLivingEntity) target).getHandle(); entity.pathToEntity = entity.worldObj.getPathEntityToEntity(entity, entity.entityToAttack, 16.0F, true, false, false, true); } }
public EntityAIAttackMelee(EntityCreature creature, double speedIn, boolean useLongMemory) { this.attacker = creature; this.worldObj = creature.worldObj; this.speedTowardsTarget = speedIn; this.longMemory = useLongMemory; this.setMutexBits(3); }
public EntityAIFleeSun(EntityCreature theCreatureIn, double movementSpeedIn) { this.theCreature = theCreatureIn; this.movementSpeed = movementSpeedIn; this.theWorld = theCreatureIn.worldObj; this.setMutexBits(1); }
@Nullable /** * finds a random target within par1(x,z) and par2 (y) blocks */ public static Vec3d findRandomTarget(EntityCreature entitycreatureIn, int xz, int y) { return findRandomTargetBlock(entitycreatureIn, xz, y, (Vec3d)null); }
protected void setEntityAttackTarget(EntityCreature creatureIn, EntityLivingBase entityLivingBaseIn) { super.setEntityAttackTarget(creatureIn, entityLivingBaseIn); if (creatureIn instanceof EntityPigZombieMage) { ((EntityPigZombieMage) creatureIn).becomeAngryAt(entityLivingBaseIn); } }
@Nullable /** * searches 10 blocks at random in a within par1(x,z) and par2 (y) distance, ignores those not in the direction of * par3Vec3, then points to the tile for which creature.getBlockPathWeight returns the highest number */ private static Vec3d findRandomTargetBlock(EntityCreature entitycreatureIn, int xz, int y, @Nullable Vec3d targetVec3) { return func_191379_a(entitycreatureIn, xz, y, targetVec3, true); }
public EntityAIMoveTowardsTarget(EntityCreature creature, double speedIn, float targetMaxDistance) { this.theEntity = creature; this.speed = speedIn; this.maxTargetDistance = targetMaxDistance; this.setMutexBits(1); }
public EntityAITempt(EntityCreature temptedEntityIn, double speedIn, Item temptItemIn, boolean scaredByPlayerMovementIn) { this.temptedEntity = temptedEntityIn; this.speed = speedIn; this.temptItem = temptItemIn; this.scaredByPlayerMovement = scaredByPlayerMovementIn; this.setMutexBits(3); if (!(temptedEntityIn.getNavigator() instanceof PathNavigateGround)) { throw new IllegalArgumentException("Unsupported mob type for TemptGoal"); } }
public EntityAIRestrictOpenDoor(EntityCreature creatureIn) { this.entityObj = creatureIn; if (!(creatureIn.getNavigator() instanceof PathNavigateGround)) { throw new IllegalArgumentException("Unsupported mob type for RestrictOpenDoorGoal"); } }
public EntityAIAttackOnCollide(EntityCreature creature, double speedIn, boolean useLongMemory) { this.attacker = creature; this.worldObj = creature.worldObj; this.speedTowardsTarget = speedIn; this.longMemory = useLongMemory; this.setMutexBits(3); }
/** * Handles updating while being ridden by an entity */ public void updateRidden() { super.updateRidden(); if (this.getRidingEntity() instanceof EntityCreature) { EntityCreature entitycreature = (EntityCreature)this.getRidingEntity(); this.renderYawOffset = entitycreature.renderYawOffset; } }
public EntityAIHurtByTarget(EntityCreature creatureIn, boolean entityCallsForHelpIn, Class... targetClassesIn) { super(creatureIn, false); this.entityCallsForHelp = entityCallsForHelpIn; this.targetClasses = targetClassesIn; this.setMutexBits(1); }
private void flee(EntityCreature bodyGuard) { bodyGuard.removeTag(NemesisSystem.TAG_BODY_GUARD); bodyGuard.setAttackTarget(null); dropItemsInHands(bodyGuard); BehaviorApi.setFollowSpeed(bodyGuard, 2); int distance = 1000; int degrees = bodyGuard.getRNG().nextInt(360); int x = distance * (int) Math.round(Math.cos(Math.toRadians(degrees))); int z = distance * (int) Math.round(Math.sin(Math.toRadians(degrees))); BlockPos from = bodyGuard.getPosition(); BlockPos to = new BlockPos(from.getX() + x, from.getY(), from.getZ() + z); bodyGuard.setHomePosAndDistance(to, 50); }
private EntityCreature createEntity(NemesisEntry nemesis) { try { return SpawnApi.getEntityFromString(mc.world, nemesis.getMob()); } catch (Exception e) { e.printStackTrace(); return null; } }
/** * Handles updating while being ridden by an entity */ public void updateRidden() { super.updateRidden(); if (this.ridingEntity instanceof EntityCreature) { EntityCreature entitycreature = (EntityCreature)this.ridingEntity; this.renderYawOffset = entitycreature.renderYawOffset; } }
public EntityAITarget(EntityCreature creature, boolean checkSight, boolean onlyNearby) { this.unseenMemoryTicks = 60; this.taskOwner = creature; this.shouldCheckSight = checkSight; this.nearbyOnly = onlyNearby; }
public static List<EntityCreature> findNemesisBodyGuards(World world, UUID id, BlockPos position) { int distance = 100; return world.getEntitiesWithinAABB(EntityCreature.class, nearByBox(position, distance), (EntityCreature searchEntity) -> isBodyGuard(searchEntity, id) ); }
private static void nemesisAnnounceEffects(EntityCreature nemesisEntity) { World world = nemesisEntity.world; if (canSeeSky(nemesisEntity)) { world.addWeatherEffect(new EntityLightningBolt(nemesisEntity.world, nemesisEntity.posX, nemesisEntity.posY, nemesisEntity.posZ, true)); } // TODO sound horn }