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

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

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

World.getEntitiesWithinAABB介绍

暂无

代码示例

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

  1. private int countEntitesAround( World world, BlockPos pos )
  2. {
  3. final AxisAlignedBB t = new AxisAlignedBB( pos ).grow( 8 );
  4. final List<Entity> list = world.getEntitiesWithinAABB( Entity.class, t );
  5. return list.size();
  6. }
  7. }

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

  1. public static <T> List<T> getEntitiesAround(Class<? extends T> clazz, World world, double x, double y, double z) {
  2. int r = SPARK_SCAN_RANGE;
  3. List entities = world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(x - r, y - r, z - r, x + r, y + r, z + r), Predicates.instanceOf(clazz));
  4. return entities;
  5. }

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

  1. List<EntityItem> getItems() {
  2. return world.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(pos, pos.add(1, 1, 1)));
  3. }

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

  1. private List<ICorporeaSpark> getNearbySparks() {
  2. return (List) world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(posX - SCAN_RANGE, posY - SCAN_RANGE, posZ - SCAN_RANGE, posX + SCAN_RANGE, posY + SCAN_RANGE, posZ + SCAN_RANGE), Predicates.instanceOf(ICorporeaSpark.class));
  3. }

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

  1. /**
  2. * Gets the spark attached to the block in the coords passed in. Note that the coords passed
  3. * in are for the block that the spark will be on, not the coords of the spark itself.
  4. */
  5. public static ICorporeaSpark getSparkForBlock(World world, BlockPos pos) {
  6. List<Entity> sparks = world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(pos.up(), pos.add(1, 2, 1)), Predicates.instanceOf(ICorporeaSpark.class));
  7. return sparks.isEmpty() ? null : (ICorporeaSpark) sparks.get(0);
  8. }

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

  1. public List<ItemStack> getFilter() {
  2. List<ItemStack> filter = new ArrayList<>();
  3. for(EnumFacing dir : EnumFacing.HORIZONTALS) {
  4. List<EntityItemFrame> frames = world.getEntitiesWithinAABB(EntityItemFrame.class, new AxisAlignedBB(pos.offset(dir), pos.offset(dir).add(1, 1, 1)));
  5. for(EntityItemFrame frame : frames) {
  6. EnumFacing orientation = frame.facingDirection;
  7. if(orientation == dir)
  8. filter.add(frame.getDisplayedItem());
  9. }
  10. }
  11. return filter;
  12. }

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

  1. @Override
  2. public ISparkEntity getAttachedSpark() {
  3. List sparks = world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(pos.up(), pos.up().add(1, 1, 1)), Predicates.instanceOf(ISparkEntity.class));
  4. if(sparks.size() == 1) {
  5. Entity e = (Entity) sparks.get(0);
  6. return (ISparkEntity) e;
  7. }
  8. return null;
  9. }

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

  1. @Override
  2. public ISparkEntity getAttachedSpark() {
  3. List<Entity> sparks = world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(pos.up(), pos.up().add(1, 1, 1)), Predicates.instanceOf(ISparkEntity.class));
  4. if(sparks.size() == 1) {
  5. Entity e = sparks.get(0);
  6. return (ISparkEntity) e;
  7. }
  8. return null;
  9. }

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

  1. @Override
  2. public void updateBurst(IManaBurst burst, EntityThrowable entity, ItemStack stack) {
  3. if(burst.isFake()) {
  4. if(entity.world.isRemote)
  5. return;
  6. AxisAlignedBB axis = new AxisAlignedBB(entity.posX, entity.posY, entity.posZ, entity.lastTickPosX, entity.lastTickPosY, entity.lastTickPosZ).grow(0.25);
  7. List<EntityLivingBase> entities = entity.world.getEntitiesWithinAABB(EntityLivingBase.class, axis);
  8. if(!entities.isEmpty()) {
  9. Entity e = (Entity) burst;
  10. e.getEntityData().setBoolean(TAG_TRIPPED, true);
  11. }
  12. }
  13. }

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

  1. @Override
  2. public void update() {
  3. if (world.isRemote)
  4. return;
  5. int range = 6;
  6. int entityCount = world.getEntitiesWithinAABB(EntityAnimal.class, new AxisAlignedBB(pos.add(-range, -range, -range), pos.add(range + 1, range + 1, range + 1))).size();
  7. if(entityCount != entities) {
  8. entities = entityCount;
  9. world.updateComparatorOutputLevel(pos, world.getBlockState(pos).getBlock());
  10. }
  11. }

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

  1. @Override
  2. public ISparkEntity getAttachedSpark() {
  3. List<Entity> sparks = world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(pos.getX(), pos.getY() + 1, pos.getZ(), pos.getX() + 1, pos.getY() + 2, pos.getZ() + 1), Predicates.instanceOf(ISparkEntity.class));
  4. if(sparks.size() == 1) {
  5. Entity e = sparks.get(0);
  6. return (ISparkEntity) e;
  7. }
  8. return null;
  9. }

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

  1. @Override
  2. public boolean isTriggerActive(IStatementContainer source, IStatementParameter[] parameters) {
  3. World world = source.getTile().getWorld();
  4. int x = source.getTile().getPos().getX(), y = source.getTile().getPos().getY(), z = source.getTile().getPos().getZ();
  5. boolean output = world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(x, y, z, x + 1, y + 1, z + 1), Predicates.instanceOf(IManaBurst.class)).size() != 0;
  6. if(output)
  7. for(int i = 0; i < 4; i++)
  8. Botania.proxy.sparkleFX(x + Math.random(), y + Math.random(), z + Math.random(), 1F, 0.2F, 0.2F, 0.7F + 0.5F * (float) Math.random(), 5);
  9. return output;
  10. }

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

  1. private static int getGaiaGuardiansAround(World world, BlockPos source) {
  2. float range = 15F;
  3. List l = world.getEntitiesWithinAABB(EntityDoppleganger.class, new AxisAlignedBB(source.getX() + 0.5 - range, source.getY() + 0.5 - range, source.getZ() + 0.5 - range, source.getX() + 0.5 + range, source.getY() + 0.5 + range, source.getZ() + 0.5 + range));
  4. return l.size();
  5. }

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

  1. @Override
  2. public void update() {
  3. boolean state = world.getBlockState(getPos()).getValue(BotaniaStateProps.POWERED);
  4. boolean expectedState = world.getEntitiesWithinAABB(EntityThrowable.class, new AxisAlignedBB(pos, pos.add(1, 1, 1)), Predicates.instanceOf(IManaBurst.class)).size() != 0;
  5. if(state != expectedState && !world.isRemote)
  6. world.setBlockState(getPos(), world.getBlockState(getPos()).withProperty(BotaniaStateProps.POWERED, expectedState), 1 | 2);
  7. if(expectedState)
  8. for(int i = 0; i < 4; i++)
  9. Botania.proxy.sparkleFX(pos.getX() + Math.random(), pos.getY() + Math.random(), pos.getZ() + Math.random(), 1F, 0.2F, 0.2F, 0.7F + 0.5F * (float) Math.random(), 5);
  10. }

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

  1. @Override
  2. public void onWornTick(ItemStack stack, EntityLivingBase player) {
  3. super.onWornTick(stack, player);
  4. if(!(player instanceof EntityPlayer))
  5. return;
  6. EntityPlayer eplayer = (EntityPlayer) player;
  7. double range = 24;
  8. AxisAlignedBB aabb = new AxisAlignedBB(player.posX, player.posY, player.posZ, player.posX, player.posY, player.posZ).grow(range);
  9. List<EntityLivingBase> mobs = player.world.getEntitiesWithinAABB(EntityLivingBase.class, aabb, (Entity e) -> e instanceof IMob);
  10. if(!mobs.isEmpty())
  11. for(EntityLivingBase e : mobs) {
  12. PotionEffect potion = e.getActivePotionEffect(MobEffects.GLOWING);
  13. if((potion == null || potion.getDuration() <= 2) && ManaItemHandler.requestManaExact(stack, eplayer, COST, true))
  14. e.addPotionEffect(new PotionEffect(MobEffects.GLOWING, 12, 0));
  15. }
  16. }

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

  1. private List<EntityPlayer> getPlayersAround() {
  2. float range = 15F;
  3. return world.getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(source.getX() + 0.5 - range, source.getY() + 0.5 - range, source.getZ() + 0.5 - range, source.getX() + 0.5 + range, source.getY() + 0.5 + range, source.getZ() + 0.5 + range));
  4. }

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

  1. @SubscribeEvent
  2. public static void onExplosion(ExplosionEvent.Detonate event) {
  3. Explosion e = event.getExplosion();
  4. Vec3d vec = e.getPosition();
  5. List<EntityPlayer> players = event.getWorld().getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(vec.x, vec.y, vec.z, vec.x, vec.y, vec.z).grow(8));
  6. for(EntityPlayer player : players) {
  7. ItemStack charm = BaublesApi.getBaublesHandler(player).getStackInSlot(6);
  8. if(!charm.isEmpty() && charm.getItem() instanceof ItemGoddessCharm && ManaItemHandler.requestManaExact(charm, player, COST, true)) {
  9. event.getAffectedBlocks().clear();
  10. return;
  11. }
  12. }
  13. }

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

  1. @Override
  2. public void onUpdate() {
  3. super.onUpdate();
  4. if(!supertile.getWorld().isRemote && mana > 0) {
  5. List<EntityLivingBase> entities = supertile.getWorld().getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(supertile.getPos().add(-RANGE, -RANGE, -RANGE), supertile.getPos().add(RANGE + 1, RANGE + 1, RANGE + 1)));
  6. for(EntityLivingBase entity : entities)
  7. if(!(entity instanceof EntityPlayer)) {
  8. entity.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 2, 100));
  9. mana--;
  10. if(mana == 0)
  11. return;
  12. }
  13. }
  14. }

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

  1. @Override
  2. public void onUpdate() {
  3. super.onUpdate();
  4. if(supertile.getWorld().isRemote || redstoneSignal > 0)
  5. return;
  6. final int cost = 20;
  7. List<EntityLivingBase> entities = supertile.getWorld().getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(supertile.getPos().add(-RANGE, -RANGE, -RANGE), supertile.getPos().add(RANGE + 1, RANGE + 1, RANGE + 1)));
  8. for(EntityLivingBase entity : entities) {
  9. if(!(entity instanceof EntityPlayer) && entity.getActivePotionEffect(MobEffects.POISON) == null && mana >= cost && !entity.world.isRemote && entity.getCreatureAttribute() != EnumCreatureAttribute.UNDEAD) {
  10. entity.addPotionEffect(new PotionEffect(MobEffects.POISON, 60, 0));
  11. mana -= cost;
  12. }
  13. }
  14. }

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

  1. @Override
  2. public void onUpdate() {
  3. super.onUpdate();
  4. if(!supertile.getWorld().isRemote && supertile.getWorld().provider.getDimension() != 1) {
  5. boolean did = false;
  6. List<EntityPlayer> players = supertile.getWorld().getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(supertile.getPos().add(-RANGE, -RANGE, -RANGE), supertile.getPos().add(RANGE + 1, RANGE + 1, RANGE + 1)));
  7. for(EntityPlayer player : players) {
  8. if(player.getActivePotionEffect(MobEffects.REGENERATION) == null && mana >= COST) {
  9. player.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 59, 2, true, true));
  10. mana -= COST;
  11. did = true;
  12. }
  13. }
  14. if(did)
  15. sync();
  16. }
  17. }

相关文章

World类方法