本文整理汇总了Java中net.minecraft.util.math.MathHelper.sqrt_float方法的典型用法代码示例。如果您正苦于以下问题:Java MathHelper.sqrt_float方法的具体用法?Java MathHelper.sqrt_float怎么用?Java MathHelper.sqrt_float使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.util.math.MathHelper
的用法示例。
在下文中一共展示了MathHelper.sqrt_float方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: layerSize
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
* Gets the rough size of a layer of the tree.
*/
float layerSize(int y)
{
if ((float)y < (float)this.heightLimit * 0.3F)
{
return -1.0F;
}
else
{
float f = (float)this.heightLimit / 2.0F;
float f1 = f - (float)y;
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;
}
}
示例2: moveRelative
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
* Used in both water and by flying objects
*/
public void moveRelative(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 * 0.017453292F);
float f2 = MathHelper.cos(this.rotationYaw * 0.017453292F);
this.motionX += (double)(strafe * f2 - forward * f1);
this.motionZ += (double)(forward * f2 + strafe * f1);
}
}
示例3: 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);
}
}
示例4: EntityRenderer
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public EntityRenderer(Minecraft mcIn, IResourceManager resourceManagerIn)
{
this.shaderIndex = SHADER_COUNT;
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;
}
}
}
示例5: renderMapFirstPersonSide
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
private void renderMapFirstPersonSide(float p_187465_1_, EnumHandSide p_187465_2_, float p_187465_3_, ItemStack p_187465_4_)
{
float f = p_187465_2_ == EnumHandSide.RIGHT ? 1.0F : -1.0F;
GlStateManager.translate(f * 0.125F, -0.125F, 0.0F);
if (!this.mc.thePlayer.isInvisible())
{
GlStateManager.pushMatrix();
GlStateManager.rotate(f * 10.0F, 0.0F, 0.0F, 1.0F);
this.renderArmFirstPerson(p_187465_1_, p_187465_3_, p_187465_2_);
GlStateManager.popMatrix();
}
GlStateManager.pushMatrix();
GlStateManager.translate(f * 0.51F, -0.08F + p_187465_1_ * -1.2F, -0.75F);
float f1 = MathHelper.sqrt_float(p_187465_3_);
float f2 = MathHelper.sin(f1 * (float)Math.PI);
float f3 = -0.5F * f2;
float f4 = 0.4F * MathHelper.sin(f1 * ((float)Math.PI * 2F));
float f5 = -0.3F * MathHelper.sin(p_187465_3_ * (float)Math.PI);
GlStateManager.translate(f * f3, f4 - 0.3F * f2, f5);
GlStateManager.rotate(f2 * -45.0F, 1.0F, 0.0F, 0.0F);
GlStateManager.rotate(f * f2 * -30.0F, 0.0F, 1.0F, 0.0F);
this.renderMapFirstPerson(p_187465_4_);
GlStateManager.popMatrix();
}
示例6: getDistanceToEntity
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
* Returns the distance to the 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);
}
示例7: rotateCorpse
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
protected void rotateCorpse(T entityLiving, float p_77043_2_, float p_77043_3_, float partialTicks)
{
GlStateManager.rotate(180.0F - p_77043_3_, 0.0F, 1.0F, 0.0F);
if (entityLiving.deathTime > 0)
{
float f = ((float)entityLiving.deathTime + partialTicks - 1.0F) / 20.0F * 1.6F;
f = MathHelper.sqrt_float(f);
if (f > 1.0F)
{
f = 1.0F;
}
GlStateManager.rotate(f * this.getDeathMaxRotation(entityLiving), 0.0F, 0.0F, 1.0F);
}
else
{
String s = TextFormatting.getTextWithoutFormattingCodes(entityLiving.getName());
if (s != null && ("Dinnerbone".equals(s) || "Grumm".equals(s)) && (!(entityLiving instanceof EntityPlayer) || ((EntityPlayer)entityLiving).isWearing(EnumPlayerModelParts.CAPE)))
{
GlStateManager.translate(0.0F, entityLiving.height + 0.1F, 0.0F);
GlStateManager.rotate(180.0F, 0.0F, 0.0F, 1.0F);
}
}
}
示例8: renderCrystalBeams
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public static void renderCrystalBeams(double p_188325_0_, double p_188325_2_, double p_188325_4_, float p_188325_6_, double p_188325_7_, double p_188325_9_, double p_188325_11_, int p_188325_13_, double p_188325_14_, double p_188325_16_, double p_188325_18_)
{
float f = (float)(p_188325_14_ - p_188325_7_);
float f1 = (float)(p_188325_16_ - 1.0D - p_188325_9_);
float f2 = (float)(p_188325_18_ - p_188325_11_);
float f3 = MathHelper.sqrt_float(f * f + f2 * f2);
float f4 = MathHelper.sqrt_float(f * f + f1 * f1 + f2 * f2);
GlStateManager.pushMatrix();
GlStateManager.translate((float)p_188325_0_, (float)p_188325_2_ + 2.0F, (float)p_188325_4_);
GlStateManager.rotate((float)(-Math.atan2((double)f2, (double)f)) * (180F / (float)Math.PI) - 90.0F, 0.0F, 1.0F, 0.0F);
GlStateManager.rotate((float)(-Math.atan2((double)f3, (double)f1)) * (180F / (float)Math.PI) - 90.0F, 1.0F, 0.0F, 0.0F);
Tessellator tessellator = Tessellator.getInstance();
VertexBuffer vertexbuffer = tessellator.getBuffer();
RenderHelper.disableStandardItemLighting();
GlStateManager.disableCull();
GlStateManager.shadeModel(7425);
float f5 = 0.0F - ((float)p_188325_13_ + p_188325_6_) * 0.01F;
float f6 = MathHelper.sqrt_float(f * f + f1 * f1 + f2 * f2) / 32.0F - ((float)p_188325_13_ + p_188325_6_) * 0.01F;
vertexbuffer.begin(5, DefaultVertexFormats.POSITION_TEX_COLOR);
int i = 8;
for (int j = 0; j <= 8; ++j)
{
float f7 = MathHelper.sin((float)(j % 8) * ((float)Math.PI * 2F) / 8.0F) * 0.75F;
float f8 = MathHelper.cos((float)(j % 8) * ((float)Math.PI * 2F) / 8.0F) * 0.75F;
float f9 = (float)(j % 8) / 8.0F;
vertexbuffer.pos((double)(f7 * 0.2F), (double)(f8 * 0.2F), 0.0D).tex((double)f9, (double)f5).color(0, 0, 0, 255).endVertex();
vertexbuffer.pos((double)f7, (double)f8, (double)f4).tex((double)f9, (double)f6).color(255, 255, 255, 255).endVertex();
}
tessellator.draw();
GlStateManager.enableCull();
GlStateManager.shadeModel(7424);
RenderHelper.enableStandardItemLighting();
GlStateManager.popMatrix();
}
示例9: renderMapFirstPerson
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
private void renderMapFirstPerson(float p_187463_1_, float p_187463_2_, float p_187463_3_)
{
float f = MathHelper.sqrt_float(p_187463_3_);
float f1 = -0.2F * MathHelper.sin(p_187463_3_ * (float)Math.PI);
float f2 = -0.4F * MathHelper.sin(f * (float)Math.PI);
GlStateManager.translate(0.0F, -f1 / 2.0F, f2);
float f3 = this.getMapAngleFromPitch(p_187463_1_);
GlStateManager.translate(0.0F, 0.04F + p_187463_2_ * -1.2F + f3 * -0.5F, -0.72F);
GlStateManager.rotate(f3 * -85.0F, 1.0F, 0.0F, 0.0F);
this.renderArms();
float f4 = MathHelper.sin(f * (float)Math.PI);
GlStateManager.rotate(f4 * 20.0F, 1.0F, 0.0F, 0.0F);
GlStateManager.scale(2.0F, 2.0F, 2.0F);
this.renderMapFirstPerson(this.itemStackMainHand);
}
示例10: renderArmFirstPerson
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
private void renderArmFirstPerson(float p_187456_1_, float p_187456_2_, EnumHandSide p_187456_3_)
{
boolean flag = p_187456_3_ != EnumHandSide.LEFT;
float f = flag ? 1.0F : -1.0F;
float f1 = MathHelper.sqrt_float(p_187456_2_);
float f2 = -0.3F * MathHelper.sin(f1 * (float)Math.PI);
float f3 = 0.4F * MathHelper.sin(f1 * ((float)Math.PI * 2F));
float f4 = -0.4F * MathHelper.sin(p_187456_2_ * (float)Math.PI);
GlStateManager.translate(f * (f2 + 0.64000005F), f3 + -0.6F + p_187456_1_ * -0.6F, f4 + -0.71999997F);
GlStateManager.rotate(f * 45.0F, 0.0F, 1.0F, 0.0F);
float f5 = MathHelper.sin(p_187456_2_ * p_187456_2_ * (float)Math.PI);
float f6 = MathHelper.sin(f1 * (float)Math.PI);
GlStateManager.rotate(f * f6 * 70.0F, 0.0F, 1.0F, 0.0F);
GlStateManager.rotate(f * f5 * -20.0F, 0.0F, 0.0F, 1.0F);
AbstractClientPlayer abstractclientplayer = this.mc.thePlayer;
this.mc.getTextureManager().bindTexture(abstractclientplayer.getLocationSkin());
GlStateManager.translate(f * -1.0F, 3.6F, 3.5F);
GlStateManager.rotate(f * 120.0F, 0.0F, 0.0F, 1.0F);
GlStateManager.rotate(200.0F, 1.0F, 0.0F, 0.0F);
GlStateManager.rotate(f * -135.0F, 0.0F, 1.0F, 0.0F);
GlStateManager.translate(f * 5.6F, 0.0F, 0.0F);
RenderPlayer renderplayer = (RenderPlayer)this.renderManager.getEntityRenderObject(abstractclientplayer);
GlStateManager.disableCull();
if (flag)
{
renderplayer.renderRightArm(abstractclientplayer);
}
else
{
renderplayer.renderLeftArm(abstractclientplayer);
}
GlStateManager.enableCull();
}
示例11: normalize
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
private void normalize(float[] p_180547_1_)
{
float f = MathHelper.sqrt_float(p_180547_1_[0] * p_180547_1_[0] + p_180547_1_[1] * p_180547_1_[1] + p_180547_1_[2] * p_180547_1_[2]);
p_180547_1_[0] /= f;
p_180547_1_[1] /= f;
p_180547_1_[2] /= f;
p_180547_1_[3] /= f;
}
示例12: distanceTo
import net.minecraft.util.math.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);
}
示例13: ChunkProviderOverworld
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public ChunkProviderOverworld(World worldIn, long seed, boolean mapFeaturesEnabledIn, String p_i46668_5_)
{
{
caveGenerator = net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(caveGenerator, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.CAVE);
strongholdGenerator = (MapGenStronghold)net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(strongholdGenerator, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.STRONGHOLD);
villageGenerator = (MapGenVillage)net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(villageGenerator, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.VILLAGE);
mineshaftGenerator = (MapGenMineshaft)net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(mineshaftGenerator, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.MINESHAFT);
scatteredFeatureGenerator = (MapGenScatteredFeature)net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(scatteredFeatureGenerator, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.SCATTERED_FEATURE);
ravineGenerator = net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(ravineGenerator, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.RAVINE);
oceanMonumentGenerator = (StructureOceanMonument)net.minecraftforge.event.terraingen.TerrainGen.getModdedMapGen(oceanMonumentGenerator, net.minecraftforge.event.terraingen.InitMapGenEvent.EventType.OCEAN_MONUMENT);
}
this.worldObj = worldIn;
this.mapFeaturesEnabled = mapFeaturesEnabledIn;
this.terrainType = worldIn.getWorldInfo().getTerrainType();
this.rand = new Random(seed);
this.minLimitPerlinNoise = new NoiseGeneratorOctaves(this.rand, 16);
this.maxLimitPerlinNoise = new NoiseGeneratorOctaves(this.rand, 16);
this.mainPerlinNoise = new NoiseGeneratorOctaves(this.rand, 8);
this.surfaceNoise = new NoiseGeneratorPerlin(this.rand, 4);
this.scaleNoise = new NoiseGeneratorOctaves(this.rand, 10);
this.depthNoise = new NoiseGeneratorOctaves(this.rand, 16);
this.forestNoise = new NoiseGeneratorOctaves(this.rand, 8);
this.heightMap = new double[825];
this.biomeWeights = 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.biomeWeights[i + 2 + (j + 2) * 5] = f;
}
}
if (p_i46668_5_ != null)
{
this.settings = ChunkProviderSettings.Factory.jsonToFactory(p_i46668_5_).build();
this.oceanBlock = this.settings.useLavaOceans ? Blocks.LAVA.getDefaultState() : Blocks.WATER.getDefaultState();
worldIn.setSeaLevel(this.settings.seaLevel);
}
net.minecraftforge.event.terraingen.InitNoiseGensEvent.ContextOverworld ctx =
new net.minecraftforge.event.terraingen.InitNoiseGensEvent.ContextOverworld(minLimitPerlinNoise, maxLimitPerlinNoise, mainPerlinNoise, surfaceNoise, scaleNoise, depthNoise, forestNoise);
ctx = net.minecraftforge.event.terraingen.TerrainGen.getModdedNoiseGenerators(worldIn, this.rand, ctx);
this.minLimitPerlinNoise = ctx.getLPerlin1();
this.maxLimitPerlinNoise = ctx.getLPerlin2();
this.mainPerlinNoise = ctx.getPerlin();
this.surfaceNoise = ctx.getHeight();
this.scaleNoise = ctx.getScale();
this.depthNoise = ctx.getDepth();
this.forestNoise = ctx.getForest();
}
示例14: getIslandHeightValue
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
private float getIslandHeightValue(int p_185960_1_, int p_185960_2_, int p_185960_3_, int p_185960_4_)
{
float f = (float)(p_185960_1_ * 2 + p_185960_3_);
float f1 = (float)(p_185960_2_ * 2 + p_185960_4_);
float f2 = 100.0F - MathHelper.sqrt_float(f * f + f1 * f1) * 8.0F;
if (f2 > 80.0F)
{
f2 = 80.0F;
}
if (f2 < -100.0F)
{
f2 = -100.0F;
}
for (int i = -12; i <= 12; ++i)
{
for (int j = -12; j <= 12; ++j)
{
long k = (long)(p_185960_1_ + i);
long l = (long)(p_185960_2_ + j);
if (k * k + l * l > 4096L && this.islandNoise.getValue((double)k, (double)l) < -0.8999999761581421D)
{
float f3 = (MathHelper.abs((float)k) * 3439.0F + MathHelper.abs((float)l) * 147.0F) % 13.0F + 9.0F;
f = (float)(p_185960_3_ - i * 2);
f1 = (float)(p_185960_4_ - j * 2);
float f4 = 100.0F - MathHelper.sqrt_float(f * f + f1 * f1) * f3;
if (f4 > 80.0F)
{
f4 = 80.0F;
}
if (f4 < -100.0F)
{
f4 = -100.0F;
}
if (f4 > f2)
{
f2 = f4;
}
}
}
}
return f2;
}
示例15: onUpdateMoveHelper
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public void onUpdateMoveHelper()
{
if (this.action == EntityMoveHelper.Action.STRAFE)
{
float f = (float)this.entity.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).getAttributeValue();
float f1 = (float)this.speed * f;
float f2 = this.moveForward;
float f3 = this.moveStrafe;
float f4 = MathHelper.sqrt_float(f2 * f2 + f3 * f3);
if (f4 < 1.0F)
{
f4 = 1.0F;
}
f4 = f1 / f4;
f2 = f2 * f4;
f3 = f3 * f4;
float f5 = MathHelper.sin(this.entity.rotationYaw * 0.017453292F);
float f6 = MathHelper.cos(this.entity.rotationYaw * 0.017453292F);
float f7 = f2 * f6 - f3 * f5;
float f8 = f3 * f6 + f2 * f5;
PathNavigate pathnavigate = this.entity.getNavigator();
if (pathnavigate != null)
{
NodeProcessor nodeprocessor = pathnavigate.getNodeProcessor();
if (nodeprocessor != null && nodeprocessor.getPathNodeType(this.entity.worldObj, MathHelper.floor_double(this.entity.posX + (double)f7), MathHelper.floor_double(this.entity.posY), MathHelper.floor_double(this.entity.posZ + (double)f8)) != PathNodeType.WALKABLE)
{
this.moveForward = 1.0F;
this.moveStrafe = 0.0F;
f1 = f;
}
}
this.entity.setAIMoveSpeed(f1);
this.entity.setMoveForward(this.moveForward);
this.entity.setMoveStrafing(this.moveStrafe);
this.action = EntityMoveHelper.Action.WAIT;
}
else if (this.action == EntityMoveHelper.Action.MOVE_TO)
{
this.action = EntityMoveHelper.Action.WAIT;
double d0 = this.posX - this.entity.posX;
double d1 = this.posZ - this.entity.posZ;
double d2 = this.posY - this.entity.posY;
double d3 = d0 * d0 + d2 * d2 + d1 * d1;
if (d3 < 2.500000277905201E-7D)
{
this.entity.setMoveForward(0.0F);
return;
}
float f9 = (float)(MathHelper.atan2(d1, d0) * (180D / Math.PI)) - 90.0F;
this.entity.rotationYaw = this.limitAngle(this.entity.rotationYaw, f9, 90.0F);
this.entity.setAIMoveSpeed((float)(this.speed * this.entity.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).getAttributeValue()));
if (d2 > (double)this.entity.stepHeight && d0 * d0 + d1 * d1 < (double)Math.max(1.0F, this.entity.width))
{
this.entity.getJumpHelper().setJumping();
}
}
else
{
this.entity.setMoveForward(0.0F);
}
}