當前位置: 首頁>>代碼示例>>Java>>正文


Java BlockPos.distanceSq方法代碼示例

本文整理匯總了Java中net.minecraft.util.BlockPos.distanceSq方法的典型用法代碼示例。如果您正苦於以下問題:Java BlockPos.distanceSq方法的具體用法?Java BlockPos.distanceSq怎麽用?Java BlockPos.distanceSq使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.util.BlockPos的用法示例。


在下文中一共展示了BlockPos.distanceSq方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: spawnParticle

import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
/**
 * Spawns the desired particle and sends the necessary packets to the relevant connected players.
 */
public void spawnParticle(EnumParticleTypes particleType, boolean longDistance, double xCoord, double yCoord, double zCoord, int numberOfParticles, double xOffset, double yOffset, double zOffset, double particleSpeed, int... p_180505_18_)
{
    Packet packet = new S2APacketParticles(particleType, longDistance, (float)xCoord, (float)yCoord, (float)zCoord, (float)xOffset, (float)yOffset, (float)zOffset, (float)particleSpeed, numberOfParticles, p_180505_18_);

    for (int i = 0; i < this.playerEntities.size(); ++i)
    {
        EntityPlayerMP entityplayermp = (EntityPlayerMP)this.playerEntities.get(i);
        BlockPos blockpos = entityplayermp.getPosition();
        double d0 = blockpos.distanceSq(xCoord, yCoord, zCoord);

        if (d0 <= 256.0D || longDistance && d0 <= 65536.0D)
        {
            entityplayermp.playerNetServerHandler.sendPacket(packet);
        }
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:20,代碼來源:WorldServer.java

示例2: getClosestStrongholdPos

import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
public BlockPos getClosestStrongholdPos(World worldIn, BlockPos pos)
{
    this.worldObj = worldIn;
    this.func_143027_a(worldIn);
    this.rand.setSeed(worldIn.getSeed());
    long i = this.rand.nextLong();
    long j = this.rand.nextLong();
    long k = (long)(pos.getX() >> 4) * i;
    long l = (long)(pos.getZ() >> 4) * j;
    this.rand.setSeed(k ^ l ^ worldIn.getSeed());
    this.recursiveGenerate(worldIn, pos.getX() >> 4, pos.getZ() >> 4, 0, 0, (ChunkPrimer)null);
    double d0 = Double.MAX_VALUE;
    BlockPos blockpos = null;

    for (StructureStart structurestart : this.structureMap.values())
    {
        if (structurestart.isSizeableStructure())
        {
            StructureComponent structurecomponent = (StructureComponent)structurestart.getComponents().get(0);
            BlockPos blockpos1 = structurecomponent.getBoundingBoxCenter();
            double d1 = blockpos1.distanceSq(pos);

            if (d1 < d0)
            {
                d0 = d1;
                blockpos = blockpos1;
            }
        }
    }

    if (blockpos != null)
    {
        return blockpos;
    }
    else
    {
        List<BlockPos> list = this.getCoordList();

        if (list != null)
        {
            BlockPos blockpos2 = null;

            for (BlockPos blockpos3 : list)
            {
                double d2 = blockpos3.distanceSq(pos);

                if (d2 < d0)
                {
                    d0 = d2;
                    blockpos2 = blockpos3;
                }
            }

            return blockpos2;
        }
        else
        {
            return null;
        }
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:62,代碼來源:MapGenStructure.java

示例3: generate

import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
public boolean generate(World worldIn, Random rand, BlockPos position)
{
    while (true)
    {
        label0:
        {
            if (position.getY() > 3)
            {
                if (worldIn.isAirBlock(position.down()))
                {
                    break label0;
                }

                Block block = worldIn.getBlockState(position.down()).getBlock();

                if (block != Blocks.grass && block != Blocks.dirt && block != Blocks.stone)
                {
                    break label0;
                }
            }

            if (position.getY() <= 3)
            {
                return false;
            }

            int i1 = this.field_150544_b;

            for (int i = 0; i1 >= 0 && i < 3; ++i)
            {
                int j = i1 + rand.nextInt(2);
                int k = i1 + rand.nextInt(2);
                int l = i1 + rand.nextInt(2);
                float f = (float)(j + k + l) * 0.333F + 0.5F;

                for (BlockPos blockpos : BlockPos.getAllInBox(position.add(-j, -k, -l), position.add(j, k, l)))
                {
                    if (blockpos.distanceSq(position) <= (double)(f * f))
                    {
                        worldIn.setBlockState(blockpos, this.field_150545_a.getDefaultState(), 4);
                    }
                }

                position = position.add(-(i1 + 1) + rand.nextInt(2 + i1 * 2), 0 - rand.nextInt(2), -(i1 + 1) + rand.nextInt(2 + i1 * 2));
            }

            return true;
        }
        position = position.down();
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:52,代碼來源:WorldGenBlockBlob.java

示例4: getDistanceSq

import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
public double getDistanceSq(BlockPos pos)
{
    return pos.distanceSq(this.posX, this.posY, this.posZ);
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:5,代碼來源:Entity.java

示例5: getDistanceToDoorBlockSq

import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
public int getDistanceToDoorBlockSq(BlockPos p_179848_1_)
{
    return (int)p_179848_1_.distanceSq(this.getDoorBlockPos());
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:5,代碼來源:VillageDoorInfo.java


注:本文中的net.minecraft.util.BlockPos.distanceSq方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。