Java Code Examples for net.minecraft.world.World.getEntitiesWithinAABB()

The following are Jave code examples for showing how to use getEntitiesWithinAABB() of the net.minecraft.world.World class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: CustomWorldGen   File: EntityLeashKnot.java   View Source Code Vote up 6 votes
public static EntityLeashKnot getKnotForPosition(World worldIn, BlockPos pos)
{
    int i = pos.getX();
    int j = pos.getY();
    int k = pos.getZ();

    for (EntityLeashKnot entityleashknot : worldIn.getEntitiesWithinAABB(EntityLeashKnot.class, new AxisAlignedBB((double)i - 1.0D, (double)j - 1.0D, (double)k - 1.0D, (double)i + 1.0D, (double)j + 1.0D, (double)k + 1.0D)))
    {
        if (entityleashknot.getHangingPosition().equals(pos))
        {
            return entityleashknot;
        }
    }

    return null;
}
 
Example 2
Project: Backmemed   File: EntityLeashKnot.java   View Source Code Vote up 6 votes
@Nullable
public static EntityLeashKnot getKnotForPosition(World worldIn, BlockPos pos)
{
    int i = pos.getX();
    int j = pos.getY();
    int k = pos.getZ();

    for (EntityLeashKnot entityleashknot : worldIn.getEntitiesWithinAABB(EntityLeashKnot.class, new AxisAlignedBB((double)i - 1.0D, (double)j - 1.0D, (double)k - 1.0D, (double)i + 1.0D, (double)j + 1.0D, (double)k + 1.0D)))
    {
        if (entityleashknot.getHangingPosition().equals(pos))
        {
            return entityleashknot;
        }
    }

    return null;
}
 
Example 3
Project: DecompiledMinecraft   File: EntityLeashKnot.java   View Source Code Vote up 6 votes
public static EntityLeashKnot getKnotForPosition(World worldIn, BlockPos pos)
{
    int i = pos.getX();
    int j = pos.getY();
    int k = pos.getZ();

    for (EntityLeashKnot entityleashknot : worldIn.getEntitiesWithinAABB(EntityLeashKnot.class, new AxisAlignedBB((double)i - 1.0D, (double)j - 1.0D, (double)k - 1.0D, (double)i + 1.0D, (double)j + 1.0D, (double)k + 1.0D)))
    {
        if (entityleashknot.getHangingPosition().equals(pos))
        {
            return entityleashknot;
        }
    }

    return null;
}
 
Example 4
Project: uniquecrops   File: GrowthSteps.java   View Source Code Vote up 6 votes
@Override
public boolean canAdvance(World world, BlockPos pos, IBlockState state) {

	List<EntityItem> items = world.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(pos, pos.add(1, 1, 1)));
	for (EntityItem item : items) {
		if (!item.isDead && item.getEntityItem() != null) {
			if (item.getEntityItem().getItem() == Items.WATER_BUCKET)
			{
				UCPacketHandler.sendToNearbyPlayers(world, pos, new PacketUCEffect(EnumParticleTypes.WATER_DROP, pos.getX(), pos.getY(), pos.getZ(), 6));
				item.setEntityItemStack(new ItemStack(Items.BUCKET, 1, 0));
				return true;
			}
		}
	}
	return false;
}
 
Example 5
Project: BaseClient   File: BlockPressurePlate.java   View Source Code Vote up 5 votes
protected int computeRedstoneStrength(World worldIn, BlockPos pos)
{
    AxisAlignedBB axisalignedbb = this.getSensitiveAABB(pos);
    List <? extends Entity > list;

    switch (this.sensitivity)
    {
        case EVERYTHING:
            list = worldIn.getEntitiesWithinAABBExcludingEntity((Entity)null, axisalignedbb);
            break;

        case MOBS:
            list = worldIn.<Entity>getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb);
            break;

        default:
            return 0;
    }

    if (!list.isEmpty())
    {
        for (Entity entity : list)
        {
            if (!entity.doesEntityNotTriggerPressurePlate())
            {
                return 15;
            }
        }
    }

    return 0;
}
 
Example 6
Project: Bewitchment   File: AutoPlantBrew.java   View Source Code Vote up 5 votes
@Override
void safeImpact(BlockPos pos, @Nullable EnumFacing side, World world, int amplifier) {
	AxisAlignedBB space = new AxisAlignedBB(pos).grow(2 + MathHelper.clamp(amplifier, 0, 5));
	List<EntityItem> items = world.getEntitiesWithinAABB(EntityItem.class, space, input -> input != null && isSeed(input.getItem()));
	if (items.isEmpty()) return;
	plantAll(items, world, pos, amplifier);
}
 
