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


Java Entity.getDistanceSq方法代码示例

本文整理汇总了Java中net.minecraft.entity.Entity.getDistanceSq方法的典型用法代码示例。如果您正苦于以下问题:Java Entity.getDistanceSq方法的具体用法?Java Entity.getDistanceSq怎么用?Java Entity.getDistanceSq使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.entity.Entity的用法示例。


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

示例1: getClosestHorse

import net.minecraft.entity.Entity; //导入方法依赖的package包/类
protected EntityHorse getClosestHorse(Entity entityIn, double distance)
{
    double d0 = Double.MAX_VALUE;
    Entity entity = null;

    for (Entity entity1 : this.worldObj.getEntitiesInAABBexcluding(entityIn, entityIn.getEntityBoundingBox().addCoord(distance, distance, distance), horseBreedingSelector))
    {
        double d1 = entity1.getDistanceSq(entityIn.posX, entityIn.posY, entityIn.posZ);

        if (d1 < d0)
        {
            entity = entity1;
            d0 = d1;
        }
    }

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

示例2: getClosestHorse

import net.minecraft.entity.Entity; //导入方法依赖的package包/类
@Nullable
protected AbstractHorse getClosestHorse(Entity entityIn, double distance)
{
    double d0 = Double.MAX_VALUE;
    Entity entity = null;

    for (Entity entity1 : this.world.getEntitiesInAABBexcluding(entityIn, entityIn.getEntityBoundingBox().addCoord(distance, distance, distance), IS_HORSE_BREEDING))
    {
        double d1 = entity1.getDistanceSq(entityIn.posX, entityIn.posY, entityIn.posZ);

        if (d1 < d0)
        {
            entity = entity1;
            d0 = d1;
        }
    }

    return (AbstractHorse)entity;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:20,代码来源:AbstractHorse.java

示例3: getClosestHorse

import net.minecraft.entity.Entity; //导入方法依赖的package包/类
protected EntityHorse getClosestHorse(Entity entityIn, double distance)
{
    double d0 = Double.MAX_VALUE;
    Entity entity = null;

    for (Entity entity1 : this.worldObj.getEntitiesInAABBexcluding(entityIn, entityIn.getEntityBoundingBox().addCoord(distance, distance, distance), IS_HORSE_BREEDING))
    {
        double d1 = entity1.getDistanceSq(entityIn.posX, entityIn.posY, entityIn.posZ);

        if (d1 < d0)
        {
            entity = entity1;
            d0 = d1;
        }
    }

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

示例4: pushEntities

import net.minecraft.entity.Entity; //导入方法依赖的package包/类
private void pushEntities(World world, BlockPos pos, Vec3d tileVec) {
    AxisAlignedBB bbBox = new AxisAlignedBB(pos.add(-grateRange, -grateRange, -grateRange), pos.add(grateRange + 1, grateRange + 1, grateRange + 1));
    List<Entity> entities = world.getEntitiesWithinAABB(Entity.class, bbBox, new StringFilterEntitySelector().setFilter(entityFilter));
    double d0 = grateRange + 0.5D;
    for (Entity entity : entities) {
        if (!entity.world.isRemote && entity.getDistanceSq(pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D) < 0.6D && entity instanceof EntityItem && !entity.isDead) {
            ItemStack leftover = ((EntityItem) entity).getItem();
            for (EnumFacing dir : EnumFacing.VALUES) {
                TileEntity inv = pressureTube.world().getTileEntity(pos.offset(dir));
                leftover = IOHelper.insert(inv, leftover, dir.getOpposite(), false);
                if (leftover.isEmpty()) break;
            }
            if (leftover.isEmpty()) {
                entity.setDead();
            } else {
                ((EntityItem) entity).setItem(leftover);
            }
        } else {
            if (!(entity instanceof EntityPlayer) || !((EntityPlayer) entity).capabilities.isCreativeMode) {
                Vec3d entityVec = new Vec3d(entity.posX, entity.posY, entity.posZ);
                RayTraceResult trace = world.rayTraceBlocks(entityVec, tileVec);
                if (trace != null && trace.getBlockPos().equals(pos)) {
                    double d1 = (entity.posX - pos.getX() - 0.5D) / d0;
                    double d2 = (entity.posY - pos.getY() - 0.5D) / d0;
                    double d3 = (entity.posZ - pos.getZ() - 0.5D) / d0;
                    double d4 = Math.sqrt(d1 * d1 + d2 * d2 + d3 * d3);
                    double d5 = 1.0D - d4;

                    if (d5 > 0.0D) {
                        d5 *= d5;
                        if (!vacuum) d5 *= -1;
                        entity.motionX -= d1 / d4 * d5 * 0.1D;
                        entity.motionY -= d2 / d4 * d5 * 0.1D;
                        entity.motionZ -= d3 / d4 * d5 * 0.1D;
                    }
                }
            }
        }
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:41,代码来源:ModuleAirGrate.java

示例5: updateTask

import net.minecraft.entity.Entity; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void updateTask() {
    // System.out.println("executing
    // "+TF2ActionHandler.playerAction.server.get(host));
    boolean easier = host.world.getDifficulty() == EnumDifficulty.NORMAL;
    delay--;
    if (delay > 0 || this.host.getRNG().nextFloat() > (easier ? 0.22f : 0.28f)) {
        host.getCapability(TF2weapons.WEAPONS_CAP, null).state &= 5;// System.out.println("reset:");
        return;
    }
    Vec3d eyeVec = new Vec3d(host.posX, host.posY + host.getEyeHeight(), host.posZ);
    List<Entity> list = host.world.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(eyeVec.x - 5,
            eyeVec.y - 5, eyeVec.z - 5, eyeVec.x + 5, eyeVec.y + 5, eyeVec.z + 5));
    boolean airblast = false;
    for (Entity entity : list)
        // System.out.println(entity+"
        // "+ItemFlameThrower.isPushable(host,entity));
        if (ItemFlameThrower.isPushable(host, entity)
                && (entity instanceof EntityThrowable || entity instanceof IProjectile)) {
            // System.out.println(entity);
            // System.out.println("dystans:
            // "+(entity.getDistanceSq(host.posX, host.posY +
            // (double)host.getEyeHeight(), host.posZ)<25));
            // System.out.println(TF2weapons.getTeam(entity)+"
            // "+TF2weapons.getTeam(host));
            airblast = entity.getDistanceSq(host.posX, host.posY + host.getEyeHeight(),
                    host.posZ) < (easier ? 16 : 25)
                    && TF2Util.lookingAt(host, (easier ? 40 : 60), entity.posX, entity.posY + entity.height / 2,
                            entity.posZ);
            if (airblast)
                break;
        }

    if (airblast) {
        // System.out.println("airblast:");
        ((ItemFlameThrower) this.host.getHeldItemMainhand().getItem()).altUse(this.host.getHeldItemMainhand(), host,
                this.host.world);
        this.delay = easier ? 30 : 18;
    } else
        host.getCapability(TF2weapons.WEAPONS_CAP, null).state &= 5;
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:43,代码来源:EntityAIAirblast.java


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