本文整理汇总了Java中net.minecraft.util.math.MathHelper.sin方法的典型用法代码示例。如果您正苦于以下问题:Java MathHelper.sin方法的具体用法?Java MathHelper.sin怎么用?Java MathHelper.sin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.util.math.MathHelper
的用法示例。
在下文中一共展示了MathHelper.sin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updatePassenger
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public void updatePassenger(Entity passenger)
{
super.updatePassenger(passenger);
if (passenger instanceof EntityLiving)
{
EntityLiving entityliving = (EntityLiving)passenger;
this.renderYawOffset = entityliving.renderYawOffset;
}
if (this.prevRearingAmount > 0.0F)
{
float f3 = MathHelper.sin(this.renderYawOffset * 0.017453292F);
float f = MathHelper.cos(this.renderYawOffset * 0.017453292F);
float f1 = 0.7F * this.prevRearingAmount;
float f2 = 0.15F * this.prevRearingAmount;
passenger.setPosition(this.posX + (double)(f1 * f3), this.posY + this.getMountedYOffset() + passenger.getYOffset() + (double)f2, this.posZ - (double)(f1 * f));
if (passenger instanceof EntityLivingBase)
{
((EntityLivingBase)passenger).renderYawOffset = this.renderYawOffset;
}
}
}
示例2: updateRenderInfo
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
* Updates the current render info and camera location based on entity look angles and 1st/3rd person view mode
*/
public static void updateRenderInfo(EntityPlayer entityplayerIn, boolean p_74583_1_)
{
GlStateManager.getFloat(2982, MODELVIEW);
GlStateManager.getFloat(2983, PROJECTION);
GlStateManager.glGetInteger(2978, VIEWPORT);
float f = (float)((VIEWPORT.get(0) + VIEWPORT.get(2)) / 2);
float f1 = (float)((VIEWPORT.get(1) + VIEWPORT.get(3)) / 2);
GLU.gluUnProject(f, f1, 0.0F, MODELVIEW, PROJECTION, VIEWPORT, OBJECTCOORDS);
position = new Vec3d((double)OBJECTCOORDS.get(0), (double)OBJECTCOORDS.get(1), (double)OBJECTCOORDS.get(2));
int i = p_74583_1_ ? 1 : 0;
float f2 = entityplayerIn.rotationPitch;
float f3 = entityplayerIn.rotationYaw;
rotationX = MathHelper.cos(f3 * 0.017453292F) * (float)(1 - i * 2);
rotationZ = MathHelper.sin(f3 * 0.017453292F) * (float)(1 - i * 2);
rotationYZ = -rotationZ * MathHelper.sin(f2 * 0.017453292F) * (float)(1 - i * 2);
rotationXY = rotationX * MathHelper.sin(f2 * 0.017453292F) * (float)(1 - i * 2);
rotationXZ = MathHelper.cos(f2 * 0.017453292F);
}
示例3: updateTask
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
public void updateTask()
{
int i = this.squid.getAge();
if (i > 100)
{
this.squid.setMovementVector(0.0F, 0.0F, 0.0F);
}
else if (this.squid.getRNG().nextInt(50) == 0 || !this.squid.inWater || !this.squid.hasMovementVector())
{
float f = this.squid.getRNG().nextFloat() * ((float)Math.PI * 2F);
float f1 = MathHelper.cos(f) * 0.2F;
float f2 = -0.1F + this.squid.getRNG().nextFloat() * 0.2F;
float f3 = MathHelper.sin(f) * 0.2F;
this.squid.setMovementVector(f1, f2, f3);
}
}
示例4: updateTask
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
* Updates the task
*/
public void updateTask()
{
int i = this.squid.getAge();
if (i > 100)
{
this.squid.setMovementVector(0.0F, 0.0F, 0.0F);
}
else if (this.squid.getRNG().nextInt(50) == 0 || !this.squid.inWater || !this.squid.hasMovementVector())
{
float f = this.squid.getRNG().nextFloat() * ((float)Math.PI * 2F);
float f1 = MathHelper.cos(f) * 0.2F;
float f2 = -0.1F + this.squid.getRNG().nextFloat() * 0.2F;
float f3 = MathHelper.sin(f) * 0.2F;
this.squid.setMovementVector(f1, f2, f3);
}
}
示例5: 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.villagerNose.offsetX = 0.0F;
this.villagerNose.offsetY = 0.0F;
this.villagerNose.offsetZ = 0.0F;
float f = 0.01F * (float)(entityIn.getEntityId() % 10);
this.villagerNose.rotateAngleX = MathHelper.sin((float)entityIn.ticksExisted * f) * 4.5F * 0.017453292F;
this.villagerNose.rotateAngleY = 0.0F;
this.villagerNose.rotateAngleZ = MathHelper.cos((float)entityIn.ticksExisted * f) * 2.5F * 0.017453292F;
if (this.holdingItem)
{
this.villagerNose.rotateAngleX = -0.9F;
this.villagerNose.offsetZ = -0.09375F;
this.villagerNose.offsetY = 0.1875F;
}
}
示例6: calcSunriseSunsetColors
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
* Returns array with sunrise/sunset colors
*/
@Nullable
@SideOnly(Side.CLIENT)
public float[] calcSunriseSunsetColors(float celestialAngle, float partialTicks)
{
float f = 0.4F;
float f1 = MathHelper.cos(celestialAngle * ((float)Math.PI * 2F)) - 0.0F;
float f2 = -0.0F;
if (f1 >= -0.4F && f1 <= 0.4F)
{
float f3 = (f1 - -0.0F) / 0.4F * 0.5F + 0.5F;
float f4 = 1.0F - (1.0F - MathHelper.sin(f3 * (float)Math.PI)) * 0.99F;
f4 = f4 * f4;
this.colorsSunriseSunset[0] = f3 * 0.3F + 0.7F;
this.colorsSunriseSunset[1] = f3 * f3 * 0.7F + 0.2F;
this.colorsSunriseSunset[2] = f3 * f3 * 0.0F + 0.2F;
this.colorsSunriseSunset[3] = f4;
return this.colorsSunriseSunset;
}
else
{
return null;
}
}
示例7: 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();
}
示例8: 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;
}
示例9: preRenderCallback
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
* Allows the render to do state modifications necessary before the model is rendered.
*/
protected void preRenderCallback(EntityCreeper entitylivingbaseIn, float partialTickTime)
{
float f = entitylivingbaseIn.getCreeperFlashIntensity(partialTickTime);
float f1 = 1.0F + MathHelper.sin(f * 100.0F) * f * 0.01F;
f = MathHelper.clamp_float(f, 0.0F, 1.0F);
f = f * f;
f = f * f;
float f2 = (1.0F + f * 0.4F) * f1;
float f3 = (1.0F + f * 0.1F) / f1;
GlStateManager.scale(f2, f3, f2);
}
示例10: 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)
{
for (int i = 0; i < this.bodyParts.length; ++i)
{
this.bodyParts[i].rotateAngleY = MathHelper.cos(ageInTicks * 0.9F + (float)i * 0.15F * (float)Math.PI) * (float)Math.PI * 0.01F * (float)(1 + Math.abs(i - 2));
this.bodyParts[i].rotationPointX = MathHelper.sin(ageInTicks * 0.9F + (float)i * 0.15F * (float)Math.PI) * (float)Math.PI * 0.1F * (float)Math.abs(i - 2);
}
}
示例11: setHeadingFromThrower
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
* Sets throwable heading based on an entity that's throwing it
*/
public void setHeadingFromThrower(Entity entityThrower, float rotationPitchIn, float rotationYawIn, float pitchOffset, float velocity, float inaccuracy)
{
float f = -MathHelper.sin(rotationYawIn * 0.017453292F) * MathHelper.cos(rotationPitchIn * 0.017453292F);
float f1 = -MathHelper.sin((rotationPitchIn + pitchOffset) * 0.017453292F);
float f2 = MathHelper.cos(rotationYawIn * 0.017453292F) * MathHelper.cos(rotationPitchIn * 0.017453292F);
this.setThrowableHeading((double)f, (double)f1, (double)f2, velocity, inaccuracy);
this.motionX += entityThrower.motionX;
this.motionZ += entityThrower.motionZ;
if (!entityThrower.onGround)
{
this.motionY += entityThrower.motionY;
}
}
示例12: transformModelCount
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
private int transformModelCount(EntityItem itemIn, double p_177077_2_, double p_177077_4_, double p_177077_6_, float p_177077_8_, IBakedModel p_177077_9_)
{
ItemStack itemstack = itemIn.getEntityItem();
Item item = itemstack.getItem();
if (item == null)
{
return 0;
}
else
{
boolean flag = p_177077_9_.isGui3d();
int i = this.getModelCount(itemstack);
float f = 0.25F;
float f1 = shouldBob() ? MathHelper.sin(((float)itemIn.getAge() + p_177077_8_) / 10.0F + itemIn.hoverStart) * 0.1F + 0.1F : 0;
float f2 = p_177077_9_.getItemCameraTransforms().getTransform(ItemCameraTransforms.TransformType.GROUND).scale.y;
GlStateManager.translate((float)p_177077_2_, (float)p_177077_4_ + f1 + 0.25F * f2, (float)p_177077_6_);
if (flag || this.renderManager.options != null)
{
float f3 = (((float)itemIn.getAge() + p_177077_8_) / 20.0F + itemIn.hoverStart) * (180F / (float)Math.PI);
GlStateManager.rotate(f3, 0.0F, 1.0F, 0.0F);
}
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
return i;
}
}
示例13: updateTask
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
@Override
public void updateTask() {
// System.out.println("Tick");
EntityLivingBase target = this.host.getAttackTarget();
if ((target != null && target.deathTime > 0) || host.deathTime > 0) {
this.resetTask();
return;
}
if (target == null)
return;
/*
* if(!this.host.cloak.getTagCompound().getBoolean("Active")){
*
* ((ItemCloak)this.host.cloak.getItem()).setCloak(true,
* this.host.cloak, this.host, this.host.world); }
*/
if (this.host.getAttackTarget() != null && this.host.getAttackTarget() instanceof EntityPlayer)
ItemDisguiseKit.startDisguise(this.host, this.host.world, "M:"+TF2weapons.animals.get(this.host.getRNG().nextInt(TF2weapons.animals.size())));
else
ItemDisguiseKit.startDisguise(this.host, this.host.world, "T:Engineer");
// this.host.getNavigator().tryMoveToEntityLiving(target, 1);
this.host.getLookHelper().setLookPosition(target.posX, target.posY + target.getEyeHeight(), target.posZ, 90,
90.0F);
float x = -MathHelper.sin(target.rotationYaw / 180.0F * (float) Math.PI);
float z = MathHelper.cos(target.rotationYaw / 180.0F * (float) Math.PI);
host.getNavigator().tryMoveToXYZ(target.posX - x * 2, target.posY, target.posZ - z * 2, 1);
// this.host.getLookHelper().setLookPosition(target.posX+x*2,target.posY+target.getEyeHeight(),target.posZ+z*2,
// 90f, 90.0F);
}
示例14: doRender
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
* Renders the desired {@code T} type Entity.
*/
public void doRender(T entity, double x, double y, double z, float entityYaw, float partialTicks)
{
this.bindEntityTexture(entity);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
GlStateManager.pushMatrix();
GlStateManager.disableLighting();
GlStateManager.translate((float)x, (float)y, (float)z);
GlStateManager.rotate(entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * partialTicks - 90.0F, 0.0F, 1.0F, 0.0F);
GlStateManager.rotate(entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * partialTicks, 0.0F, 0.0F, 1.0F);
Tessellator tessellator = Tessellator.getInstance();
VertexBuffer vertexbuffer = tessellator.getBuffer();
GlStateManager.enableRescaleNormal();
float f9 = (float)entity.arrowShake - partialTicks;
if (f9 > 0.0F)
{
float f10 = -MathHelper.sin(f9 * 3.0F) * f9;
GlStateManager.rotate(f10, 0.0F, 0.0F, 1.0F);
}
GlStateManager.rotate(45.0F, 1.0F, 0.0F, 0.0F);
GlStateManager.scale(0.05625F, 0.05625F, 0.05625F);
GlStateManager.translate(-4.0F, 0.0F, 0.0F);
if (this.renderOutlines)
{
GlStateManager.enableColorMaterial();
GlStateManager.enableOutlineMode(this.getTeamColor(entity));
}
GlStateManager.glNormal3f(0.05625F, 0.0F, 0.0F);
vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX);
vertexbuffer.pos(-7.0D, -2.0D, -2.0D).tex(0.0D, 0.15625D).endVertex();
vertexbuffer.pos(-7.0D, -2.0D, 2.0D).tex(0.15625D, 0.15625D).endVertex();
vertexbuffer.pos(-7.0D, 2.0D, 2.0D).tex(0.15625D, 0.3125D).endVertex();
vertexbuffer.pos(-7.0D, 2.0D, -2.0D).tex(0.0D, 0.3125D).endVertex();
tessellator.draw();
GlStateManager.glNormal3f(-0.05625F, 0.0F, 0.0F);
vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX);
vertexbuffer.pos(-7.0D, 2.0D, -2.0D).tex(0.0D, 0.15625D).endVertex();
vertexbuffer.pos(-7.0D, 2.0D, 2.0D).tex(0.15625D, 0.15625D).endVertex();
vertexbuffer.pos(-7.0D, -2.0D, 2.0D).tex(0.15625D, 0.3125D).endVertex();
vertexbuffer.pos(-7.0D, -2.0D, -2.0D).tex(0.0D, 0.3125D).endVertex();
tessellator.draw();
for (int j = 0; j < 4; ++j)
{
GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F);
GlStateManager.glNormal3f(0.0F, 0.0F, 0.05625F);
vertexbuffer.begin(7, DefaultVertexFormats.POSITION_TEX);
vertexbuffer.pos(-8.0D, -2.0D, 0.0D).tex(0.0D, 0.0D).endVertex();
vertexbuffer.pos(8.0D, -2.0D, 0.0D).tex(0.5D, 0.0D).endVertex();
vertexbuffer.pos(8.0D, 2.0D, 0.0D).tex(0.5D, 0.15625D).endVertex();
vertexbuffer.pos(-8.0D, 2.0D, 0.0D).tex(0.0D, 0.15625D).endVertex();
tessellator.draw();
}
if (this.renderOutlines)
{
GlStateManager.disableOutlineMode();
GlStateManager.disableColorMaterial();
}
GlStateManager.disableRescaleNormal();
GlStateManager.enableLighting();
GlStateManager.popMatrix();
super.doRender(entity, x, y, z, entityYaw, partialTicks);
}
示例15: moveEntityWithHeading
import net.minecraft.util.math.MathHelper; //导入方法依赖的package包/类
/**
* Moves the entity based on the specified heading.
*/
public void moveEntityWithHeading(float strafe, float forward)
{
Entity entity = this.getPassengers().isEmpty() ? null : (Entity)this.getPassengers().get(0);
if (this.isBeingRidden() && this.canBeSteered())
{
this.rotationYaw = entity.rotationYaw;
this.prevRotationYaw = this.rotationYaw;
this.rotationPitch = entity.rotationPitch * 0.5F;
this.setRotation(this.rotationYaw, this.rotationPitch);
this.renderYawOffset = this.rotationYaw;
this.rotationYawHead = this.rotationYaw;
this.stepHeight = 1.0F;
this.jumpMovementFactor = this.getAIMoveSpeed() * 0.1F;
if (this.boosting && this.boostTime++ > this.totalBoostTime)
{
this.boosting = false;
}
if (this.canPassengerSteer())
{
float f = (float)this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).getAttributeValue() * 0.225F;
if (this.boosting)
{
f += f * 1.15F * MathHelper.sin((float)this.boostTime / (float)this.totalBoostTime * (float)Math.PI);
}
this.setAIMoveSpeed(f);
super.moveEntityWithHeading(0.0F, 1.0F);
}
else
{
this.motionX = 0.0D;
this.motionY = 0.0D;
this.motionZ = 0.0D;
}
this.prevLimbSwingAmount = this.limbSwingAmount;
double d1 = this.posX - this.prevPosX;
double d0 = this.posZ - this.prevPosZ;
float f1 = MathHelper.sqrt(d1 * d1 + d0 * d0) * 4.0F;
if (f1 > 1.0F)
{
f1 = 1.0F;
}
this.limbSwingAmount += (f1 - this.limbSwingAmount) * 0.4F;
this.limbSwing += this.limbSwingAmount;
}
else
{
this.stepHeight = 0.5F;
this.jumpMovementFactor = 0.02F;
super.moveEntityWithHeading(strafe, forward);
}
}