@Override protected boolean matches(EntityLivingBase entity) { if (type == BOSS) return !entity.isNonBoss(); else if (!entity.isNonBoss()) return false; switch (type) { case ANIMAL: return entity instanceof EntityAnimal; case MONSTER: return entity instanceof IMob; case TAMEABLE: return entity instanceof IEntityOwnable; case PLAYER: return entity instanceof EntityPlayer; case WATER: return entity instanceof EntityWaterMob || entity instanceof EntityGuardian; case NPC: return entity instanceof INpc; case GOLEM: return entity instanceof EntityGolem; default: return false; } }
@Override public JsonElement serialize(Entity src, Type typeOfSrc, JsonSerializationContext context) { JsonObject object = new JsonObject(); object.addProperty("x", MathHelper.floor_double(src.posX)); object.addProperty("y", MathHelper.floor_double(src.posY + 0.5d)); object.addProperty("z", MathHelper.floor_double(src.posZ)); if (src instanceof EntityPlayer) { object.addProperty("player", src.getUniqueID().toString()); } else { object.addProperty("id", EntityList.getEntityString(src)); if (src instanceof EntityLiving) object.addProperty("name", ((EntityLiving) src).getCustomNameTag()); if (src instanceof IEntityOwnable) object.addProperty("owner", ((IEntityOwnable) src).func_152113_b()); } return object; }
public static boolean isSuitableTarget(EntityPlayer attacker, @Nullable EntityLivingBase target, boolean includeInvincibles, boolean checkSight) { if (target == null) { return false; } else if (target == attacker) { return false; } else if (!target.isEntityAlive()) { return false; } else if (target instanceof EntityPlayer && !attacker.canAttackPlayer((EntityPlayer) target)) { return false; } else { if (attacker instanceof IEntityOwnable && ((IEntityOwnable)attacker).getOwnerId() != null) { if (target instanceof IEntityOwnable && ((IEntityOwnable)attacker).getOwnerId().equals(target.getUniqueID())) { return false; } if (target == ((IEntityOwnable)attacker).getOwner()) { return false; } } else if (target instanceof EntityPlayer && !includeInvincibles && ((EntityPlayer)target).capabilities.disableDamage) { return false; } return !checkSight || attacker.canEntityBeSeen(target); } }
@Override public boolean testCondition(Random rand, LootContext context) { Entity player = this.team ? context.getKiller() : context.getKillerPlayer(); if(player instanceof IEntityOwnable && ((IEntityOwnable)player).getOwner() instanceof EntityPlayer) player = ((IEntityOwnable)player).getOwner(); return player != null && player.getTeam() != null && !player.isOnSameTeam(context.getLootedEntity()); }
@Override protected boolean isSuitableTarget(EntityLivingBase target, boolean includeInvincibles) { if (target == null) return false; else if (target == this.taskOwner) return false; else if (!target.isEntityAlive()) return false; else if (!this.taskOwner.canAttackClass(target.getClass())) return false; else{ Team team = this.taskOwner.getTeam(); Team team1 = target.getTeam(); boolean medic = (this.taskOwner instanceof EntityMedic); if ((team != null && team1 == team) && !medic) return false; else { if (!medic && this.taskOwner instanceof IEntityOwnable && ((IEntityOwnable) this.taskOwner).getOwnerId() != null) { if (target instanceof IEntityOwnable && ((IEntityOwnable) this.taskOwner).getOwnerId() .equals(((IEntityOwnable) target).getOwnerId())) return false; if (target == ((IEntityOwnable) this.taskOwner).getOwner()) return false; } else if (target instanceof EntityPlayer && !includeInvincibles && ((EntityPlayer) target).capabilities.disableDamage) return false; return !this.shouldCheckSight || this.taskOwner.getEntitySenses().canSee(target); } } }
@Override protected boolean isSuitableTarget(EntityLivingBase target, boolean includeInvincibles) { if (target == null) return false; else if (target == this.taskOwner) return false; else if (!target.isEntityAlive()) return false; else if (!this.taskOwner.canAttackClass(target.getClass())) return false; else { Team team = this.taskOwner.getTeam(); Team team1 = target.getTeam(); if ((team != null && team1 == team) && !(this.taskOwner instanceof EntityMedic)) return false; else { if (this.taskOwner instanceof IEntityOwnable && ((IEntityOwnable) this.taskOwner).getOwnerId() != null) { if (target instanceof IEntityOwnable && ((IEntityOwnable) this.taskOwner).getOwnerId() .equals(((IEntityOwnable) target).getOwnerId())) return false; if (target == ((IEntityOwnable) this.taskOwner).getOwner()) return false; } else if (target instanceof EntityPlayer && !includeInvincibles && ((EntityPlayer) target).capabilities.disableDamage) return false; return !this.shouldCheckSight || this.taskOwner.getEntitySenses().canSee(target); } } }
@Override public float getAttributeModifier(String attribute) { if (!(this.getAttackTarget() instanceof EntityPlayer || (this.getAttackTarget() instanceof IEntityOwnable && ((IEntityOwnable) this.getAttackTarget()).getOwnerId() != null))) { if (attribute.equals("Heal")) return this.getDiff() == 1 ? 0.75f : (this.getDiff() == 3 ? 1f : 0.9f); if (attribute.equals("Overheal")) return this.getDiff() == 1 ? 0.55f : (this.getDiff() == 3 ? 0.85f : 0.7f); } return super.getAttributeModifier(attribute); }
/** * Returns true if the entity is considered friendly to the player (or IS the player) */ public static boolean isOnTeam(EntityPlayer player, EntityLivingBase entity) { if (entity == player) { return true; } else if (player.isOnSameTeam(entity)) { return true; } else if (entity instanceof IEntityOwnable) { return ((IEntityOwnable) entity).getOwner() == player; } else { return false; } }
/** * A static method used to see if an entity is a suitable target through a number of checks. */ public static boolean isSuitableTarget(EntityLiving attacker, EntityLivingBase target, boolean includeInvincibles, boolean checkSight) { if (target == null) { return false; } else if (target == attacker) { return false; } else if (!target.isEntityAlive()) { return false; } else if (!attacker.canAttackClass(target.getClass())) { return false; } else { Team team = attacker.getTeam(); Team team1 = target.getTeam(); if (team != null && team1 == team) { return false; } else { if (attacker instanceof IEntityOwnable && StringUtils.isNotEmpty(((IEntityOwnable)attacker).getOwnerId())) { if (target instanceof IEntityOwnable && ((IEntityOwnable)attacker).getOwnerId().equals(((IEntityOwnable)target).getOwnerId())) { return false; } if (target == ((IEntityOwnable)attacker).getOwner()) { return false; } } else if (target instanceof EntityPlayer && !includeInvincibles && ((EntityPlayer)target).capabilities.disableDamage) { return false; } return !checkSight || attacker.getEntitySenses().canSee(target); } } }
/** * A static method used to see if an entity is a suitable target through a number of checks. */ public static boolean isSuitableTarget(EntityLiving attacker, @Nullable EntityLivingBase target, boolean includeInvincibles, boolean checkSight) { if (target == null) { return false; } else if (target == attacker) { return false; } else if (!target.isEntityAlive()) { return false; } else if (!attacker.canAttackClass(target.getClass())) { return false; } else if (attacker.isOnSameTeam(target)) { return false; } else { if (attacker instanceof IEntityOwnable && ((IEntityOwnable)attacker).getOwnerId() != null) { if (target instanceof IEntityOwnable && ((IEntityOwnable)attacker).getOwnerId().equals(target.getUniqueID())) { return false; } if (target == ((IEntityOwnable)attacker).getOwner()) { return false; } } else if (target instanceof EntityPlayer && !includeInvincibles && ((EntityPlayer)target).capabilities.disableDamage) { return false; } return !checkSight || attacker.getEntitySenses().canSee(target); } }
public static boolean isOnSameTeam(Entity entity1, Entity entity2) { return (TF2Util.getTeam(entity1) == TF2Util.getTeam(entity2) && TF2Util.getTeam(entity1) != null) || (entity1 instanceof IEntityOwnable && ((IEntityOwnable) entity1).getOwner() == entity2) || (entity2 instanceof IEntityOwnable && ((IEntityOwnable) entity2).getOwner() == entity1) || entity1 == entity2; }
public boolean shouldScaleAttributes() { return this.getAttackTarget() != null && (this.getAttackTarget() instanceof EntityPlayer || this.getAttackTarget() instanceof IEntityOwnable && ((IEntityOwnable) this.getAttackTarget()).getOwnerId() != null) && this.getOwnerId() == null; }
/** * A static method used to see if an entity is a suitable target through a number of checks. */ public static boolean isSuitableTarget(EntityLiving attacker, EntityLivingBase target, boolean includeInvincibles, boolean checkSight) { if (target == null) { return false; } else if (target == attacker) { return false; } else if (!target.isEntityAlive()) { return false; } else if (!attacker.canAttackClass(target.getClass())) { return false; } else if (attacker.isOnSameTeam(target)) { return false; } else { if (attacker instanceof IEntityOwnable && ((IEntityOwnable)attacker).getOwnerId() != null) { if (target instanceof IEntityOwnable && ((IEntityOwnable)attacker).getOwnerId().equals(target.getUniqueID())) { return false; } if (target == ((IEntityOwnable)attacker).getOwner()) { return false; } } else if (target instanceof EntityPlayer && !includeInvincibles && ((EntityPlayer)target).capabilities.disableDamage) { return false; } return !checkSight || attacker.getEntitySenses().canSee(target); } }
@Override public void onEntityTick(@Nonnull EntityArmyMember armyMember) { for (Entity entity : armyMember.world.getEntitiesWithinAABBExcludingEntity(armyMember, armyMember.getEntityBoundingBox().grow(5))) if (entity instanceof EntityLivingBase && entity instanceof IEntityOwnable && ((IEntityOwnable) entity).getOwnerId() != null && ((IEntityOwnable) entity).getOwnerId().equals(armyMember.getOwnerId()) && ((EntityLivingBase) entity).getActivePotionEffect(MobEffects.RESISTANCE) == null) ((EntityLivingBase) entity).addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, 120)); }
public void collectEntityData(List<String> lines, RayTraceResult ray, Entity entity){ String nameLine = entity.getDisplayName().getFormattedText() + " (#"+entity.getEntityId()+")"; lines.add(nameLine); boolean handledRider = false; if(entity instanceof EntityItemFrame){ EntityItemFrame frame = (EntityItemFrame)entity; ItemStack item = frame.getDisplayedItem(); if(ItemStackTools.isEmpty(item)){ lines.add("Item: "+Lang.localize("gui.empty")); } else { lines.add("Item: "+item.getDisplayName()); } } if(entity instanceof EntityLivingBase){ EntityLivingBase living = (EntityLivingBase)entity; String health = "Health: "+(living.getHealth()+" / "+ living.getMaxHealth()); lines.add(health); } if(entity instanceof EntityBoat){ EntityBoat boat = (EntityBoat)entity; if(boat.getControllingPassenger() !=null){ lines.add("Driver: "+boat.getControllingPassenger().getDisplayName().getFormattedText()); } else { lines.add("Driver: "+Lang.localize("gui.empty")); } if(!boat.getPassengers().isEmpty() && boat.getPassengers().size() > 1 && boat.getPassengers().get(1) !=null){ lines.add("Passenger: "+boat.getPassengers().get(1).getDisplayName().getFormattedText()); } else { lines.add("Passenger: "+Lang.localize("gui.empty")); } handledRider = true; } if(entity instanceof EntityMinecart){ EntityMinecart cart = (EntityMinecart)entity; if(cart instanceof EntityMinecartEmpty){ if(cart.getControllingPassenger() !=null){ lines.add("Rider: "+cart.getControllingPassenger().getDisplayName().getFormattedText()); } else { lines.add("Rider: "+Lang.localize("gui.empty")); } } if(cart instanceof EntityMinecartFurnace){ EntityMinecartFurnace furnace = (EntityMinecartFurnace)cart; int fuel = ObfuscationReflectionHelper.getPrivateValue(EntityMinecartFurnace.class, furnace, 1); lines.add("Fuel: "+TimeUtil.getTimeFromTicks(fuel)); } handledRider = true; } if(entity instanceof IEntityOwnable){ IEntityOwnable ownable = (IEntityOwnable)entity; UUID owner = ownable.getOwnerId(); if(owner !=null){ String name = ProfileUtil.getUsername(owner); if(name != ProfileUtil.ERROR){ lines.add("Owner: "+name); } } } if(!handledRider && entity.getControllingPassenger() !=null){ lines.add("Rider: "+entity.getControllingPassenger().getDisplayName().getFormattedText()); } }
public boolean passesFilter(Entity entity){ if(filter == null || filter == FilterType.NONE) return false; switch(filter){ default : case ALL : { return true; } case PLAYER : { return entity instanceof EntityPlayer; } case UNDEAD : { return (entity instanceof EntityLivingBase && ((EntityLivingBase)entity).getCreatureAttribute() == EnumCreatureAttribute.UNDEAD); } case ARTHROPOD : { return (entity instanceof EntityLivingBase && ((EntityLivingBase)entity).getCreatureAttribute() == EnumCreatureAttribute.ARTHROPOD); } case MONSTER : { return (entity instanceof IMob); } case ANIMAL : { return (entity instanceof EntityAnimal); } case LIVING : { return (entity instanceof EntityLiving); } case WATER : { return (entity instanceof EntityWaterMob || entity instanceof EntityGuardian); } case BABY : { return (entity instanceof EntityLivingBase && ((EntityLivingBase)entity).isChild()); } case PET : { return (entity instanceof IEntityOwnable); } case SLIME : { return (entity instanceof EntitySlime); } case VILLAGER : { return (entity instanceof EntityVillager); } case ITEM : { return (entity instanceof EntityItem); } } }
protected boolean isSuitableTarget(EntityLivingBase target, boolean p_75296_2_) { if (target == null) { return false; } else if (target == this.taskOwner) { return false; } else if (!target.isEntityAlive()) { return false; } else if (!this.taskOwner.canAttackClass(target.getClass())) { return false; } else { if (this.taskOwner instanceof IEntityOwnable && StringUtils.isNotEmpty(((IEntityOwnable)this.taskOwner).func_152113_b())) { if (target instanceof IEntityOwnable && ((IEntityOwnable)this.taskOwner).func_152113_b().equals(((IEntityOwnable)target).func_152113_b())) { return false; } if (target == ((IEntityOwnable)this.taskOwner).getOwner()) { return false; } } else if (target instanceof EntityPlayer && !p_75296_2_ && ((EntityPlayer)target).capabilities.disableDamage) { return false; } if (!this.taskOwner.isWithinHomeDistance(MathHelper.floor_double(target.posX), MathHelper.floor_double(target.posY), MathHelper.floor_double(target.posZ))) { return false; } else if (this.shouldCheckSight && !this.taskOwner.getEntitySenses().canSee(target)) { return false; } else { if (this.nearbyOnly) { if (--this.targetSearchDelay <= 0) { this.targetSearchStatus = 0; } if (this.targetSearchStatus == 0) { this.targetSearchStatus = this.canEasilyReach(target) ? 1 : 2; } if (this.targetSearchStatus == 2) { return false; } } return true; } } }
protected boolean isSuitableTarget(EntityLivingBase target, boolean p_75296_2_) { if (target == null) { return false; } else if (target == this.taskOwner) { return false; } else if (!target.isEntityAlive()) { return false; } else if (!this.taskOwner.canAttackClass(target.getClass())) { return false; } else { if (this.taskOwner instanceof IEntityOwnable && StringUtils.isNullOrEmpty(((IEntityOwnable)this.taskOwner).func_152113_b())) { if (target instanceof IEntityOwnable && ((IEntityOwnable)this.taskOwner).func_152113_b().equals(((IEntityOwnable)target).func_152113_b())) { return false; } if (target == ((IEntityOwnable)this.taskOwner).getOwner()) { return false; } } else if (target instanceof EntityPlayer && !p_75296_2_ && ((EntityPlayer)target).capabilities.disableDamage) { return false; } if (!this.taskOwner.isWithinHomeDistance(MathHelper.floor_double(target.posX), MathHelper.floor_double(target.posY), MathHelper.floor_double(target.posZ))) { return false; } else if (this.shouldCheckSight && !this.taskOwner.getEntitySenses().canSee(target)) { return false; } else { if (this.nearbyOnly) { if (--this.targetSearchDelay <= 0) { this.targetSearchStatus = 0; } if (this.targetSearchStatus == 0) { this.targetSearchStatus = this.canEasilyReach(target) ? 1 : 2; } if (this.targetSearchStatus == 2) { return false; } } return true; } } }
/** * A method used to see if an entity is a suitable target through a number of checks. */ protected boolean isSuitableTarget(EntityLivingBase par1EntityLivingBase, boolean par2) { if (par1EntityLivingBase == null) { return false; } else if (par1EntityLivingBase == this.taskOwner) { return false; } else if (!par1EntityLivingBase.isEntityAlive()) { return false; } else if (!this.taskOwner.canAttackClass(par1EntityLivingBase.getClass())) { return false; } else { if (this.taskOwner instanceof IEntityOwnable && StringUtils.isNotEmpty(((IEntityOwnable)this.taskOwner).getOwnerName())) { if (par1EntityLivingBase instanceof IEntityOwnable && ((IEntityOwnable)this.taskOwner).getOwnerName().equals(((IEntityOwnable)par1EntityLivingBase).getOwnerName())) { return false; } if (par1EntityLivingBase == ((IEntityOwnable)this.taskOwner).getOwner()) { return false; } } else if (par1EntityLivingBase instanceof EntityPlayer && !par2 && ((EntityPlayer)par1EntityLivingBase).capabilities.disableDamage) { return false; } if (!this.taskOwner.isWithinHomeDistance(MathHelper.floor_double(par1EntityLivingBase.posX), MathHelper.floor_double(par1EntityLivingBase.posY), MathHelper.floor_double(par1EntityLivingBase.posZ))) { return false; } else if (this.shouldCheckSight && !this.taskOwner.getEntitySenses().canSee(par1EntityLivingBase)) { return false; } else { if (this.nearbyOnly) { if (--this.targetSearchDelay <= 0) { this.targetSearchStatus = 0; } if (this.targetSearchStatus == 0) { this.targetSearchStatus = this.canEasilyReach(par1EntityLivingBase) ? 1 : 2; } if (this.targetSearchStatus == 2) { return false; } } return true; } } }
protected boolean isSuitableTarget(EntityLivingBase p_75296_1_, boolean p_75296_2_) { if (p_75296_1_ == null) { return false; } else if (p_75296_1_ == this.taskOwner) { return false; } else if (!p_75296_1_.isEntityAlive()) { return false; } else if (!this.taskOwner.canAttackClass(p_75296_1_.getClass())) { return false; } else { if (this.taskOwner instanceof IEntityOwnable && StringUtils.isNotEmpty(((IEntityOwnable)this.taskOwner).func_152113_b())) { if (p_75296_1_ instanceof IEntityOwnable && ((IEntityOwnable)this.taskOwner).func_152113_b().equals(((IEntityOwnable)p_75296_1_).func_152113_b())) { return false; } if (p_75296_1_ == ((IEntityOwnable)this.taskOwner).getOwner()) { return false; } } else if (p_75296_1_ instanceof EntityPlayer && !p_75296_2_ && ((EntityPlayer)p_75296_1_).capabilities.disableDamage) { return false; } if (!this.taskOwner.isWithinHomeDistance(MathHelper.floor_double(p_75296_1_.posX), MathHelper.floor_double(p_75296_1_.posY), MathHelper.floor_double(p_75296_1_.posZ))) { return false; } else if (this.shouldCheckSight && !this.taskOwner.getEntitySenses().canSee(p_75296_1_)) { return false; } else { if (this.nearbyOnly) { if (--this.targetSearchDelay <= 0) { this.targetSearchStatus = 0; } if (this.targetSearchStatus == 0) { this.targetSearchStatus = this.canEasilyReach(p_75296_1_) ? 1 : 2; } if (this.targetSearchStatus == 2) { return false; } } return true; } } }
@Override public boolean itemInteractionForEntity(@Nonnull ItemStack item, @Nonnull EntityPlayer player, @Nonnull EntityLivingBase entity, @Nonnull EnumHand hand) { if (entity.world.isRemote) { return false; } boolean isCreative = player.capabilities.isCreativeMode; if (CapturedMob.containsSoul(item) && !isCreative) { return false; } // first check if that entity can be picked up at all CapturedMob capturedMob = CapturedMob.create(entity); if (capturedMob == null) { if (entity instanceof EntityPlayer) { player.sendMessage(Lang.SOUL_VIAL_DENIED_PLAYER.toChatServer()); } else if (CapturedMob.isBlacklisted(entity)) { player.sendMessage(Lang.SOUL_VIAL_DENIED_AALISTED.toChatServer()); } return false; } // then check for reasons this specific one cannot if (entity instanceof IEntityOwnable && ((IEntityOwnable) entity).getOwnerId() != null && !player.equals(((IEntityOwnable) entity).getOwner()) && !PermissionAPI.hasPermission(player.getGameProfile(), permissionPickupOwned, new TargetContext(player, entity))) { player.sendMessage(Lang.SOUL_VIAL_DENIED_OWNED_PET.toChatServer()); return false; } if (!PermissionAPI.hasPermission(player.getGameProfile(), permissionPickup, new TargetContext(player, entity))) { player.sendMessage(Lang.SOUL_VIAL_DENIED.toChatServer()); return false; } ItemStack capturedMobVessel = capturedMob.toStack(this, 1, 1); player.swingArm(hand); if (!isCreative) { entity.setDead(); if (entity.isDead) { // Forge Bug: if the current itemstack is left empty, // forge replaces the hotbar item with EMPTY itself. // So we do not shrink the stack when it is 1. if (item.getCount() > 1) { item.shrink(1); // Since this stack still exists, add the new vial to the first location, or drop if (!player.inventory.addItemStackToInventory(capturedMobVessel)) { player.dropItem(capturedMobVessel, false); } } else { // Otherwise, just replace the stack player.setHeldItem(hand, capturedMobVessel); } player.inventoryContainer.detectAndSendChanges(); return true; } } else { if (!player.inventory.addItemStackToInventory(capturedMobVessel)) { player.dropItem(capturedMobVessel, false); } player.inventoryContainer.detectAndSendChanges(); return true; } return false; }