當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。