net.minecraft.world.World.getEntitiesInAABBexcluding()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(11.4k)|赞(0)|评价(0)|浏览(229)

本文整理了Java中net.minecraft.world.World.getEntitiesInAABBexcluding()方法的一些代码示例,展示了World.getEntitiesInAABBexcluding()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。World.getEntitiesInAABBexcluding()方法的具体详情如下:
包路径:net.minecraft.world.World
类名称:World
方法名:getEntitiesInAABBexcluding

World.getEntitiesInAABBexcluding介绍

暂无

代码示例

代码示例来源:origin: Vazkii/Botania

  1. @Override
  2. public boolean hitEntity(ItemStack stack, EntityLivingBase entity, @Nonnull EntityLivingBase attacker) {
  3. if(!(entity instanceof EntityPlayer) && entity != null) {
  4. double range = 8;
  5. List<EntityLivingBase> alreadyTargetedEntities = new ArrayList<>();
  6. int dmg = 5;
  7. long lightningSeed = ItemNBTHelper.getLong(stack, TAG_LIGHTNING_SEED, 0);
  8. Predicate<Entity> selector = e -> e instanceof EntityLivingBase && e instanceof IMob && !(e instanceof EntityPlayer) && !alreadyTargetedEntities.contains(e);
  9. Random rand = new Random(lightningSeed);
  10. EntityLivingBase lightningSource = entity;
  11. int hops = entity.world.isThundering() ? 10 : 4;
  12. for(int i = 0; i < hops; i++) {
  13. List<Entity> entities = entity.world.getEntitiesInAABBexcluding(lightningSource, new AxisAlignedBB(lightningSource.posX - range, lightningSource.posY - range, lightningSource.posZ - range, lightningSource.posX + range, lightningSource.posY + range, lightningSource.posZ + range), selector::test);
  14. if(entities.isEmpty())
  15. break;
  16. EntityLivingBase target = (EntityLivingBase) entities.get(rand.nextInt(entities.size()));
  17. if(attacker instanceof EntityPlayer)
  18. target.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer) attacker), dmg);
  19. else target.attackEntityFrom(DamageSource.causeMobDamage(attacker), dmg);
  20. Botania.proxy.lightningFX(Vector3.fromEntityCenter(lightningSource), Vector3.fromEntityCenter(target), 1, 0x0179C4, 0xAADFFF);
  21. alreadyTargetedEntities.add(target);
  22. lightningSource = target;
  23. dmg--;
  24. }
  25. if(!entity.world.isRemote)
  26. ItemNBTHelper.setLong(stack, TAG_LIGHTNING_SEED, entity.world.rand.nextLong());
  27. }
  28. return super.hitEntity(stack, entity, attacker);
  29. }

代码示例来源:origin: SleepyTrousers/EnderIO

  1. @Override
  2. public @Nonnull List<Entity> getEntitiesInAABBexcluding(@Nullable Entity entityIn, @Nonnull AxisAlignedBB boundingBox,
  3. @Nullable Predicate<? super Entity> predicate) {
  4. return wrapped.getEntitiesInAABBexcluding(entityIn, boundingBox, predicate);
  5. }

代码示例来源:origin: amadornes/MCMultiPart

  1. @Override
  2. public List<Entity> getEntitiesInAABBexcluding(Entity entityIn, AxisAlignedBB boundingBox, Predicate<? super Entity> predicate) {
  3. return getActualWorld().getEntitiesInAABBexcluding(entityIn, boundingBox, predicate);
  4. }

代码示例来源:origin: Alex-the-666/Ice_and_Fire

  1. private boolean areMyrmexNear(double distance){
  2. List<Entity> sentinels = this.myrmex.world.getEntitiesInAABBexcluding(this.myrmex, this.getTargetableArea(distance), this.targetEntitySelector);
  3. List<Entity> hiddenSentinels = new ArrayList<>();
  4. for(Entity sentinel : sentinels){
  5. if(sentinel instanceof EntityMyrmexSentinel && ((EntityMyrmexSentinel) sentinel).isHiding()){
  6. hiddenSentinels.add(sentinel);
  7. }
  8. }
  9. return !hiddenSentinels.isEmpty();
  10. }

