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


Java MathHelper.sqrt_float方法代碼示例

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


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

示例1: moveFlying

import net.minecraft.util.MathHelper; //導入方法依賴的package包/類
/**
 * Used in both water and by flying objects
 */
public void moveFlying(float strafe, float forward, float friction)
{
    float f = strafe * strafe + forward * forward;

    if (f >= 1.0E-4F)
    {
        f = MathHelper.sqrt_float(f);

        if (f < 1.0F)
        {
            f = 1.0F;
        }

        f = friction / f;
        strafe = strafe * f;
        forward = forward * f;
        float f1 = MathHelper.sin(this.rotationYaw * (float)Math.PI / 180.0F);
        float f2 = MathHelper.cos(this.rotationYaw * (float)Math.PI / 180.0F);
        this.motionX += (double)(strafe * f2 - forward * f1);
        this.motionZ += (double)(forward * f2 + strafe * f1);
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:26,代碼來源:Entity.java

示例2: EntityRenderer

import net.minecraft.util.MathHelper; //導入方法依賴的package包/類
public EntityRenderer(Minecraft mcIn, IResourceManager resourceManagerIn) {
	this.shaderIndex = shaderCount;
	this.useShader = false;
	this.frameCount = 0;
	this.mc = mcIn;
	this.resourceManager = resourceManagerIn;
	this.itemRenderer = mcIn.getItemRenderer();
	this.theMapItemRenderer = new MapItemRenderer(mcIn.getTextureManager());
	this.lightmapTexture = new DynamicTexture(16, 16);
	this.locationLightMap = mcIn.getTextureManager().getDynamicTextureLocation("lightMap", this.lightmapTexture);
	this.lightmapColors = this.lightmapTexture.getTextureData();
	this.theShaderGroup = null;

	for (int i = 0; i < 32; ++i) {
		for (int j = 0; j < 32; ++j) {
			float f = (float) (j - 16);
			float f1 = (float) (i - 16);
			float f2 = MathHelper.sqrt_float(f * f + f1 * f1);
			this.rainXCoords[i << 5 | j] = -f1 / f2;
			this.rainYCoords[i << 5 | j] = f / f2;
		}
	}
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:24,代碼來源:EntityRenderer.java

示例3: rotateCorpse

import net.minecraft.util.MathHelper; //導入方法依賴的package包/類
protected void rotateCorpse(EntityDragon bat, float p_77043_2_, float p_77043_3_, float partialTicks)
{
    float f = (float)bat.getMovementOffsets(7, partialTicks)[0];
    float f1 = (float)(bat.getMovementOffsets(5, partialTicks)[1] - bat.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 (bat.deathTime > 0)
    {
        float f2 = ((float)bat.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(bat), 0.0F, 0.0F, 1.0F);
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:22,代碼來源:RenderDragon.java

示例4: layerSize

import net.minecraft.util.MathHelper; //導入方法依賴的package包/類
/**
 * Gets the rough size of a layer of the tree.
 */
float layerSize(int p_76490_1_)
{
    if ((float)p_76490_1_ < (float)this.heightLimit * 0.3F)
    {
        return -1.0F;
    }
    else
    {
        float f = (float)this.heightLimit / 2.0F;
        float f1 = f - (float)p_76490_1_;
        float f2 = MathHelper.sqrt_float(f * f - f1 * f1);

        if (f1 == 0.0F)
        {
            f2 = f;
        }
        else if (Math.abs(f1) >= f)
        {
            return 0.0F;
        }

        return f2 * 0.5F;
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:28,代碼來源:WorldGenBigTree.java

示例5: ChunkProviderGenerate

import net.minecraft.util.MathHelper; //導入方法依賴的package包/類
public ChunkProviderGenerate(World worldIn, long p_i45636_2_, boolean p_i45636_4_, String p_i45636_5_)
{
    this.worldObj = worldIn;
    this.mapFeaturesEnabled = p_i45636_4_;
    this.field_177475_o = worldIn.getWorldInfo().getTerrainType();
    this.rand = new Random(p_i45636_2_);
    this.field_147431_j = new NoiseGeneratorOctaves(this.rand, 16);
    this.field_147432_k = new NoiseGeneratorOctaves(this.rand, 16);
    this.field_147429_l = new NoiseGeneratorOctaves(this.rand, 8);
    this.field_147430_m = new NoiseGeneratorPerlin(this.rand, 4);
    this.noiseGen5 = new NoiseGeneratorOctaves(this.rand, 10);
    this.noiseGen6 = new NoiseGeneratorOctaves(this.rand, 16);
    this.mobSpawnerNoise = new NoiseGeneratorOctaves(this.rand, 8);
    this.field_147434_q = new double[825];
    this.parabolicField = new float[25];

    for (int i = -2; i <= 2; ++i)
    {
        for (int j = -2; j <= 2; ++j)
        {
            float f = 10.0F / MathHelper.sqrt_float((float)(i * i + j * j) + 0.2F);
            this.parabolicField[i + 2 + (j + 2) * 5] = f;
        }
    }

    if (p_i45636_5_ != null)
    {
        this.settings = ChunkProviderSettings.Factory.jsonToFactory(p_i45636_5_).func_177864_b();
        this.field_177476_s = this.settings.useLavaOceans ? Blocks.lava : Blocks.water;
        worldIn.func_181544_b(this.settings.seaLevel);
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:33,代碼來源:ChunkProviderGenerate.java

示例6: getDistanceToEntity

import net.minecraft.util.MathHelper; //導入方法依賴的package包/類
/**
 * Returns the distance to the entity. Args: entity
 */
public float getDistanceToEntity(Entity entityIn)
{
    float f = (float)(this.posX - entityIn.posX);
    float f1 = (float)(this.posY - entityIn.posY);
    float f2 = (float)(this.posZ - entityIn.posZ);
    return MathHelper.sqrt_float(f * f + f1 * f1 + f2 * f2);
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:11,代碼來源:Entity.java

示例7: distanceTo

import net.minecraft.util.MathHelper; //導入方法依賴的package包/類
/**
 * Returns the linear distance to another path point
 */
public float distanceTo(PathPoint pathpointIn)
{
    float f = (float)(pathpointIn.xCoord - this.xCoord);
    float f1 = (float)(pathpointIn.yCoord - this.yCoord);
    float f2 = (float)(pathpointIn.zCoord - this.zCoord);
    return MathHelper.sqrt_float(f * f + f1 * f1 + f2 * f2);
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:11,代碼來源:PathPoint.java

示例8: ChunkProviderSpaceLakes

import net.minecraft.util.MathHelper; //導入方法依賴的package包/類
public ChunkProviderSpaceLakes(World world, long seed, boolean flag)
{
	super();
	this.stoneNoise = new double[256];
	this.worldObj = world;
	this.rand = new Random(seed);
	this.noiseGen4 = new NoiseGeneratorOctaves(this.rand, 4);
	this.noiseGen5 = new NoiseGeneratorOctaves(this.rand, 10);
	this.noiseGen6 = new NoiseGeneratorOctaves(this.rand, 16);
	this.noiseGen8 = new Gradient(this.rand.nextLong(), 2, 0.25F);
	this.mobSpawnerNoise = new NoiseGeneratorOctaves(this.rand, 8);
	this.field_147431_j = new NoiseGeneratorOctaves(this.rand, 16);
	this.field_147432_k = new NoiseGeneratorOctaves(this.rand, 16);
	this.field_147429_l = new NoiseGeneratorOctaves(this.rand, 8);
	this.field_147430_m = new NoiseGeneratorPerlin(this.rand, 4);
	this.terrainCalcs = new double[825];
	this.parabolicField = new float[25];

	for (int j = -2; j <= 2; j++)
	{
		for (int k = -2; k <= 2; k++)
		{
			float f = 10.0F / MathHelper.sqrt_float(j * j + k * k + 0.2F);
			this.parabolicField[j + 2 + (k + 2) * 5] = f;
		}
	}
}
 
開發者ID:BlesseNtumble,項目名稱:TRAPPIST-1,代碼行數:28,代碼來源:ChunkProviderSpaceLakes.java

示例9: doRender_NeutralBeam

import net.minecraft.util.MathHelper; //導入方法依賴的package包/類
public void doRender_NeutralBeam(_ProjectileBase entity, double x, double y, double z, float yaw, float tick, float beamWidth) 
  {
  	//GL11.glPushMatrix();
  	
//float f2 = par9;// (float) player.innerRotation + par9;
float f3 = MathHelper.sin(tick * 0.2F) / 2.0F + 0.5F;
f3 = (f3 * f3 + f3) * 0.2F;

float xPosEnd = (float) (entity.ownerX - entity.posX - (entity.prevPosX - entity.posX) * (double) (1.0F - tick));
float yPosEnd = (float) ((double) f3 + entity.ownerY - entity.posY - (entity.prevPosY - entity.posY) * (double) (1.0F - tick));
float zPosEnd = (float) (entity.ownerZ - entity.posZ - (entity.prevPosZ - entity.posZ) * (double) (1.0F - tick));

//for rotation/distance
float f7 = MathHelper.sqrt_float(xPosEnd * xPosEnd + zPosEnd * zPosEnd);
float f8 = MathHelper.sqrt_float(xPosEnd * xPosEnd + yPosEnd * yPosEnd + zPosEnd * zPosEnd);

// Changing the starting point here slightly, so it doesn't come out of the center
//int distance = 6;	// Increasing this will likely increase the distance
//double adjustmentZ = -MathHelper.cos((entity.shootingEntity.rotationYaw) * (float)Math.PI / 180.0F) * (distance * 0.08);
//double adjustmentX = MathHelper.sin((entity.shootingEntity.rotationYaw) * (float)Math.PI / 180.0F) * (distance * 0.08);

// Start drawing (i think)
GL11.glTranslated((float) x, (float) y, (float) z);	// Adjusted with distance to shooter
GL11.glRotatef((float) (-Math.atan2((double) zPosEnd, (double) xPosEnd)) * 180.0F / (float) Math.PI - 90.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef((float) (-Math.atan2((double) f7, (double) yPosEnd)) * 180.0F / (float) Math.PI - 90.0F, 1.0F, 0.0F, 0.0F);
Tessellator tessellator = Tessellator.instance;

//Makes the beam look nice
RenderHelper.disableStandardItemLighting();
GL11.glDisable(GL11.GL_CULL_FACE);

//Shading?
GL11.glShadeModel(GL11.GL_SMOOTH);

//from what i can tell f9 and f10 make the beam change (looks like its rotating or whatnot)
float f9 = 0.0F - ((float) entity.ticksExisted + tick) * 0.01F;
float f10 = MathHelper.sqrt_float(xPosEnd * xPosEnd + yPosEnd * yPosEnd + zPosEnd * zPosEnd) / 32.0F - ((float) entity.ticksExisted + tick) * 0.01F;

// change draw mode
tessellator.startDrawing(5);
byte b0 = 8;	// how many sides the circle has?

//float beamWidth = 0.15f;

for (int i = 0; i <= b0; ++i) 	// makes one side circular(fancy math stuff)
{
       float f11 = MathHelper.sin((float) (i % b0) * (float) Math.PI * 2.0F / (float) b0) * beamWidth;		// "changing the 2 or .75 should change size of circle"
       float f12 = MathHelper.cos((float) (i % b0) * (float) Math.PI * 2.0F / (float) b0) * beamWidth;		// The 2 seems to be there to describe a full circle
       float f13 = (float) (i % b0) * 1.0F / (float) b0;												// 1 makes it a half circle
       tessellator.setColorOpaque_I(0);
       tessellator.addVertexWithUV((double) (f11 * 0.2F), (double) (f12 * 0.2F), 0.0D, (double) f13, (double) f10);	// Now how do I shorten the beam slightly
       tessellator.setColorOpaque_I(16777215);																			// so it doesn't appear from the center of the shooter
       tessellator.addVertexWithUV((double) f11, (double) f12, (double) f8, (double) f13, (double) f9);				
}

tessellator.draw();	// draw added vertices
  
// reset openGl stuff?
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glShadeModel(GL11.GL_FLAT);
RenderHelper.enableStandardItemLighting();
  	
  	GL11.glPopMatrix();
  }
 
開發者ID:Domochevsky,項目名稱:minecraft-quiverbow,代碼行數:65,代碼來源:Render_Projectile.java

示例10: doRenderLayer

import net.minecraft.util.MathHelper; //導入方法依賴的package包/類
public void doRenderLayer(EntityLivingBase entitylivingbaseIn, float p_177141_2_, float p_177141_3_, float partialTicks, float p_177141_5_, float p_177141_6_, float p_177141_7_, float scale)
{
    int i = entitylivingbaseIn.getArrowCountInEntity();

    if (i > 0)
    {
        Entity entity = new EntityArrow(entitylivingbaseIn.worldObj, entitylivingbaseIn.posX, entitylivingbaseIn.posY, entitylivingbaseIn.posZ);
        Random random = new Random((long)entitylivingbaseIn.getEntityId());
        RenderHelper.disableStandardItemLighting();

        for (int j = 0; j < i; ++j)
        {
            GlStateManager.pushMatrix();
            ModelRenderer modelrenderer = this.field_177168_a.getMainModel().getRandomModelBox(random);
            ModelBox modelbox = (ModelBox)modelrenderer.cubeList.get(random.nextInt(modelrenderer.cubeList.size()));
            modelrenderer.postRender(0.0625F);
            float f = random.nextFloat();
            float f1 = random.nextFloat();
            float f2 = random.nextFloat();
            float f3 = (modelbox.posX1 + (modelbox.posX2 - modelbox.posX1) * f) / 16.0F;
            float f4 = (modelbox.posY1 + (modelbox.posY2 - modelbox.posY1) * f1) / 16.0F;
            float f5 = (modelbox.posZ1 + (modelbox.posZ2 - modelbox.posZ1) * f2) / 16.0F;
            GlStateManager.translate(f3, f4, f5);
            f = f * 2.0F - 1.0F;
            f1 = f1 * 2.0F - 1.0F;
            f2 = f2 * 2.0F - 1.0F;
            f = f * -1.0F;
            f1 = f1 * -1.0F;
            f2 = f2 * -1.0F;
            float f6 = MathHelper.sqrt_float(f * f + f2 * f2);
            entity.prevRotationYaw = entity.rotationYaw = (float)(Math.atan2((double)f, (double)f2) * 180.0D / Math.PI);
            entity.prevRotationPitch = entity.rotationPitch = (float)(Math.atan2((double)f1, (double)f6) * 180.0D / Math.PI);
            double d0 = 0.0D;
            double d1 = 0.0D;
            double d2 = 0.0D;
            this.field_177168_a.getRenderManager().renderEntityWithPosYaw(entity, d0, d1, d2, 0.0F, partialTicks);
            GlStateManager.popMatrix();
        }

        RenderHelper.enableStandardItemLighting();
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:43,代碼來源:LayerArrow.java

示例11: sqrt

import net.minecraft.util.MathHelper; //導入方法依賴的package包/類
public static float sqrt(float p_sqrt_0_)
{
    return MathHelper.sqrt_float(p_sqrt_0_);
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:5,代碼來源:RealmsMth.java

示例12: updateTask

import net.minecraft.util.MathHelper; //導入方法依賴的package包/類
public void updateTask()
{
    --this.field_179468_c;
    EntityLivingBase entitylivingbase = this.blaze.getAttackTarget();
    double d0 = this.blaze.getDistanceSqToEntity(entitylivingbase);

    if (d0 < 4.0D)
    {
        if (this.field_179468_c <= 0)
        {
            this.field_179468_c = 20;
            this.blaze.attackEntityAsMob(entitylivingbase);
        }

        this.blaze.getMoveHelper().setMoveTo(entitylivingbase.posX, entitylivingbase.posY, entitylivingbase.posZ, 1.0D);
    }
    else if (d0 < 256.0D)
    {
        double d1 = entitylivingbase.posX - this.blaze.posX;
        double d2 = entitylivingbase.getEntityBoundingBox().minY + (double)(entitylivingbase.height / 2.0F) - (this.blaze.posY + (double)(this.blaze.height / 2.0F));
        double d3 = entitylivingbase.posZ - this.blaze.posZ;

        if (this.field_179468_c <= 0)
        {
            ++this.field_179467_b;

            if (this.field_179467_b == 1)
            {
                this.field_179468_c = 60;
                this.blaze.setOnFire(true);
            }
            else if (this.field_179467_b <= 4)
            {
                this.field_179468_c = 6;
            }
            else
            {
                this.field_179468_c = 100;
                this.field_179467_b = 0;
                this.blaze.setOnFire(false);
            }

            if (this.field_179467_b > 1)
            {
                float f = MathHelper.sqrt_float(MathHelper.sqrt_double(d0)) * 0.5F;
                this.blaze.worldObj.playAuxSFXAtEntity((EntityPlayer)null, 1009, new BlockPos((int)this.blaze.posX, (int)this.blaze.posY, (int)this.blaze.posZ), 0);

                for (int i = 0; i < 1; ++i)
                {
                    EntitySmallFireball entitysmallfireball = new EntitySmallFireball(this.blaze.worldObj, this.blaze, d1 + this.blaze.getRNG().nextGaussian() * (double)f, d2, d3 + this.blaze.getRNG().nextGaussian() * (double)f);
                    entitysmallfireball.posY = this.blaze.posY + (double)(this.blaze.height / 2.0F) + 0.5D;
                    this.blaze.worldObj.spawnEntityInWorld(entitysmallfireball);
                }
            }
        }

        this.blaze.getLookHelper().setLookPositionWithEntity(entitylivingbase, 10.0F, 10.0F);
    }
    else
    {
        this.blaze.getNavigator().clearPathEntity();
        this.blaze.getMoveHelper().setMoveTo(entitylivingbase.posX, entitylivingbase.posY, entitylivingbase.posZ, 1.0D);
    }

    super.updateTask();
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:67,代碼來源:EntityBlaze.java

示例13: drawRechargeRay

import net.minecraft.util.MathHelper; //導入方法依賴的package包/類
/**
 * Draws the ray from the dragon to it's crystal
 */
protected void drawRechargeRay(EntityDragon dragon, double p_180574_2_, double p_180574_4_, double p_180574_6_, float p_180574_8_)
{
    float f = (float)dragon.healingEnderCrystal.innerRotation + p_180574_8_;
    float f1 = MathHelper.sin(f * 0.2F) / 2.0F + 0.5F;
    f1 = (f1 * f1 + f1) * 0.2F;
    float f2 = (float)(dragon.healingEnderCrystal.posX - dragon.posX - (dragon.prevPosX - dragon.posX) * (double)(1.0F - p_180574_8_));
    float f3 = (float)((double)f1 + dragon.healingEnderCrystal.posY - 1.0D - dragon.posY - (dragon.prevPosY - dragon.posY) * (double)(1.0F - p_180574_8_));
    float f4 = (float)(dragon.healingEnderCrystal.posZ - dragon.posZ - (dragon.prevPosZ - dragon.posZ) * (double)(1.0F - p_180574_8_));
    float f5 = MathHelper.sqrt_float(f2 * f2 + f4 * f4);
    float f6 = MathHelper.sqrt_float(f2 * f2 + f3 * f3 + f4 * f4);
    GlStateManager.pushMatrix();
    GlStateManager.translate((float)p_180574_2_, (float)p_180574_4_ + 2.0F, (float)p_180574_6_);
    GlStateManager.rotate((float)(-Math.atan2((double)f4, (double)f2)) * 180.0F / (float)Math.PI - 90.0F, 0.0F, 1.0F, 0.0F);
    GlStateManager.rotate((float)(-Math.atan2((double)f5, (double)f3)) * 180.0F / (float)Math.PI - 90.0F, 1.0F, 0.0F, 0.0F);
    Tessellator tessellator = Tessellator.getInstance();
    WorldRenderer worldrenderer = tessellator.getWorldRenderer();
    RenderHelper.disableStandardItemLighting();
    GlStateManager.disableCull();
    this.bindTexture(enderDragonCrystalBeamTextures);
    GlStateManager.shadeModel(7425);
    float f7 = 0.0F - ((float)dragon.ticksExisted + p_180574_8_) * 0.01F;
    float f8 = MathHelper.sqrt_float(f2 * f2 + f3 * f3 + f4 * f4) / 32.0F - ((float)dragon.ticksExisted + p_180574_8_) * 0.01F;
    worldrenderer.begin(5, DefaultVertexFormats.POSITION_TEX_COLOR);
    int i = 8;

    for (int j = 0; j <= 8; ++j)
    {
        float f9 = MathHelper.sin((float)(j % 8) * (float)Math.PI * 2.0F / 8.0F) * 0.75F;
        float f10 = MathHelper.cos((float)(j % 8) * (float)Math.PI * 2.0F / 8.0F) * 0.75F;
        float f11 = (float)(j % 8) * 1.0F / 8.0F;
        worldrenderer.pos((double)(f9 * 0.2F), (double)(f10 * 0.2F), 0.0D).tex((double)f11, (double)f8).color(0, 0, 0, 255).endVertex();
        worldrenderer.pos((double)f9, (double)f10, (double)f6).tex((double)f11, (double)f7).color(255, 255, 255, 255).endVertex();
    }

    tessellator.draw();
    GlStateManager.enableCull();
    GlStateManager.shadeModel(7424);
    RenderHelper.enableStandardItemLighting();
    GlStateManager.popMatrix();
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:44,代碼來源:RenderDragon.java


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