/** * 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 } }
private boolean checkValidity(final EntityLivingBase entity) { if (entity == this.mc.thePlayer) { return false; } if (!entity.isEntityAlive()) { return false; } if (this.mc.thePlayer.getDistanceToEntity(entity) > this.range) { return false; } if (!(entity instanceof EntityPlayer)) { return (this.monsters && entity instanceof EntityMob) || (this.animals && (entity instanceof EntityAnimal || entity instanceof EntitySquid)) || (this.bats && entity instanceof EntityBat); } if (this.players) { final EntityPlayer player = (EntityPlayer)entity; return (this.friend && FriendManager.isFriend(player.getName())) || (!FriendManager.isFriend(player.getName()) && (!this.noArmor || this.hasArmor(player))); } return false; }
private void onUpdateMinimal() { ++this.entityAge; if (this instanceof EntityMob) { float f = this.getBrightness(1.0F); if (f > 0.5F) { this.entityAge += 2; } } this.despawnEntity(); }
/** * Make the drone mob attack the target player */ private boolean initializeDrone(EntityMob mob) { // ensure that the drone has sufficient follow range to be able to path to the player double followRange = mob.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).getAttributeValue(); float distance = mob.getDistanceToEntity(this.attackTarget); if (followRange < distance) { mob.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).setBaseValue(distance * 1.1D); } // set the drone on a path to the player boolean canNavigate = mob.getNavigator().tryMoveToEntityLiving(this.attackTarget, this.currentDrone.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).getAttributeValue()); if (canNavigate) { // set the drone's attack target to be the player mob.setAttackTarget(this.attackTarget); } else { this.currentDrone = null; } return canNavigate; }
/** * Checks spawning */ @SubscribeEvent public void onSpawn(CheckSpawn event) { //If the entity is not a mob or above the forced-spawn-y-level, stop if (!(event.getEntity() instanceof EntityMob && event.getY() < underground)) return; EntityMob mob = (EntityMob) event.getEntity(); String name = EntityList.getEntityString(mob); //If whitelist and list contains mob, or blacklist and list does not contain mob if ((spawnWhitelist && mobsToSpawn.contains(name)) || (!(spawnWhitelist && mobsToSpawn.contains(name)))){ //If the chance is within allowed mob-spawn-under-y-level range, and the game is not on Peaceful if (rand.nextFloat() < undergroundChance && event.getWorld().getDifficulty() != EnumDifficulty.PEACEFUL){ //If there are no other entities in this area, and there are no collisions, and there is not a liquid if (event.getWorld().checkNoEntityCollision(mob.getEntityBoundingBox()) && event.getWorld().getCollisionBoxes(mob, mob.getEntityBoundingBox()).isEmpty() && !event.getWorld().containsAnyLiquid(mob.getEntityBoundingBox())){ //Allow the spawn event.setResult(Result.ALLOW); } } } }
@Override public int activateSkill(IWeaponSkillInfo info, EntityLivingBase attacker, ItemStack item, DamageSource source, EntityLivingBase opponent) { //If you don't know about Earthbound, we can't be friends. Sorry, I don't make the rules. DamageSource smaaaaaaash = new EntityDamageSource("weaponskill.smash", attacker); opponent.attackEntityFrom(smaaaaaaash, 4f); opponent.addPotionEffect( new PotionEffect(Potion.getPotionFromResourceLocation("minecraft:blindness"), 20*3, 2 )); //Thermionics.LOG.info("SMAAAAAAASH WeaponSkill activated against entity {} at {},{},{}", opponent, opponent.posX, opponent.posY, opponent.posZ); if (opponent instanceof EntityMob) { EntityMob monster = (EntityMob)opponent; monster.setAttackTarget(null); monster.setRevengeTarget(null); } if (!attacker.world.isRemote) { //Serverside, queue the effect SpawnParticleEmitterMessage fx = new SpawnParticleEmitterMessage(Thermionics.CONTEXT, EnumWeaponSkill.SMAAAAAAASH, opponent); fx.sendToAllWatching(opponent); } return 20*5; }
public Color getEntityColor() { if ((entity instanceof EntityAnimal)) { return Color.white; } if ((entity instanceof EntityMob)) { return Color.red; } if ((entity instanceof EntitySlime)) { return Color.green; } if ((entity instanceof EntityVillager)) { return new Color(245, 245, 220); } if ((entity instanceof EntityBat)) { return Color.BLACK; } if ((entity instanceof EntitySquid)) { return Color.PINK; } return Color.white; }
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; } } }
public boolean SpawnMob(final EntityLiving t) { if (t.getCanSpawnHere()) { t.onSpawnWithEgg((IEntityLivingData)null); if (t instanceof EntityMob) { t.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 3600, 1)); t.addPotionEffect(new PotionEffect(Potion.damageBoost.id, 3600, 1)); } else { t.addPotionEffect(new PotionEffect(Potion.regeneration.id, 3600, 1)); } t.getEntityData().setLong("CursedEarth", 3600L); t.forceSpawn = true; t.func_110163_bv(); return true; } return false; }
public static void beginSiege(final World world) { if (world.isRemote) { return; } if (world.provider.dimensionId != 1) { return; } for (int i = 0; i < world.loadedEntityList.size(); ++i) { if (world.loadedEntityList.get(i) instanceof EntityMob) { world.removeEntity((Entity)world.loadedEntityList.get(i)); } else if (world.loadedEntityList.get(i) instanceof EntityPlayer) { final EntityPlayer player = (EntityPlayer)world.loadedEntityList.get(i); EventHandlerSiege.SiegeParticipants.add(player.getGameProfile().getName()); player.getEntityData().setInteger("SiegeKills", 0); } } if (EventHandlerSiege.SiegeParticipants.size() != 0) { MinecraftServer.getServer().getConfigurationManager().sendChatMsg((IChatComponent)new ChatComponentText("The Siege has begun in 'The End'")); } else { endSiege(world, false); } }
@SubscribeEvent public void SiegeCheckSpawn(final LivingSpawnEvent.CheckSpawn event) { if (EventHandlerSiege.SiegeParticipants.isEmpty()) { return; } if (event.entity.worldObj.isRemote) { return; } if (event.world.provider.dimensionId != 1) { return; } if (event.entityLiving instanceof EntityMob && event.entityLiving.worldObj.checkNoEntityCollision(event.entityLiving.boundingBox) && event.entityLiving.worldObj.getCollidingBoundingBoxes((Entity)event.entityLiving, event.entityLiving.boundingBox).isEmpty() && !event.entityLiving.worldObj.isAnyLiquid(event.entityLiving.boundingBox)) { event.entityLiving.getEntityData().setBoolean("Siege", true); event.entityLiving.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 7200, 2)); event.setResult(Event.Result.ALLOW); } }
@SubscribeEvent public void noMobs(final LivingSpawnEvent.CheckSpawn event) { if (event.getResult() == Event.Result.DEFAULT && event.world.provider.dimensionId == ExtraUtils.underdarkDimID && event.entity instanceof EntityMob) { if (EventHandlerUnderdark.rand.nextDouble() < Math.min(0.95, event.entity.posY / 80.0)) { event.setResult(Event.Result.DENY); } else { IAttributeInstance t = ((EntityMob)event.entity).getEntityAttribute(SharedMonsterAttributes.maxHealth); t.setBaseValue(t.getBaseValue() * 2.0); ((EntityMob)event.entity).heal((float)t.getAttributeValue()); t = ((EntityMob)event.entity).getEntityAttribute(SharedMonsterAttributes.attackDamage); t.setBaseValue(t.getBaseValue() * 2.0); if (!EventHandlerServer.isInRangeOfTorch(event.entity) && event.entityLiving.worldObj.checkNoEntityCollision(event.entityLiving.boundingBox) && event.entityLiving.worldObj.getCollidingBoundingBoxes((Entity)event.entityLiving, event.entityLiving.boundingBox).isEmpty() && !event.entityLiving.worldObj.isAnyLiquid(event.entityLiving.boundingBox)) { event.setResult(Event.Result.ALLOW); } } } }
public boolean isEntityValidToAttack(EntityMinionWarrior minion, EntityLivingBase entity) { if(entity == minion || entity == minion.getRidingEntity() || !EntityAITarget.isSuitableTarget(minion, entity, false, false) || entity.getClass() == EntityCreeper.class) return false; if (entity instanceof EntityMob && (getTargetBehavior() == EnumCombatBehaviors.TARGET_HOSTILE_MOBS || getTargetBehavior() == EnumCombatBehaviors.TARGET_PASSIVE_OR_HOSTILE_MOBS)) { return true; } else if (entity instanceof EntityAnimal && (getTargetBehavior() == EnumCombatBehaviors.TARGET_PASSIVE_MOBS || getTargetBehavior() == EnumCombatBehaviors.TARGET_PASSIVE_OR_HOSTILE_MOBS)) { return true; } else { return false; } }
public EntitySlave(World p_i1688_1_) { super(p_i1688_1_); this.setSize(0.8F, 1.6F); this.getNavigator().setAvoidsWater(true); this.tasks.addTask(1, new EntityAISwimming(this)); this.tasks.addTask(2, this.aiSit); this.tasks.addTask(3, this.aiTempt = new EntityAITempt(this, 0.6D, Items.diamond, true)); this.tasks.addTask(4, new EntityAIFollowOwner(this, 1.0D, 10.0F, 5.0F)); this.tasks.addTask(5, new EntityAIAvoidEntity(this, EntityCreeper.class, 16.0F, 0.8D, 1.33D)); this.tasks.addTask(6, new EntityAILeapAtTarget(this, 0.3F)); this.tasks.addTask(7, new EntityAIOcelotAttack(this)); this.tasks.addTask(8, new EntityAIMate(this, 0.8D)); this.tasks.addTask(9, new EntityAIWander(this, 0.8D)); this.tasks.addTask(10, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F)); this.targetTasks.addTask(1, new EntityAITargetNonTamed(this, EntityMob.class, 750, false)); this.setType(this.rand.nextInt(4)); this.setRandomStuff(); }
@SubscribeEvent public void onEntityDrops(LivingDropsEvent event) { int alea; if (event.entityLiving instanceof EntityMob) alea = 20; else alea = 50; if (event.entityLiving.worldObj.rand.nextInt(alea) < 1 + event.lootingLevel * 2) { EntityItem e; e = new EntityItem(event.entityLiving.worldObj, event.entityLiving.posX, event.entityLiving.posY, event.entityLiving.posZ, new ItemStack(ItemRegister.getRandomArmor(), 1)); e = new EntityItem(event.entityLiving.worldObj, event.entityLiving.posX, event.entityLiving.posY, event.entityLiving.posZ, new ItemStack(ItemRegistry1.bagdrop, 1)); event.drops.add(e); } }
private boolean isValidTarget(Entity e) { if (e == null) return false; else if (e instanceof EntityPlayer) { EntityPlayer p = ((EntityPlayer) e); if (p.capabilities.isCreativeMode) return false; else { if (kPlayers) return true; else if (!kTeam) return false; RivalRebelsPlayer rrp = RivalRebels.round.rrplayerlist.getForName(((EntityPlayer) e).getCommandSenderName()); if (rrp == null) return kTeam; if (rrp.rrteam == RivalRebelsTeam.NONE) return !p.getCommandSenderName().equals(username); if (rrp.rrteam != team) return kTeam; else return false; } } else return (kMobs && (e instanceof EntityRhodes || (e instanceof EntityMob && !(e instanceof EntityAnimal) && !(e instanceof EntityBat) && !(e instanceof EntityVillager) && !(e instanceof EntitySquid)) || e instanceof EntityGhast)); }
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); } })); }
protected Relation determineRelation() { if (entity instanceof EntityMob) { return Relation.FOE; } else if (entity instanceof EntitySlime) { return Relation.FOE; } else if (entity instanceof EntityGhast) { return Relation.FOE; } else if (entity instanceof EntityAnimal) { return Relation.FRIEND; } else if (entity instanceof EntitySquid) { return Relation.FRIEND; } else if (entity instanceof EntityAmbientCreature) { return Relation.FRIEND; } else { return Relation.UNKNOWN; } }
@Override public void checkTarget() { if (RaytraceUtil.raytrace(getAngleFromTarget(), getTurretVector(), worldObj, InitBlocks.sentry_turret, target, RANGE) == HitType.BLOCK) { target = null; } if (target instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer)target; if (target == null || player.isDead || target.getDistance(xCoord, yCoord, zCoord) >= RANGE || player.capabilities.isCreativeMode || profile.isSameTeam(player)) { target = null; } } if (target instanceof EntityMob) { if (target == null || target.isDead || target.getDistance(xCoord, yCoord, zCoord) >= RANGE) { target = null; } } }
@Override public void fire() { if (target != null) { if (target instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) target; player.attackEntityFrom(new DamageSourceTeam((EntityPlayer) player, profile.getTeamName() + "'s Sentry Turret"), DAMAGE); } if (target instanceof EntityMob) { target.attackEntityFrom(DamageSource.generic, DAMAGE); } } }
@SuppressWarnings("rawtypes") @Override public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack stack = player.inventory.getCurrentItem(); if (player.inventory.getCurrentItem().getItem() == ModItems.voidScroll) { if (!world.isRemote) { List entityList = world.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(player.posX - 10, player.posY - 10, player.posZ - 10, player.posX + 10, player.posY + 10, player.posZ + 10)); Iterator iterator = entityList.iterator(); while (iterator.hasNext()) { Entity entity = (Entity) iterator.next(); if (entity instanceof EntityMob) ((EntityMob) entity).setHealth(0); } // decrease stack size by 1 stack.shrink(1); } } return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack); }
@SuppressWarnings("rawtypes") @Override public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) { ItemStack stack = player.inventory.getCurrentItem(); if (player.inventory.getCurrentItem().getItem() == ModItems.radiationScroll) { if (!world.isRemote) { List entityList = world.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(player.posX - 10, player.posY - 10, player.posZ - 10, player.posX + 10, player.posY + 10, player.posZ + 10)); Iterator iterator = entityList.iterator(); while (iterator.hasNext()) { Entity entity = (Entity) iterator.next(); if (entity instanceof EntityMob) entity.setFire(5); } // decrease stack size by 1 stack.shrink(1); } } return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack); }
/** Spawn a hostile mob near the player in between mindist and maxdist at a random angle * @return Returns true if the mob was successfully spawned */ public static boolean spawnMobNearPlayer(EntityPlayer player, EntityMob mob, double mindist, double maxdist) { // try this distance and angle double dd = maxdist - mindist; double dist = mindist + random.nextDouble() * dd; float angle = (float)(random.nextDouble() * 2 * Math.PI); // get corresponding position double x = player.posX - MathHelper.sin(angle) * dist; double z = player.posZ + MathHelper.cos(angle) * dist; Integer y = getOpenSurface(player.worldObj, (int)x, (int)z, (int)player.posY, 10, true); if(y == null) return false; // spawning if(player.worldObj.getCombinedLight(new BlockPos((int)x, y, (int)z), 0) <= 7) { mob.setPositionAndUpdate(x, y, z); return player.worldObj.spawnEntityInWorld(mob); } return false; }
/** * 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.getClass().equals(EntityMob.class) || entity.getClass().equals(EntitySlime.class) || entity.isCreatureType(EnumCreatureType.monster, false)) // Cauldron - account for entities that dont extend EntityMob { return 1; // Monster } else if ( entity.getClass().equals(EntityCreature.class) || entity.getClass().equals(EntityAmbientCreature.class) || entity.isCreatureType(EnumCreatureType.creature, false) || entity.isCreatureType(EnumCreatureType.waterCreature, false) || entity.isCreatureType(EnumCreatureType.ambient, false)) { return 2; // Animal // Cauldron end } else { return 3; // Misc } }
@Override public boolean onAction() { for (Object o : entitiesInAura) { if (o != null && o instanceof EntityMob) { EntityMob mob = (EntityMob)o; mob.attackEntityFrom(DamageSource.magic, 12); System.out.println(mob.toString()); return true; } } return false; }
public float getParrySkill(Entity target) { if(target instanceof EntityPlayer) { SkillTreeBase parry = SkillTrackerData.get((EntityPlayer) target).GetSkillByID("parry"); return parry != null ? parry.getSkillLevel() : 0; } else if (target instanceof EntityMob) { //TODO Give Mobs a Defense return EntityMobsExt.get((EntityMob)target).parry; } else if(target instanceof EntityAnimal) { return EntityAnimalExt.get((EntityAnimal)target).parry; } return 0; }
@Override public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) { if (!world.isRemote) { world.scheduleUpdate(pos, this, 5); AxisAlignedBB axisalignedbb = this.getCollisionBoundingBox(world, pos, state).expand(6, 6, 6); List<EntityMob> list = world.getEntitiesWithinAABB(EntityMob.class, axisalignedbb); for (EntityMob mob : list) { if (mob.getCreatureAttribute() == EnumCreatureAttribute.UNDEAD) { mob.setFire(20); } } } }
@Override protected void applyEntityAI() { // this.tasks.addTask(4, new EntityAIAttackOnCollide(this, EntityMob.class, 1.0D, true)); this.tasks.addTask(9, new SummonAIMoveToArea(this, 1.0)); this.tasks.addTask(4, new SummonAIManipulateTargetBlock(this)); this.tasks.addTask(6, new SummonAIMoveToNextTargetBlock(this, 1.0)); this.tasks.addTask(3, new SummonAIMoveToChest(this, 1.0)); this.tasks.addTask(4, new SummonAIDumpToChest(this)); // this.tasks.addTask(6, new EntityAIMoveThroughVillage(this, 1.0D, false)); this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true, new Class[] {EntityPigZombie.class})); this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityMob.class, true)); }
@Override public void onRender(EventOnRender event){ for(Object o : invoker.getEntityList()){ if(o instanceof EntityPlayer) continue; if(o instanceof EntityLivingBase){ EntityLivingBase entity = (EntityLivingBase) o; boolean mob = (entity instanceof EntityMob); RenderUtils.drawESP(false, invoker.getBoundboxMinX(entity) - invoker.getRenderPosX() - 0.1, invoker.getBoundboxMinY(entity) - invoker.getRenderPosY() - 0.1, invoker.getBoundboxMinZ(entity) - invoker.getRenderPosZ() - 0.1, invoker.getBoundboxMaxX(entity) - invoker.getRenderPosX() + 0.1, invoker.getBoundboxMaxY(entity) - invoker.getRenderPosY() + 0.1, invoker.getBoundboxMaxZ(entity) - invoker.getRenderPosZ() + 0.1, 1, 1, 1, 0.19, mob ? 1 : 0, mob ? 0 : 1, mob ? 0 : 1, 1); } } }
@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; }
@SubscribeEvent public void onLivingDrops(LivingDropsEvent event) { debug("drop"); float dropChance = 0.0f; if (event.entityLiving instanceof EntityMob) { debug("drop1"); dropChance = 0.2f; if (event.entityLiving instanceof EntityWitch) { debug("drop2"); dropChance = 1.0f; } } dropChance *= (event.lootingLevel + 1); if (rng.nextFloat() < dropChance) { debug("dropping"); event.entityLiving.worldObj.spawnEntityInWorld(new EntityItem( event.entityLiving.worldObj, event.entityLiving.posX, event.entityLiving.posY, event.entityLiving.posZ, new ItemStack(ingredient, 1, 9))); } }
public static int getHearing(Entity entity) { if(entity instanceof ISpecialSenses) { return((ISpecialSenses)entity).getSight(); } if(entity instanceof EntityMob) { if(((EntityMob)entity).getCreatureAttribute() == EnumCreatureAttribute.UNDEAD) { return 10; } } return 5; }