代码示例来源:origin: CyclopsMC/EvilCraft

  1. protected void collideWithNearbyEntities() {
  2. List<Entity> list = this.world.getEntitiesInAABBexcluding(this, this.getEntityBoundingBox().grow(0.20000000298023224D, 0.0D, 0.20000000298023224D), Predicates.<Entity>and(EntitySelectors.NOT_SPECTATING, new Predicate<Entity>() {
  3. public boolean apply(Entity p_apply_1_) {
  4. return p_apply_1_.canBePushed();
  5. }
  6. }));
  7. if (!list.isEmpty()){
  8. for (Entity entity : list) {
  9. this.applyEntityCollision(entity);
  10. }
  11. }
  12. }

代码示例来源:origin: Alex-the-666/Ice_and_Fire

  1. @Nullable
  2. public static StymphalianBirdFlock getNearbyFlock(EntityStymphalianBird bird){
  3. float d0 = IceAndFire.CONFIG.stymphalianBirdFlockLength;
  4. List<Entity> list = bird.world.getEntitiesInAABBexcluding(bird, (new AxisAlignedBB(bird.posX, bird.posY, bird.posZ, bird.posX + 1.0D, bird.posY + 1.0D, bird.posZ + 1.0D)).grow(d0, 10.0D, d0), EntityStymphalianBird.STYMPHALIAN_PREDICATE);
  5. Collections.sort(list, new EntityAINearestAttackableTarget.Sorter(bird));
  6. if (!list.isEmpty()) {
  7. Iterator<Entity> itr = list.iterator();
  8. while (itr.hasNext()) {
  9. Entity entity = itr.next();
  10. if(entity instanceof EntityStymphalianBird){
  11. EntityStymphalianBird other = (EntityStymphalianBird)entity;
  12. if(other.flock != null){
  13. return other.flock;
  14. }
  15. }
  16. }
  17. }
  18. return null;
  19. }
  20. public void addToFlock(EntityStymphalianBird bird){

代码示例来源:origin: ldtteam/minecolonies

  1. /**
  2. * Returns the closest entity to avoid.
  3. *
  4. * @return Entity to avoid.
  5. */
  6. private Entity getClosestToAvoid()
  7. {
  8. if (targetEntityClass == EntityPlayer.class)
  9. {
  10. return CompatibilityUtils.getWorld(theEntity).getClosestPlayerToEntity(theEntity, (double) distanceFromEntity);
  11. }
  12. else
  13. {
  14. final Optional<Entity> entityOptional = CompatibilityUtils.getWorld(theEntity).getEntitiesInAABBexcluding(
  15. theEntity,
  16. theEntity.getEntityBoundingBox().expand(
  17. (double) distanceFromEntity,
  18. 3.0D,
  19. (double) distanceFromEntity),
  20. target -> target.isEntityAlive() && EntityAICitizenAvoidEntity.this.theEntity.getEntitySenses().canSee(target))
  21. .stream()
  22. .filter(targetEntityClass::isInstance)
  23. .findFirst();
  24. return entityOptional.isPresent() ? entityOptional.get() : null;
  25. }
  26. }

代码示例来源:origin: Vazkii/Quark

  1. @Override
  2. public boolean onValidSurface() {
  3. if(this.realFacingDirection.getAxis() == EnumFacing.Axis.Y) {
  4. if(!this.world.getCollisionBoxes(this, this.getEntityBoundingBox()).isEmpty()) {
  5. return false;
  6. } else {
  7. BlockPos blockpos = this.hangingPosition.offset(this.realFacingDirection.getOpposite());
  8. IBlockState iblockstate = this.world.getBlockState(blockpos);
  9. if(!iblockstate.isSideSolid(this.world, blockpos, this.realFacingDirection))
  10. if(!iblockstate.getMaterial().isSolid() && !BlockRedstoneDiode.isDiode(iblockstate))
  11. return false;
  12. return this.world.getEntitiesInAABBexcluding(this, this.getEntityBoundingBox(), IS_HANGING_ENTITY).isEmpty();
  13. }
  14. } else
  15. return super.onValidSurface();
  16. }

代码示例来源:origin: Alex-the-666/Ice_and_Fire

  1. @Override
  2. public boolean shouldExecute() {
  3. if (!this.myrmex.canMove() || this.myrmex.getAttackTarget() != null || this.myrmex.releaseTicks < 400 || this.myrmex.mate != null) {
  4. return false;
  5. }
  6. MyrmexHive village = this.myrmex.getHive();
  7. if (village == null) {
  8. village = MyrmexWorldData.get(this.myrmex.world).getNearestHive(new BlockPos(this.myrmex), 100);
  9. }
  10. if (village != null) {
  11. return false;
  12. }
  13. List<Entity> list = this.taskOwner.world.getEntitiesInAABBexcluding(myrmex, this.getTargetableArea(this.getTargetDistance()), this.targetEntitySelector);
  14. if (list.isEmpty()) {
  15. return false;
  16. } else {
  17. Collections.sort(list, this.theNearestAttackableTargetSorter);
  18. for(Entity royal : list){
  19. if(this.myrmex.canMateWith((EntityMyrmexRoyal)royal)){
  20. this.myrmex.mate = (EntityMyrmexRoyal)royal;
  21. this.myrmex.world.setEntityState(this.myrmex, (byte) 76);
  22. return true;
  23. }
  24. }
  25. return false;
  26. }
  27. }

代码示例来源:origin: Alex-the-666/Ice_and_Fire

  1. double d1 = dist;
  2. Entity pointedEntity = null;
  3. List<Entity> list = rider.world.getEntitiesInAABBexcluding(rider, rider.getEntityBoundingBox().expand(vec3d1.x * dist, vec3d1.y * dist, vec3d1.z * dist).grow(1.0D, 1.0D, 1.0D), Predicates.and(EntitySelectors.NOT_SPECTATING, new Predicate<Entity>() {
  4. public boolean apply(@Nullable Entity entity) {
  5. return entity != null && entity.canBeCollidedWith() && entity instanceof EntityLivingBase && !entity.isEntityEqual(dragon) && !entity.isOnSameTeam(dragon) && (!(entity instanceof IDeadMob) || !((IDeadMob) entity).isMobDead());

代码示例来源:origin: JurassiCraftTeam/JurassiCraft2

  1. @Override
  2. public boolean onValidSurface() {
  3. if (!this.world.getCollisionBoxes(this, this.getEntityBoundingBox()).isEmpty()) {
  4. return false;
  5. }
  6. int width = this.getWidthPixels() / 16;
  7. int height = this.getHeightPixels() / 16;
  8. EnumFacing facing = this.facingDirection.rotateYCCW();
  9. BlockPos pos = this.hangingPosition.offset(this.facingDirection.getOpposite()).offset(facing, -(width / 2) + 1);
  10. for (int x = 0; x < width; x++) {
  11. for (int y = 0; y < height; y++) {
  12. BlockPos partPos = pos.offset(facing, x).down(y);
  13. IBlockState state = this.world.getBlockState(partPos);
  14. if (!(state.isSideSolid(this.world, partPos, this.facingDirection) && state.getMaterial().isSolid())) {
  15. return false;
  16. }
  17. }
  18. }
  19. return this.world.getEntitiesInAABBexcluding(this, this.getEntityBoundingBox(), IS_ATTRACTION_SIGN).isEmpty();
  20. }

代码示例来源:origin: JurassiCraftTeam/JurassiCraft2

  1. @Override
  2. public boolean onValidSurface() {
  3. if (!this.world.getCollisionBoxes(this, this.getEntityBoundingBox()).isEmpty()) {
  4. return false;
  5. }
  6. int width = this.getWidthPixels() / 16;
  7. int height = this.getHeightPixels() / 16;
  8. EnumFacing facing = this.facingDirection.rotateYCCW();
  9. BlockPos pos = this.hangingPosition.offset(this.facingDirection.getOpposite()).offset(facing, -(width / 2) + 1);
  10. for (int x = 0; x < width; x++) {
  11. for (int y = 0; y < height; y++) {
  12. BlockPos partPos = pos.offset(facing, x).down(y);
  13. IBlockState state = this.world.getBlockState(partPos);
  14. if (!(state.isSideSolid(this.world, partPos, this.facingDirection) && state.getMaterial().isSolid())) {
  15. return false;
  16. }
  17. }
  18. }
  19. return this.world.getEntitiesInAABBexcluding(this, this.getEntityBoundingBox(), IS_MURAL).isEmpty();
  20. }

代码示例来源:origin: TeamLapen/Vampirism

  1. @Override
  2. public boolean activate(final IVampirePlayer vampire) {
  3. EntityPlayer player = vampire.getRepresentingPlayer();
  4. List l = player.getEntityWorld().getEntitiesInAABBexcluding(player, player.getEntityBoundingBox().grow(10, 5, 10), vampire.getNonFriendlySelector(true, false)::test);
  5. for (Object o : l) {
  6. if (o instanceof EntityBlindingBat) continue;
  7. if (!(o instanceof EntityLivingBase)) continue;
  8. if (o instanceof EntityPlayer && ItemHunterCoat.isFullyEquipped((EntityPlayer) o)) continue;
  9. EntityLivingBase e = (EntityLivingBase) o;
  10. e.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, Balance.vpa.FREEZE_DURATION * 20, 10));
  11. e.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, Balance.vpa.FREEZE_DURATION * 20, 10));
  12. e.addPotionEffect(new PotionEffect(MobEffects.JUMP_BOOST, Balance.vpa.FREEZE_DURATION * 20, 128));
  13. VampLib.proxy.getParticleHandler().spawnParticles(player.getEntityWorld(), ModParticles.GENERIC_PARTICLE, e.posX, e.posY + e.height / 2, e.posZ, 20, 1, e.getRNG(), 2, 20, 0xF0F0F0, 0.4);
  14. }
  15. return l.size() > 0;
  16. }

代码示例来源:origin: TeamWizardry/Wizardry

  1. List<Entity> entities = world.getEntitiesInAABBexcluding(this, new AxisAlignedBB(getPosition()).grow(64, 64, 64), null);
  2. for (Entity entity : entities)
  3. if (entity instanceof EntityPlayer) {
  4. List<Entity> entities = world.getEntitiesInAABBexcluding(this, new AxisAlignedBB(getPosition()).grow(5, 5, 5), null);
  5. for (Entity entity : entities)
  6. if (entity instanceof EntityLivingBase) {

代码示例来源:origin: TeamLapen/Vampirism

  1. List<Entity> list = this.world.getEntitiesInAABBexcluding(this, this.getEntityBoundingBox().grow(2), Predicates.and(EntitySelectors.IS_ALIVE, EntitySelectors.NOT_SPECTATING));
  2. for (Entity e : list) {
  3. if (excludeShooter && e == shootingEntity) {

代码示例来源:origin: Alex-the-666/Ice_and_Fire

  1. double d1 = dist;
  2. Entity pointedEntity = null;
  3. List<Entity> list = worldIn.getEntitiesInAABBexcluding(entity, entity.getEntityBoundingBox().expand(vec3d1.x * dist, vec3d1.y * dist, vec3d1.z * dist).grow(1.0D, 1.0D, 1.0D), Predicates.and(EntitySelectors.NOT_SPECTATING, new Predicate<Entity>() {
  4. public boolean apply(@Nullable Entity entity) {
  5. boolean blindness = entity instanceof EntityLivingBase && ((EntityLivingBase) entity).isPotionActive(MobEffects.BLINDNESS) || (entity instanceof IBlacklistedFromStatues && !((IBlacklistedFromStatues) entity).canBeTurnedToStone());

代码示例来源:origin: sinkillerj/ProjectE

  1. List<Entity> entities = player.getEntityWorld().getEntitiesInAABBexcluding(player,
  2. player.getEntityBoundingBox().offset(player.motionX, player.motionY, player.motionZ).grow(2.0D),
  3. Predicates.instanceOf(EntityLivingBase.class));

代码示例来源:origin: CyclopsMC/EvilCraft

  1. List<Entity> entities = world.getEntitiesInAABBexcluding(entity, box, new Predicate<Entity>() {

代码示例来源:origin: SquidDev-CC/plethora

  1. List<Entity> entityList = entity.getEntityWorld().getEntitiesInAABBexcluding(
  2. entity,
  3. entity.getEntityBoundingBox().expand(

相关文章

World类方法