当前位置: 首页>>代码示例>>Java>>正文


Java EntitySelectors类代码示例

本文整理汇总了Java中net.minecraft.util.EntitySelectors的典型用法代码示例。如果您正苦于以下问题:Java EntitySelectors类的具体用法?Java EntitySelectors怎么用?Java EntitySelectors使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


EntitySelectors类属于net.minecraft.util包,在下文中一共展示了EntitySelectors类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findNearestEntityWithinAABB

import net.minecraft.util.EntitySelectors; //导入依赖的package包/类
public <T extends Entity> T findNearestEntityWithinAABB(Class <? extends T > entityType, AxisAlignedBB aabb, T closestTo)
{
    List<T> list = this.<T>getEntitiesWithinAABB(entityType, aabb);
    T t = null;
    double d0 = Double.MAX_VALUE;

    for (int i = 0; i < list.size(); ++i)
    {
        T t1 = list.get(i);

        if (t1 != closestTo && EntitySelectors.NOT_SPECTATING.apply(t1))
        {
            double d1 = closestTo.getDistanceSqToEntity(t1);

            if (d1 <= d0)
            {
                t = t1;
                d0 = d1;
            }
        }
    }

    return t;
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:25,代码来源:World.java

示例2: getClosestPlayer

import net.minecraft.util.EntitySelectors; //导入依赖的package包/类
/**
 * Gets the closest player to the point within the specified distance (distance can be set to less than 0 to not
 * limit the distance). Args: x, y, z, dist
 */
public EntityPlayer getClosestPlayer(double x, double y, double z, double distance)
{
    double d0 = -1.0D;
    EntityPlayer entityplayer = null;

    for (int i = 0; i < this.playerEntities.size(); ++i)
    {
        EntityPlayer entityplayer1 = (EntityPlayer)this.playerEntities.get(i);

        if (EntitySelectors.NOT_SPECTATING.apply(entityplayer1))
        {
            double d1 = entityplayer1.getDistanceSq(x, y, z);

            if ((distance < 0.0D || d1 < distance * distance) && (d0 == -1.0D || d1 < d0))
            {
                d0 = d1;
                entityplayer = entityplayer1;
            }
        }
    }

    return entityplayer;
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:28,代码来源:World.java

示例3: isAnyPlayerWithinRangeAt

import net.minecraft.util.EntitySelectors; //导入依赖的package包/类
public boolean isAnyPlayerWithinRangeAt(double x, double y, double z, double range)
{
    for (int i = 0; i < this.playerEntities.size(); ++i)
    {
        EntityPlayer entityplayer = (EntityPlayer)this.playerEntities.get(i);

        if (EntitySelectors.NOT_SPECTATING.apply(entityplayer))
        {
            double d0 = entityplayer.getDistanceSq(x, y, z);

            if (range < 0.0D || d0 < range * range)
            {
                return true;
            }
        }
    }

    return false;
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:20,代码来源:World.java

示例4: shouldExecute

import net.minecraft.util.EntitySelectors; //导入依赖的package包/类
/**
 * Returns whether the EntityAIBase should begin execution.
 */
public boolean shouldExecute()
{
    if (this.targetChance > 0 && this.taskOwner.getRNG().nextInt(this.targetChance) != 0)
    {
        return false;
    }
    else
    {
        double d0 = this.getTargetDistance();
        List<T> list = this.taskOwner.worldObj.<T>getEntitiesWithinAABB(this.targetClass, this.taskOwner.getEntityBoundingBox().expand(d0, 4.0D, d0), Predicates.<T> and (this.targetEntitySelector, EntitySelectors.NOT_SPECTATING));
        Collections.sort(list, this.theNearestAttackableTargetSorter);

        if (list.isEmpty())
        {
            return false;
        }
        else
        {
            this.targetEntity = (EntityLivingBase)list.get(0);
            return true;
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:27,代码来源:EntityAINearestAttackableTarget.java

示例5: func_96112_aD

import net.minecraft.util.EntitySelectors; //导入依赖的package包/类
public boolean func_96112_aD()
{
    if (TileEntityHopper.captureDroppedItems(this))
    {
        return true;
    }
    else
    {
        List<EntityItem> list = this.worldObj.<EntityItem>getEntitiesWithinAABB(EntityItem.class, this.getEntityBoundingBox().expand(0.25D, 0.0D, 0.25D), EntitySelectors.selectAnything);

        if (list.size() > 0)
        {
            TileEntityHopper.putDropInInventoryAllSlots(this, (EntityItem)list.get(0));
        }

        return false;
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:19,代码来源:EntityMinecartHopper.java

示例6: collideWithNearbyEntities

import net.minecraft.util.EntitySelectors; //导入依赖的package包/类
protected void collideWithNearbyEntities()
{
    List<Entity> list = this.worldObj.getEntitiesInAABBexcluding(this, this.getEntityBoundingBox().expand(0.20000000298023224D, 0.0D, 0.20000000298023224D), Predicates.<Entity> and (EntitySelectors.NOT_SPECTATING, new Predicate<Entity>()
    {
        public boolean apply(Entity p_apply_1_)
        {
            return p_apply_1_.canBePushed();
        }
    }));

    if (!list.isEmpty())
    {
        for (int i = 0; i < list.size(); ++i)
        {
            Entity entity = (Entity)list.get(i);
            this.collideWithEntity(entity);
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:20,代码来源:EntityLivingBase.java

示例7: getComparatorInputOverride

import net.minecraft.util.EntitySelectors; //导入依赖的package包/类
public int getComparatorInputOverride(World worldIn, BlockPos pos)
{
    if (((Boolean)worldIn.getBlockState(pos).getValue(POWERED)).booleanValue())
    {
        List<EntityMinecartCommandBlock> list = this.<EntityMinecartCommandBlock>findMinecarts(worldIn, pos, EntityMinecartCommandBlock.class, new Predicate[0]);

        if (!list.isEmpty())
        {
            return ((EntityMinecartCommandBlock)list.get(0)).getCommandBlockLogic().getSuccessCount();
        }

        List<EntityMinecart> list1 = this.<EntityMinecart>findMinecarts(worldIn, pos, EntityMinecart.class, new Predicate[] {EntitySelectors.selectInventories});

        if (!list1.isEmpty())
        {
            return Container.calcRedstoneFromInventory((IInventory)list1.get(0));
        }
    }

    return 0;
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:22,代码来源:BlockRailDetector.java

示例8: findNearestEntityWithinAABB

import net.minecraft.util.EntitySelectors; //导入依赖的package包/类
@Nullable
public <T extends Entity> T findNearestEntityWithinAABB(Class <? extends T > entityType, AxisAlignedBB aabb, T closestTo)
{
    List<T> list = this.<T>getEntitiesWithinAABB(entityType, aabb);
    T t = null;
    double d0 = Double.MAX_VALUE;

    for (int i = 0; i < list.size(); ++i)
    {
        T t1 = list.get(i);

        if (t1 != closestTo && EntitySelectors.NOT_SPECTATING.apply(t1))
        {
            double d1 = closestTo.getDistanceSqToEntity(t1);

            if (d1 <= d0)
            {
                t = t1;
                d0 = d1;
            }
        }
    }

    return t;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:26,代码来源:World.java

示例9: captureDroppedItems

import net.minecraft.util.EntitySelectors; //导入依赖的package包/类
public boolean captureDroppedItems()
{
    if (TileEntityHopper.captureDroppedItems(this))
    {
        return true;
    }
    else
    {
        List<EntityItem> list = this.world.<EntityItem>getEntitiesWithinAABB(EntityItem.class, this.getEntityBoundingBox().expand(0.25D, 0.0D, 0.25D), EntitySelectors.IS_ALIVE);

        if (!list.isEmpty())
        {
            TileEntityHopper.putDropInInventoryAllSlots((IInventory)null, this, (EntityItem)list.get(0));
        }

        return false;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:19,代码来源:EntityMinecartHopper.java

示例10: dispenseArmor

import net.minecraft.util.EntitySelectors; //导入依赖的package包/类
public static ItemStack dispenseArmor(IBlockSource blockSource, ItemStack stack)
{
    BlockPos blockpos = blockSource.getBlockPos().offset((EnumFacing)blockSource.getBlockState().getValue(BlockDispenser.FACING));
    List<EntityLivingBase> list = blockSource.getWorld().<EntityLivingBase>getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(blockpos), Predicates.<EntityLivingBase> and (EntitySelectors.NOT_SPECTATING, new EntitySelectors.ArmoredMob(stack)));

    if (list.isEmpty())
    {
        return ItemStack.field_190927_a;
    }
    else
    {
        EntityLivingBase entitylivingbase = (EntityLivingBase)list.get(0);
        EntityEquipmentSlot entityequipmentslot = EntityLiving.getSlotForItemStack(stack);
        ItemStack itemstack = stack.splitStack(1);
        entitylivingbase.setItemStackToSlot(entityequipmentslot, itemstack);

        if (entitylivingbase instanceof EntityLiving)
        {
            ((EntityLiving)entitylivingbase).setDropChance(entityequipmentslot, 2.0F);
        }

        return stack;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:25,代码来源:ItemArmor.java

示例11: getComparatorInputOverride

import net.minecraft.util.EntitySelectors; //导入依赖的package包/类
public int getComparatorInputOverride(IBlockState blockState, World worldIn, BlockPos pos)
{
    if (((Boolean)blockState.getValue(POWERED)).booleanValue())
    {
        List<EntityMinecartCommandBlock> list = this.<EntityMinecartCommandBlock>findMinecarts(worldIn, pos, EntityMinecartCommandBlock.class, new Predicate[0]);

        if (!list.isEmpty())
        {
            return ((EntityMinecartCommandBlock)list.get(0)).getCommandBlockLogic().getSuccessCount();
        }

        List<EntityMinecart> list1 = this.<EntityMinecart>findMinecarts(worldIn, pos, EntityMinecart.class, new Predicate[] {EntitySelectors.HAS_INVENTORY});

        if (!list1.isEmpty())
        {
            return Container.calcRedstoneFromInventory((IInventory)list1.get(0));
        }
    }

    return 0;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:22,代码来源:BlockRailDetector.java

示例12: getClosestPlayer

import net.minecraft.util.EntitySelectors; //导入依赖的package包/类
@Nullable
public EntityPlayer getClosestPlayer(double posX, double posY, double posZ, double distance, boolean spectator)
{
    double d0 = -1.0D;
    EntityPlayer entityplayer = null;

    for (int i = 0; i < this.playerEntities.size(); ++i)
    {
        EntityPlayer entityplayer1 = (EntityPlayer)this.playerEntities.get(i);

        if ((EntitySelectors.CAN_AI_TARGET.apply(entityplayer1) || !spectator) && (EntitySelectors.NOT_SPECTATING.apply(entityplayer1) || spectator))
        {
            double d1 = entityplayer1.getDistanceSq(posX, posY, posZ);

            if ((distance < 0.0D || d1 < distance * distance) && (d0 == -1.0D || d1 < d0))
            {
                d0 = d1;
                entityplayer = entityplayer1;
            }
        }
    }

    return entityplayer;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:25,代码来源:World.java

示例13: captureDroppedItems

import net.minecraft.util.EntitySelectors; //导入依赖的package包/类
public boolean captureDroppedItems()
{
    if (TileEntityHopper.captureDroppedItems(this))
    {
        return true;
    }
    else
    {
        List<EntityItem> list = this.worldObj.<EntityItem>getEntitiesWithinAABB(EntityItem.class, this.getEntityBoundingBox().expand(0.25D, 0.0D, 0.25D), EntitySelectors.IS_ALIVE);

        if (!list.isEmpty())
        {
            TileEntityHopper.putDropInInventoryAllSlots(this, (EntityItem)list.get(0));
        }

        return false;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:19,代码来源:EntityMinecartHopper.java

示例14: dispenseArmor

import net.minecraft.util.EntitySelectors; //导入依赖的package包/类
public static ItemStack dispenseArmor(IBlockSource blockSource, ItemStack stack)
{
    BlockPos blockpos = blockSource.getBlockPos().offset((EnumFacing)blockSource.getBlockState().getValue(BlockDispenser.FACING));
    List<EntityLivingBase> list = blockSource.getWorld().<EntityLivingBase>getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(blockpos), Predicates.<EntityLivingBase>and(EntitySelectors.NOT_SPECTATING, new EntitySelectors.ArmoredMob(stack)));

    if (list.isEmpty())
    {
        return null;
    }
    else
    {
        EntityLivingBase entitylivingbase = (EntityLivingBase)list.get(0);
        EntityEquipmentSlot entityequipmentslot = EntityLiving.getSlotForItemStack(stack);
        ItemStack itemstack = stack.copy();
        itemstack.stackSize = 1;
        entitylivingbase.setItemStackToSlot(entityequipmentslot, itemstack);

        if (entitylivingbase instanceof EntityLiving)
        {
            ((EntityLiving)entitylivingbase).setDropChance(entityequipmentslot, 2.0F);
        }

        --stack.stackSize;
        return stack;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:27,代码来源:ItemArmor.java

示例15: getComparatorInputOverride

import net.minecraft.util.EntitySelectors; //导入依赖的package包/类
public int getComparatorInputOverride(IBlockState blockState, World worldIn, BlockPos pos)
{
    if (((Boolean)blockState.getValue(POWERED)).booleanValue())
    {
        List<EntityMinecart> carts = this.findMinecarts(worldIn, pos, EntityMinecart.class);
        if (!carts.isEmpty() && carts.get(0).getComparatorLevel() > -1) return carts.get(0).getComparatorLevel();
        List<EntityMinecartCommandBlock> list = this.<EntityMinecartCommandBlock>findMinecarts(worldIn, pos, EntityMinecartCommandBlock.class, new Predicate[0]);

        if (!list.isEmpty())
        {
            return ((EntityMinecartCommandBlock)list.get(0)).getCommandBlockLogic().getSuccessCount();
        }

        List<EntityMinecart> list1 = this.<EntityMinecart>findMinecarts(worldIn, pos, EntityMinecart.class, new Predicate[] {EntitySelectors.HAS_INVENTORY});

        if (!list1.isEmpty())
        {
            return Container.calcRedstoneFromInventory((IInventory)list1.get(0));
        }
    }

    return 0;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:24,代码来源:BlockRailDetector.java


注:本文中的net.minecraft.util.EntitySelectors类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。