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


Java MathHelper类代码示例

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


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

示例1: rayTrace

import net.minecraft.util.math.MathHelper; //导入依赖的package包/类
protected RayTraceResult rayTrace(World worldIn, EntityPlayer playerIn, boolean useLiquids)
{
    float f = playerIn.rotationPitch;
    float f1 = playerIn.rotationYaw;
    double d0 = playerIn.posX;
    double d1 = playerIn.posY + (double)playerIn.getEyeHeight();
    double d2 = playerIn.posZ;
    Vec3d vec3d = new Vec3d(d0, d1, d2);
    float f2 = MathHelper.cos(-f1 * 0.017453292F - (float)Math.PI);
    float f3 = MathHelper.sin(-f1 * 0.017453292F - (float)Math.PI);
    float f4 = -MathHelper.cos(-f * 0.017453292F);
    float f5 = MathHelper.sin(-f * 0.017453292F);
    float f6 = f3 * f4;
    float f7 = f2 * f4;
    double d3 = 5.0D;
    if (playerIn instanceof net.minecraft.entity.player.EntityPlayerMP)
    {
        d3 = ((net.minecraft.entity.player.EntityPlayerMP)playerIn).interactionManager.getBlockReachDistance();
    }
    Vec3d vec3d1 = vec3d.addVector((double)f6 * d3, (double)f5 * d3, (double)f7 * d3);
    return worldIn.rayTraceBlocks(vec3d, vec3d1, useLiquids, !useLiquids, false);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:23,代码来源:Item.java

示例2: updateRotation

import net.minecraft.util.math.MathHelper; //导入依赖的package包/类
/**
 * Arguments: current rotation, intended rotation, max increment.
 */
private float updateRotation(float angle, float targetAngle, float maxIncrease)
{
    float f = MathHelper.wrapDegrees(targetAngle - angle);

    if (f > maxIncrease)
    {
        f = maxIncrease;
    }

    if (f < -maxIncrease)
    {
        f = -maxIncrease;
    }

    return angle + f;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:20,代码来源:EntityLiving.java

示例3: renderPathLine

import net.minecraft.util.math.MathHelper; //导入依赖的package包/类
public void renderPathLine(float p_190067_1_, Path p_190067_2_)
{
    Tessellator tessellator = Tessellator.getInstance();
    VertexBuffer vertexbuffer = tessellator.getBuffer();
    vertexbuffer.begin(3, DefaultVertexFormats.POSITION_COLOR);

    for (int i = 0; i < p_190067_2_.getCurrentPathLength(); ++i)
    {
        PathPoint pathpoint = p_190067_2_.getPathPointFromIndex(i);

        if (this.addDistanceToPlayer(pathpoint) <= 40.0F)
        {
            float f = (float)i / (float)p_190067_2_.getCurrentPathLength() * 0.33F;
            int j = i == 0 ? 0 : MathHelper.hsvToRGB(f, 0.9F, 0.9F);
            int k = j >> 16 & 255;
            int l = j >> 8 & 255;
            int i1 = j & 255;
            vertexbuffer.pos((double)pathpoint.xCoord - this.xo + 0.5D, (double)pathpoint.yCoord - this.yo + 0.5D, (double)pathpoint.zCoord - this.zo + 0.5D).color(k, l, i1, 255).endVertex();
        }
    }

    tessellator.draw();
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:24,代码来源:DebugRendererPathfinding.java

示例4: rayTraceFromEntity

import net.minecraft.util.math.MathHelper; //导入依赖的package包/类
private RayTraceResult rayTraceFromEntity(World world, Entity player, boolean par3, double range) {
	
	float f = 1.0F;
	float f1 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * f;
	float f2 = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f;
	double d0 = player.prevPosX + (player.posX - player.prevPosX) * f;
	double d1 = player.prevPosY + (player.posY - player.prevPosY) * f;
	if (player instanceof EntityPlayer)
		d1 += ((EntityPlayer)player).eyeHeight;
	double d2 = player.prevPosZ + (player.posZ - player.prevPosZ) * f;
	Vec3d vec3 = new Vec3d(d0, d1, d2);
	float f3 = MathHelper.cos(-f2 * 0.017453292F - (float)Math.PI);
	float f4 = MathHelper.sin(-f2 * 0.017453292F - (float)Math.PI);
	float f5 = -MathHelper.cos(-f1 * 0.017453292F);
	float f6 = MathHelper.sin(-f1 * 0.017453292F);
	float f7 = f4 * f5;
	float f8 = f3 * f5;
	double d3 = range;
	Vec3d vec31 = vec3.addVector(f7 * d3, f6 * d3, f8 * d3);
	return world.rayTraceBlocks(vec3, vec31, par3);
}
 
开发者ID:bafomdad,项目名称:uniquecrops,代码行数:22,代码来源:TileShyPlant.java

示例5: MapGenVillage

import net.minecraft.util.math.MathHelper; //导入依赖的package包/类
public MapGenVillage(Map<String, String> map)
{
    this();

    for (Entry<String, String> entry : map.entrySet())
    {
        if (((String)entry.getKey()).equals("size"))
        {
            this.size = MathHelper.getInt((String)entry.getValue(), this.size, 0);
        }
        else if (((String)entry.getKey()).equals("distance"))
        {
            this.distance = MathHelper.getInt((String)entry.getValue(), this.distance, 9);
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:17,代码来源:MapGenVillage.java

示例6: setRotationAngles

import net.minecraft.util.math.MathHelper; //导入依赖的package包/类
/**
 * Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms
 * and legs, where par1 represents the time(so that arms and legs swing back and forth) and par2 represents how
 * "far" arms and legs can swing at most.
 */
public void setRotationAngles(float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scaleFactor, Entity entityIn)
{
    super.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scaleFactor, entityIn);
    this.head.rotateAngleY = netHeadYaw * 0.017453292F;
    this.head.rotateAngleX = headPitch * 0.017453292F;
    this.body.rotateAngleY = netHeadYaw * 0.017453292F * 0.25F;
    float f = MathHelper.sin(this.body.rotateAngleY);
    float f1 = MathHelper.cos(this.body.rotateAngleY);
    this.rightHand.rotateAngleZ = 1.0F;
    this.leftHand.rotateAngleZ = -1.0F;
    this.rightHand.rotateAngleY = 0.0F + this.body.rotateAngleY;
    this.leftHand.rotateAngleY = (float)Math.PI + this.body.rotateAngleY;
    this.rightHand.rotationPointX = f1 * 5.0F;
    this.rightHand.rotationPointZ = -f * 5.0F;
    this.leftHand.rotationPointX = -f1 * 5.0F;
    this.leftHand.rotationPointZ = f * 5.0F;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:23,代码来源:ModelSnowMan.java

示例7: rotateCorpse

import net.minecraft.util.math.MathHelper; //导入依赖的package包/类
protected void rotateCorpse(EntityDragon entityLiving, float p_77043_2_, float p_77043_3_, float partialTicks)
{
    float f = (float)entityLiving.getMovementOffsets(7, partialTicks)[0];
    float f1 = (float)(entityLiving.getMovementOffsets(5, partialTicks)[1] - entityLiving.getMovementOffsets(10, partialTicks)[1]);
    GlStateManager.rotate(-f, 0.0F, 1.0F, 0.0F);
    GlStateManager.rotate(f1 * 10.0F, 1.0F, 0.0F, 0.0F);
    GlStateManager.translate(0.0F, 0.0F, 1.0F);

    if (entityLiving.deathTime > 0)
    {
        float f2 = ((float)entityLiving.deathTime + partialTicks - 1.0F) / 20.0F * 1.6F;
        f2 = MathHelper.sqrt_float(f2);

        if (f2 > 1.0F)
        {
            f2 = 1.0F;
        }

        GlStateManager.rotate(f2 * this.getDeathMaxRotation(entityLiving), 0.0F, 0.0F, 1.0F);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:22,代码来源:RenderDragon.java

示例8: setThrowableHeading

import net.minecraft.util.math.MathHelper; //导入依赖的package包/类
/**
 * Similar to setArrowHeading, it's point the throwable entity to a x, y, z direction.
 */
public void setThrowableHeading(double x, double y, double z, float velocity, float inaccuracy)
{
    float f = MathHelper.sqrt_double(x * x + y * y + z * z);
    x = x / (double)f;
    y = y / (double)f;
    z = z / (double)f;
    x = x + this.rand.nextGaussian() * 0.007499999832361937D * (double)inaccuracy;
    y = y + this.rand.nextGaussian() * 0.007499999832361937D * (double)inaccuracy;
    z = z + this.rand.nextGaussian() * 0.007499999832361937D * (double)inaccuracy;
    x = x * (double)velocity;
    y = y * (double)velocity;
    z = z * (double)velocity;
    this.motionX = x;
    this.motionY = y;
    this.motionZ = z;
    float f1 = MathHelper.sqrt_double(x * x + z * z);
    this.rotationYaw = (float)(MathHelper.atan2(x, z) * (180D / Math.PI));
    this.rotationPitch = (float)(MathHelper.atan2(y, (double)f1) * (180D / Math.PI));
    this.prevRotationYaw = this.rotationYaw;
    this.prevRotationPitch = this.rotationPitch;
    this.ticksInGround = 0;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:26,代码来源:EntityArrow.java

示例9: generateLeaves

import net.minecraft.util.math.MathHelper; //导入依赖的package包/类
private void generateLeaves(World world, Random rand, Vec3d pos) {
    int leavesRadius = MathHelper.ceil(variant.leavesRadius);
    double expConst = variant.distanceExpConstant;

    for (int dx = -leavesRadius; dx <= leavesRadius; dx++) {
        for (int dy = -leavesRadius; dy <= leavesRadius; dy++) {
            for (int dz = -leavesRadius; dz <= leavesRadius; dz++) {
                // lower value of p makes it closer to diamond shape, higher value makes it closer to cube, value p=2 is perfect sphere.
                if (Math.pow(Math.abs(dx), expConst) + Math.pow(Math.abs(dy), expConst) + Math.pow(Math.abs(dz), expConst)
                        - rand.nextFloat() * variant.leavesShapeRandomization * Math.pow(leavesRadius, expConst) <= Math
                        .pow(leavesRadius, expConst)) {
                    setBlockInWorld(world, new BlockPos(pos.addVector(dx, dy, dz)), LEAF);
                }
            }
        }
    }
}
 
开发者ID:Boethie,项目名称:Genesis,代码行数:18,代码来源:WorldGenTreeDryophyllum.java

示例10: setAngles

import net.minecraft.util.math.MathHelper; //导入依赖的package包/类
/**
 * Adds 15% to the entity's yaw and subtracts 15% from the pitch. Clamps pitch from -90 to 90. Both arguments in
 * degrees.
 */
public void setAngles(float yaw, float pitch)
{
    float f = this.rotationPitch;
    float f1 = this.rotationYaw;
    this.rotationYaw = (float)((double)this.rotationYaw + (double)yaw * 0.15D);
    this.rotationPitch = (float)((double)this.rotationPitch - (double)pitch * 0.15D);
    this.rotationPitch = MathHelper.clamp(this.rotationPitch, -90.0F, 90.0F);
    this.prevRotationPitch += this.rotationPitch - f;
    this.prevRotationYaw += this.rotationYaw - f1;

    if (this.ridingEntity != null)
    {
        this.ridingEntity.applyOrientationToEntity(this);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:20,代码来源:Entity.java

示例11: updateFallState

import net.minecraft.util.math.MathHelper; //导入依赖的package包/类
protected void updateFallState(double y, boolean onGroundIn, IBlockState state, BlockPos pos)
{
    if (!this.isInWater())
    {
        this.handleWaterMovement();
    }

    if (!this.world.isRemote && this.fallDistance > 3.0F && onGroundIn)
    {
        float f = (float)MathHelper.ceil(this.fallDistance - 3.0F);

        if (state.getMaterial() != Material.AIR)
        {
            double d0 = Math.min((double)(0.2F + f / 15.0F), 2.5D);
            int i = (int)(150.0D * d0);
            ((WorldServer)this.world).spawnParticle(EnumParticleTypes.BLOCK_DUST, this.posX, this.posY, this.posZ, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, new int[] {Block.getStateId(state)});
        }
    }

    super.updateFallState(y, onGroundIn, state, pos);
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:22,代码来源:EntityLivingBase.java

示例12: modifyMerchantRecipeList

import net.minecraft.util.math.MathHelper; //导入依赖的package包/类
/**
 * Affects the given MerchantRecipeList to possibly add or remove MerchantRecipes.
 */
public void modifyMerchantRecipeList(MerchantRecipeList recipeList, Random random)
{
    Enchantment enchantment = (Enchantment)Enchantment.REGISTRY.getRandomObject(random);
    int i = MathHelper.getRandomIntegerInRange(random, enchantment.getMinLevel(), enchantment.getMaxLevel());
    ItemStack itemstack = Items.ENCHANTED_BOOK.getEnchantedItemStack(new EnchantmentData(enchantment, i));
    int j = 2 + random.nextInt(5 + i * 10) + 3 * i;

    if (enchantment.isTreasureEnchantment())
    {
        j *= 2;
    }

    if (j > 64)
    {
        j = 64;
    }

    recipeList.add(new MerchantRecipe(new ItemStack(Items.BOOK), new ItemStack(Items.EMERALD, j), itemstack));
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:23,代码来源:EntityVillager.java

示例13: isOnLadder

import net.minecraft.util.math.MathHelper; //导入依赖的package包/类
/**
 * returns true if this entity is by a ladder, false otherwise
 */
public boolean isOnLadder()
{
    int i = MathHelper.floor(this.posX);
    int j = MathHelper.floor(this.getEntityBoundingBox().minY);
    int k = MathHelper.floor(this.posZ);

    if (this instanceof EntityPlayer && ((EntityPlayer)this).isSpectator())
    {
        return false;
    }
    else
    {
        BlockPos blockpos = new BlockPos(i, j, k);
        IBlockState iblockstate = this.world.getBlockState(blockpos);
        Block block = iblockstate.getBlock();
        return block != Blocks.LADDER && block != Blocks.VINE ? block instanceof BlockTrapDoor && this.canGoThroughtTrapDoorOnLadder(blockpos, iblockstate) : true;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:22,代码来源:EntityLivingBase.java

示例14: moveTowards

import net.minecraft.util.math.MathHelper; //导入依赖的package包/类
public void moveTowards(BlockPos pos)
{
    double d0 = (double)pos.getX();
    int i = pos.getY();
    double d1 = (double)pos.getZ();
    double d2 = d0 - this.posX;
    double d3 = d1 - this.posZ;
    float f = MathHelper.sqrt_double(d2 * d2 + d3 * d3);

    if (f > 12.0F)
    {
        this.targetX = this.posX + d2 / (double)f * 12.0D;
        this.targetZ = this.posZ + d3 / (double)f * 12.0D;
        this.targetY = this.posY + 8.0D;
    }
    else
    {
        this.targetX = d0;
        this.targetY = (double)i;
        this.targetZ = d1;
    }

    this.despawnTimer = 0;
    this.shatterOrDrop = this.rand.nextInt(5) > 0;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:26,代码来源:EntityEnderEye.java

示例15: moveMinecartOnRail

import net.minecraft.util.math.MathHelper; //导入依赖的package包/类
/**
 * Moved to allow overrides.
 * This code handles minecart movement and speed capping when on a rail.
 */
public void moveMinecartOnRail(BlockPos pos)
{
    double mX = this.motionX;
    double mZ = this.motionZ;

    if (this.isBeingRidden())
    {
        mX *= 0.75D;
        mZ *= 0.75D;
    }

    double max = this.getMaxSpeed();
    mX = MathHelper.clamp_double(mX, -max, max);
    mZ = MathHelper.clamp_double(mZ, -max, max);
    this.moveEntity(mX, 0.0D, mZ);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:21,代码来源:EntityMinecart.java


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