Example 7
Project: harshencastle   File: SoulReminder.java   View Source Code Vote up 5 votes
@Override
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
	isTicking = true;
	List<Entity> playersWithin = worldIn.getEntitiesWithinAABB(EntityPlayer.class, new  AxisAlignedBB(pos, pos.add(1, 1, 1)));
	if(!playersWithin.isEmpty())
		for(Object player: playersWithin.toArray())
			((EntityPlayer)player).addPotionEffect(new PotionEffect(Potion.getPotionById(9), 200));
	this.world = worldIn;
	this.pos = pos;
	worldIn.scheduleBlockUpdate(pos, this, 10, 3);
	if(world != null && pos != null)
		if (world instanceof WorldServer)
			((WorldServer)world).spawnParticle(EnumParticleTypes.CLOUD, false, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 7,  0.3, 0.2, 0.3, 0, new int[EnumParticleTypes.CLOUD.getArgumentCount()]);
	super.updateTick(worldIn, pos, state, rand);
}
 
Example 8
Project: Halloween   File: ItemCandy.java   View Source Code Vote up 5 votes
@Override
protected void onFoodEaten(ItemStack stack, World world, EntityPlayer player)
{
	List<EntityCurse> entities = world.getEntitiesWithinAABB(EntityCurse.class, player.getEntityBoundingBox().grow(4.0D, 4.0D, 4.0D));
	for (EntityCurse entity : entities)
	{
		if (entity.victim == player)
		{
			entity.setDead();
		}
	}
}
 
Example 9
Project: BaseClient   File: BlockButton.java   View Source Code Vote up 5 votes
private void checkForArrows(World worldIn, BlockPos pos, IBlockState state)
{
    this.updateBlockBounds(state);
    List <? extends Entity > list = worldIn.<Entity>getEntitiesWithinAABB(EntityArrow.class, new AxisAlignedBB((double)pos.getX() + this.minX, (double)pos.getY() + this.minY, (double)pos.getZ() + this.minZ, (double)pos.getX() + this.maxX, (double)pos.getY() + this.maxY, (double)pos.getZ() + this.maxZ));
    boolean flag = !list.isEmpty();
    boolean flag1 = ((Boolean)state.getValue(POWERED)).booleanValue();

    if (flag && !flag1)
    {
        worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(true)));
        this.notifyNeighbors(worldIn, pos, (EnumFacing)state.getValue(FACING));
        worldIn.markBlockRangeForRenderUpdate(pos, pos);
        worldIn.playSoundEffect((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, "random.click", 0.3F, 0.6F);
    }

    if (!flag && flag1)
    {
        worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(false)));
        this.notifyNeighbors(worldIn, pos, (EnumFacing)state.getValue(FACING));
        worldIn.markBlockRangeForRenderUpdate(pos, pos);
        worldIn.playSoundEffect((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, "random.click", 0.3F, 0.5F);
    }

    if (flag)
    {
        worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
    }
}
 
Example 10
Project: Mods   File: EntityDispenser.java   View Source Code Vote up 5 votes
public static boolean isNearDispenser(World world, final EntityLivingBase living) {
	List<EntityDispenser> targetList = world.getEntitiesWithinAABB(EntityDispenser.class,
			living.getEntityBoundingBox().grow(2.5D, 2D, 2.5D), new Predicate<EntityDispenser>() {

				@Override
				public boolean apply(EntityDispenser input) {

					return !input.isDisabled() && input.dispenserTarget != null
							&& input.dispenserTarget.contains(living);
				}

			});
	return !targetList.isEmpty();
}
 
Example 11
Project: DecompiledMinecraft   File: BlockRedstoneComparator.java   View Source Code Vote up 5 votes
private EntityItemFrame findItemFrame(World worldIn, final EnumFacing facing, BlockPos pos)
{
    List<EntityItemFrame> list = worldIn.<EntityItemFrame>getEntitiesWithinAABB(EntityItemFrame.class, new AxisAlignedBB((double)pos.getX(), (double)pos.getY(), (double)pos.getZ(), (double)(pos.getX() + 1), (double)(pos.getY() + 1), (double)(pos.getZ() + 1)), new Predicate<Entity>()
    {
        public boolean apply(Entity p_apply_1_)
        {
            return p_apply_1_ != null && p_apply_1_.getHorizontalFacing() == facing;
        }
    });
    return list.size() == 1 ? (EntityItemFrame)list.get(0) : null;
}
 
Example 12
Project: CustomWorldGen   File: BlockRedstoneComparator.java   View Source Code Vote up 5 votes
@Nullable
private EntityItemFrame findItemFrame(World worldIn, final EnumFacing facing, BlockPos pos)
{
    List<EntityItemFrame> list = worldIn.<EntityItemFrame>getEntitiesWithinAABB(EntityItemFrame.class, new AxisAlignedBB((double)pos.getX(), (double)pos.getY(), (double)pos.getZ(), (double)(pos.getX() + 1), (double)(pos.getY() + 1), (double)(pos.getZ() + 1)), new Predicate<Entity>()
    {
        public boolean apply(@Nullable Entity p_apply_1_)
        {
            return p_apply_1_ != null && p_apply_1_.getHorizontalFacing() == facing;
        }
    });
    return list.size() == 1 ? (EntityItemFrame)list.get(0) : null;
}
 
