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


Java MathHelper.floor_double方法代码示例

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


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

示例1: setTarget

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public void setTarget(EntityLivingBase p_188686_1_)
{
    this.attackTarget = p_188686_1_;
    int i = this.dragon.initPathPoints();
    int j = this.dragon.getNearestPpIdx(this.attackTarget.posX, this.attackTarget.posY, this.attackTarget.posZ);
    int k = MathHelper.floor_double(this.attackTarget.posX);
    int l = MathHelper.floor_double(this.attackTarget.posZ);
    double d0 = (double)k - this.dragon.posX;
    double d1 = (double)l - this.dragon.posZ;
    double d2 = (double)MathHelper.sqrt_double(d0 * d0 + d1 * d1);
    double d3 = Math.min(0.4000000059604645D + d2 / 80.0D - 1.0D, 10.0D);
    int i1 = MathHelper.floor_double(this.attackTarget.posY + d3);
    PathPoint pathpoint = new PathPoint(k, i1, l);
    this.currentPath = this.dragon.findPath(i, j, pathpoint);

    if (this.currentPath != null)
    {
        this.currentPath.incrementPathIndex();
        this.navigateToNextPathNode();
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:22,代码来源:PhaseStrafePlayer.java

示例2: onUpdate

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
 * Called to update the entity's position/logic.
 */
public void onUpdate()
{
    super.onUpdate();

    if (this.getIsBatHanging())
    {
        this.motionX = 0.0D;
        this.motionY = 0.0D;
        this.motionZ = 0.0D;
        this.posY = (double)MathHelper.floor_double(this.posY) + 1.0D - (double)this.height;
    }
    else
    {
        this.motionY *= 0.6000000238418579D;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:20,代码来源:EntityBat.java

示例3: joinEntityInSurroundings

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
 * spwans an entity and loads surrounding chunks
 */
@SideOnly(Side.CLIENT)
public void joinEntityInSurroundings(Entity entityIn)
{
    int i = MathHelper.floor_double(entityIn.posX / 16.0D);
    int j = MathHelper.floor_double(entityIn.posZ / 16.0D);
    int k = 2;

    for (int l = -2; l <= 2; ++l)
    {
        for (int i1 = -2; i1 <= 2; ++i1)
        {
            this.getChunkFromChunkCoords(i + l, j + i1);
        }
    }

    if (!this.loadedEntityList.contains(entityIn))
    {
        if (!net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityJoinWorldEvent(entityIn, this)))
        this.loadedEntityList.add(entityIn);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:25,代码来源:World.java

示例4: canEasilyReach

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
 * Checks to see if this entity can find a short path to the given target.
 */
private boolean canEasilyReach(EntityLivingBase target)
{
    this.targetSearchDelay = 10 + this.taskOwner.getRNG().nextInt(5);
    Path path = this.taskOwner.getNavigator().getPathToEntityLiving(target);

    if (path == null)
    {
        return false;
    }
    else
    {
        PathPoint pathpoint = path.getFinalPathPoint();

        if (pathpoint == null)
        {
            return false;
        }
        else
        {
            int i = pathpoint.xCoord - MathHelper.floor_double(target.posX);
            int j = pathpoint.zCoord - MathHelper.floor_double(target.posZ);
            return (double)(i * i + j * j) <= 2.25D;
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:29,代码来源:EntityAITarget.java

示例5: onLivingUpdate

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
 * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
 * use this to react to sunlight and start to burn.
 */
public void onLivingUpdate()
{
    super.onLivingUpdate();

    if (this.attackTimer > 0)
    {
        --this.attackTimer;
    }

    if (this.holdRoseTick > 0)
    {
        --this.holdRoseTick;
    }

    if (this.motionX * this.motionX + this.motionZ * this.motionZ > 2.500000277905201E-7D && this.rand.nextInt(5) == 0)
    {
        int i = MathHelper.floor_double(this.posX);
        int j = MathHelper.floor_double(this.posY - 0.20000000298023224D);
        int k = MathHelper.floor_double(this.posZ);
        IBlockState iblockstate = this.worldObj.getBlockState(new BlockPos(i, j, k));

        if (iblockstate.getMaterial() != Material.AIR)
        {
            this.worldObj.spawnParticle(EnumParticleTypes.BLOCK_CRACK, this.posX + ((double)this.rand.nextFloat() - 0.5D) * (double)this.width, this.getEntityBoundingBox().minY + 0.1D, this.posZ + ((double)this.rand.nextFloat() - 0.5D) * (double)this.width, 4.0D * ((double)this.rand.nextFloat() - 0.5D), 0.5D, ((double)this.rand.nextFloat() - 0.5D) * 4.0D, new int[] {Block.getStateId(iblockstate)});
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:32,代码来源:EntityIronGolem.java

示例6: updateMapData

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
@Override
public void updateMapData(World worldIn, Entity viewer, MapData data)
   {
       if (worldIn.provider.getDimensionType().getId() == data.dimension && viewer instanceof EntityPlayer)
       {
           int mapScale = 1 << data.scale;

           int mapCenterX = data.xCenter;
           int mapCenterZ = data.zCenter;

           int mapX = MathHelper.floor_double(viewer.posX - mapCenterX) / mapScale + 64;
           int mapZ = MathHelper.floor_double(viewer.posZ - mapCenterZ) / mapScale + 64;

           int mapY = 128 / mapScale;

           if (worldIn.provider.getHasNoSky())
           {
               mapY /= 2;
           }

           MapData.MapInfo mapdata$mapinfo = data.getMapInfo((EntityPlayer)viewer);

           ++mapdata$mapinfo.step;

           boolean flag = false;

           for (int unknownInt = mapX - mapY + 1; unknownInt < mapX + mapY; ++unknownInt)
           {
           	this.updateMapData_2(worldIn, viewer, data, mapX, mapY, mapZ, unknownInt, mapScale, mapCenterX, mapCenterZ, mapdata$mapinfo, flag);
           }
       }
   }
 
开发者ID:Domochevsky,项目名称:minecraft-territorialdealings,代码行数:33,代码来源:TerritoryMap.java

示例7: getEntitiesWithinAABBForEntity

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
 * Fills the given list of all entities that intersect within the given bounding box that aren't the passed entity.
 */
public void getEntitiesWithinAABBForEntity(@Nullable Entity entityIn, AxisAlignedBB aabb, List<Entity> listToFill, Predicate <? super Entity > p_177414_4_)
{
    int i = MathHelper.floor_double((aabb.minY - World.MAX_ENTITY_RADIUS) / 16.0D);
    int j = MathHelper.floor_double((aabb.maxY + World.MAX_ENTITY_RADIUS) / 16.0D);
    i = MathHelper.clamp_int(i, 0, this.entityLists.length - 1);
    j = MathHelper.clamp_int(j, 0, this.entityLists.length - 1);

    for (int k = i; k <= j; ++k)
    {
        if (!this.entityLists[k].isEmpty())
        {
            for (Entity entity : this.entityLists[k])
            {
                if (entity.getEntityBoundingBox().intersectsWith(aabb) && entity != entityIn)
                {
                    if (p_177414_4_ == null || p_177414_4_.apply(entity))
                    {
                        listToFill.add(entity);
                    }

                    Entity[] aentity = entity.getParts();

                    if (aentity != null)
                    {
                        for (Entity entity1 : aentity)
                        {
                            if (entity1 != entityIn && entity1.getEntityBoundingBox().intersectsWith(aabb) && (p_177414_4_ == null || p_177414_4_.apply(entity1)))
                            {
                                listToFill.add(entity1);
                            }
                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:41,代码来源:Chunk.java

示例8: calculateMapCenter

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public void calculateMapCenter(double x, double z, int mapScale)
{
    int i = 128 * (1 << mapScale);
    int j = MathHelper.floor_double((x + 64.0D) / (double)i);
    int k = MathHelper.floor_double((z + 64.0D) / (double)i);
    this.xCenter = j * i + i / 2 - 64;
    this.zCenter = k * i + i / 2 - 64;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:9,代码来源:MapData.java

示例9: spawnEntityInWorld

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
 * Called when an entity is spawned in the world. This includes players.
 */
public boolean spawnEntityInWorld(Entity entityIn)
{
    // do not drop any items while restoring blocksnapshots. Prevents dupes
    if (!this.isRemote && (entityIn == null || (entityIn instanceof net.minecraft.entity.item.EntityItem && this.restoringBlockSnapshots))) return false;

    int i = MathHelper.floor_double(entityIn.posX / 16.0D);
    int j = MathHelper.floor_double(entityIn.posZ / 16.0D);
    boolean flag = entityIn.forceSpawn;

    if (entityIn instanceof EntityPlayer)
    {
        flag = true;
    }

    if (!flag && !this.isChunkLoaded(i, j, false))
    {
        return false;
    }
    else
    {
        if (entityIn instanceof EntityPlayer)
        {
            EntityPlayer entityplayer = (EntityPlayer)entityIn;
            this.playerEntities.add(entityplayer);
            this.updateAllPlayersSleepingFlag();
        }

        if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.EntityJoinWorldEvent(entityIn, this)) && !flag) return false;

        this.getChunkFromChunkCoords(i, j).addEntity(entityIn);
        this.loadedEntityList.add(entityIn);
        this.onEntityAdded(entityIn);
        return true;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:39,代码来源:World.java

示例10: isEntityInsideOpaqueBlock

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
 * Checks if this entity is inside of an opaque block
 */
public boolean isEntityInsideOpaqueBlock()
{
    if (this.noClip)
    {
        return false;
    }
    else
    {
        BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos = BlockPos.PooledMutableBlockPos.retain();

        for (int i = 0; i < 8; ++i)
        {
            int j = MathHelper.floor_double(this.posY + (double)(((float)((i >> 0) % 2) - 0.5F) * 0.1F) + (double)this.getEyeHeight());
            int k = MathHelper.floor_double(this.posX + (double)(((float)((i >> 1) % 2) - 0.5F) * this.width * 0.8F));
            int l = MathHelper.floor_double(this.posZ + (double)(((float)((i >> 2) % 2) - 0.5F) * this.width * 0.8F));

            if (blockpos$pooledmutableblockpos.getX() != k || blockpos$pooledmutableblockpos.getY() != j || blockpos$pooledmutableblockpos.getZ() != l)
            {
                blockpos$pooledmutableblockpos.setPos(k, j, l);

                if (this.worldObj.getBlockState(blockpos$pooledmutableblockpos).getBlock().isVisuallyOpaque())
                {
                    blockpos$pooledmutableblockpos.release();
                    return true;
                }
            }
        }

        blockpos$pooledmutableblockpos.release();
        return false;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:36,代码来源:Entity.java

示例11: checkBlockCollision

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
 * Returns true if there are any blocks in the region constrained by an AxisAlignedBB
 */
public boolean checkBlockCollision(AxisAlignedBB bb)
{
    int i = MathHelper.floor_double(bb.minX);
    int j = MathHelper.ceiling_double_int(bb.maxX);
    int k = MathHelper.floor_double(bb.minY);
    int l = MathHelper.ceiling_double_int(bb.maxY);
    int i1 = MathHelper.floor_double(bb.minZ);
    int j1 = MathHelper.ceiling_double_int(bb.maxZ);
    BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos = BlockPos.PooledMutableBlockPos.retain();

    for (int k1 = i; k1 < j; ++k1)
    {
        for (int l1 = k; l1 < l; ++l1)
        {
            for (int i2 = i1; i2 < j1; ++i2)
            {
                IBlockState iblockstate = this.getBlockState(blockpos$pooledmutableblockpos.setPos(k1, l1, i2));

                if (iblockstate.getMaterial() != Material.AIR)
                {
                    blockpos$pooledmutableblockpos.release();
                    return true;
                }
            }
        }
    }

    blockpos$pooledmutableblockpos.release();
    return false;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:34,代码来源:World.java

示例12: getCurrentRailPosition

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
private BlockPos getCurrentRailPosition()
{
    int x = MathHelper.floor_double(this.posX);
    int y = MathHelper.floor_double(this.posY);
    int z = MathHelper.floor_double(this.posZ);

    if (BlockRailBase.isRailBlock(this.worldObj, new BlockPos(x, y - 1, z))) y--;
    return new BlockPos(x, y, z);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:10,代码来源:EntityMinecart.java

示例13: getBlastDamageReduction

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public static double getBlastDamageReduction(EntityLivingBase entityLivingBaseIn, double damage)
{
    int i = EnchantmentHelper.getMaxEnchantmentLevel(Enchantments.BLAST_PROTECTION, entityLivingBaseIn);

    if (i > 0)
    {
        damage -= (double)MathHelper.floor_double(damage * (double)((float)i * 0.15F));
    }

    return damage;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:12,代码来源:EnchantmentProtection.java

示例14: floor

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public static int floor(double p_floor_0_)
{
    return MathHelper.floor_double(p_floor_0_);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:5,代码来源:RealmsMth.java

示例15: isDirectPathBetweenPoints

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
 * Checks if the specified entity can safely walk to the specified location.
 */
protected boolean isDirectPathBetweenPoints(Vec3d posVec31, Vec3d posVec32, int sizeX, int sizeY, int sizeZ)
{
    int i = MathHelper.floor_double(posVec31.xCoord);
    int j = MathHelper.floor_double(posVec31.zCoord);
    double d0 = posVec32.xCoord - posVec31.xCoord;
    double d1 = posVec32.zCoord - posVec31.zCoord;
    double d2 = d0 * d0 + d1 * d1;

    if (d2 < 1.0E-8D)
    {
        return false;
    }
    else
    {
        double d3 = 1.0D / Math.sqrt(d2);
        d0 = d0 * d3;
        d1 = d1 * d3;
        sizeX = sizeX + 2;
        sizeZ = sizeZ + 2;

        if (!this.isSafeToStandAt(i, (int)posVec31.yCoord, j, sizeX, sizeY, sizeZ, posVec31, d0, d1))
        {
            return false;
        }
        else
        {
            sizeX = sizeX - 2;
            sizeZ = sizeZ - 2;
            double d4 = 1.0D / Math.abs(d0);
            double d5 = 1.0D / Math.abs(d1);
            double d6 = (double)i - posVec31.xCoord;
            double d7 = (double)j - posVec31.zCoord;

            if (d0 >= 0.0D)
            {
                ++d6;
            }

            if (d1 >= 0.0D)
            {
                ++d7;
            }

            d6 = d6 / d0;
            d7 = d7 / d1;
            int k = d0 < 0.0D ? -1 : 1;
            int l = d1 < 0.0D ? -1 : 1;
            int i1 = MathHelper.floor_double(posVec32.xCoord);
            int j1 = MathHelper.floor_double(posVec32.zCoord);
            int k1 = i1 - i;
            int l1 = j1 - j;

            while (k1 * k > 0 || l1 * l > 0)
            {
                if (d6 < d7)
                {
                    d6 += d4;
                    i += k;
                    k1 = i1 - i;
                }
                else
                {
                    d7 += d5;
                    j += l;
                    l1 = j1 - j;
                }

                if (!this.isSafeToStandAt(i, (int)posVec31.yCoord, j, sizeX, sizeY, sizeZ, posVec31, d0, d1))
                {
                    return false;
                }
            }

            return true;
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:81,代码来源:PathNavigateGround.java


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