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


Java MathHelper.floor方法代码示例

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


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

示例1: damageShield

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
protected void damageShield(float damage)
{
    if (damage >= 3.0F && this.activeItemStack.getItem() == Items.SHIELD)
    {
        int i = 1 + MathHelper.floor(damage);
        this.activeItemStack.damageItem(i, this);

        if (this.activeItemStack.func_190926_b())
        {
            EnumHand enumhand = this.getActiveHand();

            if (enumhand == EnumHand.MAIN_HAND)
            {
                this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, ItemStack.field_190927_a);
            }
            else
            {
                this.setItemStackToSlot(EntityEquipmentSlot.OFFHAND, ItemStack.field_190927_a);
            }

            this.activeItemStack = ItemStack.field_190927_a;
            this.playSound(SoundEvents.ITEM_SHIELD_BREAK, 0.8F, 0.8F + this.world.rand.nextFloat() * 0.4F);
        }
    }
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:26,代码来源:EntityPlayer.java

示例2: joinEntityInSurroundings

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
 * spwans an entity and loads surrounding chunks
 */
public void joinEntityInSurroundings(Entity entityIn)
{
    int i = MathHelper.floor(entityIn.posX / 16.0D);
    int j = MathHelper.floor(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))
    {
        this.loadedEntityList.add(entityIn);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:23,代码来源:World.java

示例3: updateChunkPositions

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public void updateChunkPositions(double viewEntityX, double viewEntityZ)
{
    int i = MathHelper.floor(viewEntityX) - 8;
    int j = MathHelper.floor(viewEntityZ) - 8;
    int k = this.countChunksX * 16;

    for (int l = 0; l < this.countChunksX; ++l)
    {
        int i1 = this.getBaseCoordinate(i, k, l);

        for (int j1 = 0; j1 < this.countChunksZ; ++j1)
        {
            int k1 = this.getBaseCoordinate(j, k, j1);

            for (int l1 = 0; l1 < this.countChunksY; ++l1)
            {
                int i2 = l1 * 16;
                RenderChunk renderchunk = this.renderChunks[(j1 * this.countChunksY + l1) * this.countChunksX + l];
                renderchunk.setPosition(i1, i2, k1);
            }
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:24,代码来源:ViewFrustum.java

示例4: 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(this.attackTarget.posX);
    int l = MathHelper.floor(this.attackTarget.posZ);
    double d0 = (double)k - this.dragon.posX;
    double d1 = (double)l - this.dragon.posZ;
    double d2 = (double)MathHelper.sqrt(d0 * d0 + d1 * d1);
    double d3 = Math.min(0.4000000059604645D + d2 / 80.0D - 1.0D, 10.0D);
    int i1 = MathHelper.floor(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:sudofox,项目名称:Backmemed,代码行数:22,代码来源:PhaseStrafePlayer.java

示例5: EntityPlayerMP

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public EntityPlayerMP(MinecraftServer server, WorldServer worldIn, GameProfile profile, PlayerInteractionManager interactionManagerIn)
{
    super(worldIn, profile);
    interactionManagerIn.thisPlayerMP = this;
    this.interactionManager = interactionManagerIn;
    BlockPos blockpos = worldIn.getSpawnPoint();

    if (worldIn.provider.func_191066_m() && worldIn.getWorldInfo().getGameType() != GameType.ADVENTURE)
    {
        int i = Math.max(0, server.getSpawnRadius(worldIn));
        int j = MathHelper.floor(worldIn.getWorldBorder().getClosestDistance((double)blockpos.getX(), (double)blockpos.getZ()));

        if (j < i)
        {
            i = j;
        }

        if (j <= 1)
        {
            i = 1;
        }

        blockpos = worldIn.getTopSolidOrLiquidBlock(blockpos.add(this.rand.nextInt(i * 2 + 1) - i, 0, this.rand.nextInt(i * 2 + 1) - i));
    }

    this.mcServer = server;
    this.statsFile = server.getPlayerList().getPlayerStatsFile(this);
    this.stepHeight = 0.0F;
    this.moveToBlockPosAndAngles(blockpos, 0.0F, 0.0F);

    while (!worldIn.getCollisionBoxes(this, this.getEntityBoundingBox()).isEmpty() && this.posY < 255.0D)
    {
        this.setPosition(this.posX, this.posY + 1.0D, this.posZ);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:36,代码来源:EntityPlayerMP.java

示例6: 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(bb.minX);
    int j = MathHelper.ceil(bb.maxX);
    int k = MathHelper.floor(bb.minY);
    int l = MathHelper.ceil(bb.maxY);
    int i1 = MathHelper.floor(bb.minZ);
    int j1 = MathHelper.ceil(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:sudofox,项目名称:Backmemed,代码行数:34,代码来源:World.java

示例7: generateLoot

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
 * generates loot and puts it in an inventory
 */
public void generateLoot(Collection<ItemStack> stacks, Random rand, LootContext context)
{
    if (LootConditionManager.testAllConditions(this.poolConditions, rand, context))
    {
        int i = this.rolls.generateInt(rand) + MathHelper.floor(this.bonusRolls.generateFloat(rand) * context.getLuck());

        for (int j = 0; j < i; ++j)
        {
            this.createLootRoll(stacks, rand, context);
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:16,代码来源:LootPool.java

示例8: func_190876_a

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
private void func_190876_a(double p_190876_1_, double p_190876_3_, double p_190876_5_, double p_190876_7_, float p_190876_9_, int p_190876_10_)
{
    BlockPos blockpos = new BlockPos(p_190876_1_, p_190876_7_, p_190876_3_);
    boolean flag = false;
    double d0 = 0.0D;

    while (true)
    {
        if (!EntityEvoker.this.world.isBlockNormalCube(blockpos, true) && EntityEvoker.this.world.isBlockNormalCube(blockpos.down(), true))
        {
            if (!EntityEvoker.this.world.isAirBlock(blockpos))
            {
                IBlockState iblockstate = EntityEvoker.this.world.getBlockState(blockpos);
                AxisAlignedBB axisalignedbb = iblockstate.getCollisionBoundingBox(EntityEvoker.this.world, blockpos);

                if (axisalignedbb != null)
                {
                    d0 = axisalignedbb.maxY;
                }
            }

            flag = true;
            break;
        }

        blockpos = blockpos.down();

        if (blockpos.getY() < MathHelper.floor(p_190876_5_) - 1)
        {
            break;
        }
    }

    if (flag)
    {
        EntityEvokerFangs entityevokerfangs = new EntityEvokerFangs(EntityEvoker.this.world, p_190876_1_, (double)blockpos.getY() + d0, p_190876_3_, p_190876_9_, p_190876_10_, EntityEvoker.this);
        EntityEvoker.this.world.spawnEntityInWorld(entityevokerfangs);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:40,代码来源:EntityEvoker.java

示例9: getBrightness

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
@Override
public float getBrightness() {
	BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(MathHelper.floor(posX), 0, MathHelper.floor(posZ));

	if (world != null && world.isBlockLoaded(blockpos$mutableblockpos)) {
		blockpos$mutableblockpos.setY(MathHelper.floor(posY + getEyeHeight()));
		return world.getLightBrightness(blockpos$mutableblockpos);
	}
	else {
		return 1.0F;
	}
}
 
开发者ID:p455w0rd,项目名称:EndermanEvolution,代码行数:13,代码来源:EntityFrienderman.java

示例10: getBrightnessForRender

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
@SideOnly(Side.CLIENT)
@Override
public int getBrightnessForRender() {
	BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(MathHelper.floor(posX), 0, MathHelper.floor(posZ));

	if (world != null && world.isBlockLoaded(blockpos$mutableblockpos)) {
		blockpos$mutableblockpos.setY(MathHelper.floor(posY + getEyeHeight()));
		return world.getCombinedLight(blockpos$mutableblockpos, 0);
	}
	else {
		return 15;
	}
}
 
开发者ID:p455w0rd,项目名称:EndermanEvolution,代码行数:14,代码来源:EntityEvolvedEnderman.java

示例11: getBrightnessForRender

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public int getBrightnessForRender(float partialTicks)
{
    BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(MathHelper.floor(this.posX), 0, MathHelper.floor(this.posZ));

    if (this.world.isBlockLoaded(blockpos$mutableblockpos))
    {
        blockpos$mutableblockpos.setY(MathHelper.floor(this.posY + (double)this.getEyeHeight()));
        return this.world.getCombinedLight(blockpos$mutableblockpos, 0);
    }
    else
    {
        return 0;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:15,代码来源:Entity.java

示例12: getWaterLevelAbove

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public float getWaterLevelAbove()
{
    AxisAlignedBB axisalignedbb = this.getEntityBoundingBox();
    int i = MathHelper.floor(axisalignedbb.minX);
    int j = MathHelper.ceil(axisalignedbb.maxX);
    int k = MathHelper.floor(axisalignedbb.maxY);
    int l = MathHelper.ceil(axisalignedbb.maxY - this.lastYd);
    int i1 = MathHelper.floor(axisalignedbb.minZ);
    int j1 = MathHelper.ceil(axisalignedbb.maxZ);
    BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos = BlockPos.PooledMutableBlockPos.retain();

    try
    {
        label78:

        for (int k1 = k; k1 < l; ++k1)
        {
            float f = 0.0F;
            int l1 = i;

            while (true)
            {
                if (l1 >= j)
                {
                    if (f < 1.0F)
                    {
                        float f2 = (float)blockpos$pooledmutableblockpos.getY() + f;
                        return f2;
                    }

                    break;
                }

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

                    if (iblockstate.getMaterial() == Material.WATER)
                    {
                        f = Math.max(f, BlockLiquid.func_190973_f(iblockstate, this.world, blockpos$pooledmutableblockpos));
                    }

                    if (f >= 1.0F)
                    {
                        continue label78;
                    }
                }

                ++l1;
            }
        }

        float f1 = (float)(l + 1);
        return f1;
    }
    finally
    {
        blockpos$pooledmutableblockpos.release();
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:62,代码来源:EntityBoat.java

示例13: getStart

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public PathPoint getStart()
{
    int i;

    if (this.getCanSwim() && this.entity.isInWater())
    {
        i = (int)this.entity.getEntityBoundingBox().minY;
        BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(MathHelper.floor(this.entity.posX), i, MathHelper.floor(this.entity.posZ));

        for (Block block = this.blockaccess.getBlockState(blockpos$mutableblockpos).getBlock(); block == Blocks.FLOWING_WATER || block == Blocks.WATER; block = this.blockaccess.getBlockState(blockpos$mutableblockpos).getBlock())
        {
            ++i;
            blockpos$mutableblockpos.setPos(MathHelper.floor(this.entity.posX), i, MathHelper.floor(this.entity.posZ));
        }
    }
    else if (this.entity.onGround)
    {
        i = MathHelper.floor(this.entity.getEntityBoundingBox().minY + 0.5D);
    }
    else
    {
        BlockPos blockpos;

        for (blockpos = new BlockPos(this.entity); (this.blockaccess.getBlockState(blockpos).getMaterial() == Material.AIR || this.blockaccess.getBlockState(blockpos).getBlock().isPassable(this.blockaccess, blockpos)) && blockpos.getY() > 0; blockpos = blockpos.down())
        {
            ;
        }

        i = blockpos.up().getY();
    }

    BlockPos blockpos2 = new BlockPos(this.entity);
    PathNodeType pathnodetype1 = this.getPathNodeType(this.entity, blockpos2.getX(), i, blockpos2.getZ());

    if (this.entity.getPathPriority(pathnodetype1) < 0.0F)
    {
        Set<BlockPos> set = Sets.<BlockPos>newHashSet();
        set.add(new BlockPos(this.entity.getEntityBoundingBox().minX, (double)i, this.entity.getEntityBoundingBox().minZ));
        set.add(new BlockPos(this.entity.getEntityBoundingBox().minX, (double)i, this.entity.getEntityBoundingBox().maxZ));
        set.add(new BlockPos(this.entity.getEntityBoundingBox().maxX, (double)i, this.entity.getEntityBoundingBox().minZ));
        set.add(new BlockPos(this.entity.getEntityBoundingBox().maxX, (double)i, this.entity.getEntityBoundingBox().maxZ));

        for (BlockPos blockpos1 : set)
        {
            PathNodeType pathnodetype = this.getPathNodeType(this.entity, blockpos1);

            if (this.entity.getPathPriority(pathnodetype) >= 0.0F)
            {
                return this.openPoint(blockpos1.getX(), blockpos1.getY(), blockpos1.getZ());
            }
        }
    }

    return this.openPoint(blockpos2.getX(), i, blockpos2.getZ());
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:56,代码来源:WalkNodeProcessor.java

示例14: getUnderwaterStatus

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
@Nullable

    /**
     * Decides whether the boat is currently underwater.
     */
    private EntityBoat.Status getUnderwaterStatus()
    {
        AxisAlignedBB axisalignedbb = this.getEntityBoundingBox();
        double d0 = axisalignedbb.maxY + 0.001D;
        int i = MathHelper.floor(axisalignedbb.minX);
        int j = MathHelper.ceil(axisalignedbb.maxX);
        int k = MathHelper.floor(axisalignedbb.maxY);
        int l = MathHelper.ceil(d0);
        int i1 = MathHelper.floor(axisalignedbb.minZ);
        int j1 = MathHelper.ceil(axisalignedbb.maxZ);
        boolean flag = false;
        BlockPos.PooledMutableBlockPos blockpos$pooledmutableblockpos = BlockPos.PooledMutableBlockPos.retain();

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

                        if (iblockstate.getMaterial() == Material.WATER && d0 < (double)BlockLiquid.func_190972_g(iblockstate, this.world, blockpos$pooledmutableblockpos))
                        {
                            if (((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue() != 0)
                            {
                                EntityBoat.Status entityboat$status = EntityBoat.Status.UNDER_FLOWING_WATER;
                                return entityboat$status;
                            }

                            flag = true;
                        }
                    }
                }
            }
        }
        finally
        {
            blockpos$pooledmutableblockpos.release();
        }

        return flag ? EntityBoat.Status.UNDER_WATER : null;
    }
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:51,代码来源:EntityBoat.java

示例15: renderShadow

import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
 * Renders the entities shadow.
 */
private void renderShadow(Entity entityIn, double x, double y, double z, float shadowAlpha, float partialTicks)
{
    if (!Config.isShaders() || !Shaders.shouldSkipDefaultShadow)
    {
        GlStateManager.enableBlend();
        GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
        this.renderManager.renderEngine.bindTexture(SHADOW_TEXTURES);
        World world = this.getWorldFromRenderManager();
        GlStateManager.depthMask(false);
        float f = this.shadowSize;

        if (entityIn instanceof EntityLiving)
        {
            EntityLiving entityliving = (EntityLiving)entityIn;
            f *= entityliving.getRenderSizeModifier();

            if (entityliving.isChild())
            {
                f *= 0.5F;
            }
        }

        double d5 = entityIn.lastTickPosX + (entityIn.posX - entityIn.lastTickPosX) * (double)partialTicks;
        double d0 = entityIn.lastTickPosY + (entityIn.posY - entityIn.lastTickPosY) * (double)partialTicks;
        double d1 = entityIn.lastTickPosZ + (entityIn.posZ - entityIn.lastTickPosZ) * (double)partialTicks;
        int i = MathHelper.floor(d5 - (double)f);
        int j = MathHelper.floor(d5 + (double)f);
        int k = MathHelper.floor(d0 - (double)f);
        int l = MathHelper.floor(d0);
        int i1 = MathHelper.floor(d1 - (double)f);
        int j1 = MathHelper.floor(d1 + (double)f);
        double d2 = x - d5;
        double d3 = y - d0;
        double d4 = z - d1;
        Tessellator tessellator = Tessellator.getInstance();
        VertexBuffer vertexbuffer = tessellator.getBuffer();
        vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);

        for (BlockPos blockpos : BlockPos.getAllInBoxMutable(new BlockPos(i, k, i1), new BlockPos(j, l, j1)))
        {
            IBlockState iblockstate = world.getBlockState(blockpos.down());

            if (iblockstate.getRenderType() != EnumBlockRenderType.INVISIBLE && world.getLightFromNeighbors(blockpos) > 3)
            {
                this.renderShadowSingle(iblockstate, x, y, z, blockpos, shadowAlpha, f, d2, d3, d4);
            }
        }

        tessellator.draw();
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        GlStateManager.disableBlend();
        GlStateManager.depthMask(true);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:58,代码来源:Render.java


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