Example 13
Project: DecompiledMinecraft   File: BlockButton.java   View Source Code Vote up 5 votes
private void checkForArrows(World worldIn, BlockPos pos, IBlockState state)
{
    this.updateBlockBounds(state);
    List <? extends Entity > list = worldIn.<Entity>getEntitiesWithinAABB(EntityArrow.class, new AxisAlignedBB((double)pos.getX() + this.minX, (double)pos.getY() + this.minY, (double)pos.getZ() + this.minZ, (double)pos.getX() + this.maxX, (double)pos.getY() + this.maxY, (double)pos.getZ() + this.maxZ));
    boolean flag = !list.isEmpty();
    boolean flag1 = ((Boolean)state.getValue(POWERED)).booleanValue();

    if (flag && !flag1)
    {
        worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(true)));
        this.notifyNeighbors(worldIn, pos, (EnumFacing)state.getValue(FACING));
        worldIn.markBlockRangeForRenderUpdate(pos, pos);
        worldIn.playSoundEffect((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, "random.click", 0.3F, 0.6F);
    }

    if (!flag && flag1)
    {
        worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(false)));
        this.notifyNeighbors(worldIn, pos, (EnumFacing)state.getValue(FACING));
        worldIn.markBlockRangeForRenderUpdate(pos, pos);
        worldIn.playSoundEffect((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, "random.click", 0.3F, 0.5F);
    }

    if (flag)
    {
        worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
    }
}
 
Example 14
Project: DecompiledMinecraft   File: BlockPressurePlate.java   View Source Code Vote up 5 votes
protected int computeRedstoneStrength(World worldIn, BlockPos pos)
{
    AxisAlignedBB axisalignedbb = this.getSensitiveAABB(pos);
    List <? extends Entity > list;

    switch (this.sensitivity)
    {
        case EVERYTHING:
            list = worldIn.getEntitiesWithinAABBExcludingEntity((Entity)null, axisalignedbb);
            break;

        case MOBS:
            list = worldIn.<Entity>getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb);
            break;

        default:
            return 0;
    }

    if (!list.isEmpty())
    {
        for (Entity entity : list)
        {
            if (!entity.doesEntityNotTriggerPressurePlate())
            {
                return 15;
            }
        }
    }

    return 0;
}
 
Example 15
Project: BaseClient   File: TileEntityHopper.java   View Source Code Vote up 4 votes
public static List<EntityItem> func_181556_a(World p_181556_0_, double p_181556_1_, double p_181556_3_, double p_181556_5_)
{
    return p_181556_0_.<EntityItem>getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(p_181556_1_ - 0.5D, p_181556_3_ - 0.5D, p_181556_5_ - 0.5D, p_181556_1_ + 0.5D, p_181556_3_ + 0.5D, p_181556_5_ + 0.5D), EntitySelectors.selectAnything);
}
 
Example 16
Project: Halloween   File: WorldUtils.java   View Source Code Vote up 4 votes
public static <T extends Entity> T getRandomEntity(final World world, final Class<? extends T> classEntity, final BlockPos pos, double distance, Predicate<? super T> filter)
{
	List<T> entities = world.getEntitiesWithinAABB(classEntity, new AxisAlignedBB(pos).grow(distance, distance, distance), filter);
	return getRandomEntity(entities, pos);
}
 
Example 17
Project: Backmemed   File: BlockRailDetector.java   View Source Code Vote up 4 votes
protected <T extends EntityMinecart> List<T> findMinecarts(World worldIn, BlockPos pos, Class<T> clazz, Predicate<Entity>... filter)
{
    AxisAlignedBB axisalignedbb = this.getDectectionBox(pos);
    return filter.length != 1 ? worldIn.getEntitiesWithinAABB(clazz, axisalignedbb) : worldIn.getEntitiesWithinAABB(clazz, axisalignedbb, filter[0]);
}
 
Example 18
Project: DecompiledMinecraft   File: TileEntityHopper.java   View Source Code Vote up 4 votes
public static List<EntityItem> func_181556_a(World p_181556_0_, double p_181556_1_, double p_181556_3_, double p_181556_5_)
{
    return p_181556_0_.<EntityItem>getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(p_181556_1_ - 0.5D, p_181556_3_ - 0.5D, p_181556_5_ - 0.5D, p_181556_1_ + 0.5D, p_181556_3_ + 0.5D, p_181556_5_ + 0.5D), EntitySelectors.selectAnything);
}
 
Example 19
Project: DecompiledMinecraft   File: BlockRailDetector.java   View Source Code Vote up 4 votes
protected <T extends EntityMinecart> List<T> findMinecarts(World worldIn, BlockPos pos, Class<T> clazz, Predicate<Entity>... filter)
{
    AxisAlignedBB axisalignedbb = this.getDectectionBox(pos);
    return filter.length != 1 ? worldIn.getEntitiesWithinAABB(clazz, axisalignedbb) : worldIn.getEntitiesWithinAABB(clazz, axisalignedbb, filter[0]);
}
 
Example 20
Project: Halloween   File: WorldUtils.java   View Source Code Vote up 4 votes
public static <T extends Entity> T getClosestEntity(final World world, final Class<? extends T> classEntity, final BlockPos pos, double distance, Predicate<? super T> filter)
{
	List<T> entities = world.getEntitiesWithinAABB(classEntity, new AxisAlignedBB(pos).grow(distance, distance, distance), filter);
	return getClosestEntity(entities, pos);
}