Java Code Examples for net.minecraft.util.MathHelper#cos()
The following examples show how to use
net.minecraft.util.MathHelper#cos() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: mocreaturesdev File: MoCEntityTurtle.java License: GNU General Public License v3.0 | 6 votes |
@Override protected void jump() { if (isInsideOfMaterial(Material.water)) // super.jump(); { motionY = 0.3D; if (isSprinting()) { float f = rotationYaw * 0.01745329F; motionX -= MathHelper.sin(f) * 0.2F; motionZ += MathHelper.cos(f) * 0.2F; } isAirBorne = true; } }
Example 2
Source Project: Electro-Magic-Tools File: EntityLaser.java License: GNU General Public License v3.0 | 6 votes |
public EntityLaser(World par1World, EntityLivingBase par2EntityLivingBase, float par3) { super(par1World); this.renderDistanceWeight = 10.0D; this.shootingEntity = par2EntityLivingBase; this.setSize(0.5F, 0.5F); this.setLocationAndAngles(par2EntityLivingBase.posX, par2EntityLivingBase.posY + (double) par2EntityLivingBase.getEyeHeight(), par2EntityLivingBase.posZ, par2EntityLivingBase.rotationYaw, par2EntityLivingBase.rotationPitch); this.posX -= (double) (MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI) * 0.16F); this.posY -= 0.10000000149011612D; this.posZ -= (double) (MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI) * 0.16F); this.setPosition(this.posX, this.posY, this.posZ); this.yOffset = 0.0F; this.motionX = (double) (-MathHelper.sin(this.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI)); this.motionZ = (double) (MathHelper.cos(this.rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float) Math.PI)); this.motionY = (double) (-MathHelper.sin(this.rotationPitch / 180.0F * (float) Math.PI)); this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, par3 * 1.5F, 1.0F); }
Example 3
Source Project: LiquidBounce File: SpectreOnGround.java License: GNU General Public License v3.0 | 6 votes |
@Override public void onMove(MoveEvent event) { if(!MovementUtils.isMoving() || mc.thePlayer.movementInput.jump) return; if(speedUp >= 10) { if(mc.thePlayer.onGround) { mc.thePlayer.motionX = 0D; mc.thePlayer.motionZ = 0D; speedUp = 0; } return; } if(mc.thePlayer.onGround && mc.gameSettings.keyBindForward.isKeyDown()) { final float f = mc.thePlayer.rotationYaw * 0.017453292F; mc.thePlayer.motionX -= MathHelper.sin(f) * 0.145F; mc.thePlayer.motionZ += MathHelper.cos(f) * 0.145F; event.setX(mc.thePlayer.motionX); event.setY(0.005); event.setZ(mc.thePlayer.motionZ); speedUp++; } }
Example 4
Source Project: LiquidBounce File: NCPYPort.java License: GNU General Public License v3.0 | 6 votes |
@Override public void onMotion() { if(mc.thePlayer.isOnLadder() || mc.thePlayer.isInWater() || mc.thePlayer.isInLava() || mc.thePlayer.isInWeb || !MovementUtils.isMoving() || mc.thePlayer.isInWater()) return; if(jumps >= 4 && mc.thePlayer.onGround) jumps = 0; if(mc.thePlayer.onGround) { mc.thePlayer.motionY = jumps <= 1 ? 0.42F : 0.4F; float f = mc.thePlayer.rotationYaw * 0.017453292F; mc.thePlayer.motionX -= MathHelper.sin(f) * 0.2F; mc.thePlayer.motionZ += MathHelper.cos(f) * 0.2F; jumps++; }else if(jumps <= 1) mc.thePlayer.motionY = -5D; MovementUtils.strafe(); }
Example 5
Source Project: mocreaturesdev File: MoCModelFly.java License: GNU General Public License v3.0 | 6 votes |
public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, boolean onGround) { //super.setRotationAngles(f, f1, f2, f3, f4, f5); float WingRot = MathHelper.cos((f2 * 3.0F)) * 0.7F; RightWing.rotateAngleZ = WingRot; LeftWing.rotateAngleZ = -WingRot; float legMov = 0F; float legMovB = 0F; if (!onGround) { legMov = (f1 * 1.5F); legMovB = legMov; } else { legMov = MathHelper.cos((f * 1.5F) + 3.141593F) * 2.0F * f1; legMovB = MathHelper.cos(f * 1.5F) * 2.0F * f1; } FrontLegs.rotateAngleX = 0.1487144F + legMov; MidLegs.rotateAngleX = 0.5948578F + legMovB; RearLegs.rotateAngleX = 1.070744F + legMov; }
Example 6
Source Project: LiquidBounce File: MixinEntityLivingBase.java License: GNU General Public License v3.0 | 6 votes |
/** * @author CCBlueX */ @Overwrite protected void jump() { final JumpEvent jumpEvent = new JumpEvent(this.getJumpUpwardsMotion()); LiquidBounce.eventManager.callEvent(jumpEvent); if(jumpEvent.isCancelled()) return; this.motionY = jumpEvent.getMotion(); if(this.isPotionActive(Potion.jump)) this.motionY += (double) ((float) (this.getActivePotionEffect(Potion.jump).getAmplifier() + 1) * 0.1F); if(this.isSprinting()) { float f = this.rotationYaw * 0.017453292F; this.motionX -= (double) (MathHelper.sin(f) * 0.2F); this.motionZ += (double) (MathHelper.cos(f) * 0.2F); } this.isAirBorne = true; }
Example 7
Source Project: mocreaturesdev File: MoCModelMouse.java License: GNU General Public License v3.0 | 6 votes |
public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5) { Head.rotateAngleX = -(f4 / 57.29578F); Head.rotateAngleY = f3 / 57.29578F; EarR.rotateAngleX = Head.rotateAngleX; EarR.rotateAngleY = Head.rotateAngleY; EarL.rotateAngleX = Head.rotateAngleX; EarL.rotateAngleY = Head.rotateAngleY; WhiskerR.rotateAngleX = Head.rotateAngleX; WhiskerR.rotateAngleY = Head.rotateAngleY; WhiskerL.rotateAngleX = Head.rotateAngleX; WhiskerL.rotateAngleY = Head.rotateAngleY; FrontL.rotateAngleX = MathHelper.cos(f * 0.6662F) * 0.6F * f1; RearL.rotateAngleX = MathHelper.cos((f * 0.6662F) + 3.141593F) * 0.8F * f1; RearR.rotateAngleX = MathHelper.cos(f * 0.6662F) * 0.6F * f1; FrontR.rotateAngleX = MathHelper.cos((f * 0.6662F) + 3.141593F) * 0.8F * f1; Tail.rotateAngleY = FrontL.rotateAngleX * 0.625F; }
Example 8
Source Project: mocreaturesdev File: MoCModelWraith.java License: GNU General Public License v3.0 | 6 votes |
@Override public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity par7Entity) { //super.setRotationAngles(f, f1, f2, f3, f4, f5); float f6 = MathHelper.sin(onGround * 3.141593F); float f7 = MathHelper.sin((1.0F - ((1.0F - onGround) * (1.0F - onGround))) * 3.141593F); bipedRightArm.rotateAngleZ = 0.0F; bipedLeftArm.rotateAngleZ = 0.0F; bipedRightArm.rotateAngleY = -(0.1F - (f6 * 0.6F)); bipedLeftArm.rotateAngleY = 0.1F - (f6 * 0.6F); bipedRightArm.rotateAngleX = -1.570796F; bipedLeftArm.rotateAngleX = -1.570796F; bipedRightArm.rotateAngleX -= (f6 * 1.2F) - (f7 * 0.4F); bipedLeftArm.rotateAngleX -= (f6 * 1.2F) - (f7 * 0.4F); bipedRightArm.rotateAngleZ += (MathHelper.cos(f2 * 0.09F) * 0.05F) + 0.05F; bipedLeftArm.rotateAngleZ -= (MathHelper.cos(f2 * 0.09F) * 0.05F) + 0.05F; bipedRightArm.rotateAngleX += MathHelper.sin(f2 * 0.067F) * 0.05F; bipedLeftArm.rotateAngleX -= MathHelper.sin(f2 * 0.067F) * 0.05F; }
Example 9
Source Project: Chisel-2 File: General.java License: GNU General Public License v2.0 | 6 votes |
public static MovingObjectPosition getMovingObjectPositionFromPlayer(World par1World, EntityPlayer par2EntityPlayer, boolean par3) { float var4 = 1.0F; float var5 = par2EntityPlayer.prevRotationPitch + (par2EntityPlayer.rotationPitch - par2EntityPlayer.prevRotationPitch) * var4; float var6 = par2EntityPlayer.prevRotationYaw + (par2EntityPlayer.rotationYaw - par2EntityPlayer.prevRotationYaw) * var4; double var7 = par2EntityPlayer.prevPosX + (par2EntityPlayer.posX - par2EntityPlayer.prevPosX) * var4; double var9 = par2EntityPlayer.prevPosY + (par2EntityPlayer.posY - par2EntityPlayer.prevPosY) * var4 + 1.62D - par2EntityPlayer.yOffset; double var11 = par2EntityPlayer.prevPosZ + (par2EntityPlayer.posZ - par2EntityPlayer.prevPosZ) * var4; // TODO- 1.7.10 fix? Vec3 var13 = Vec3.createVectorHelper(var7, var9, var11); float var14 = MathHelper.cos(-var6 * 0.017453292F - (float) Math.PI); float var15 = MathHelper.sin(-var6 * 0.017453292F - (float) Math.PI); float var16 = -MathHelper.cos(-var5 * 0.017453292F); float var17 = MathHelper.sin(-var5 * 0.017453292F); float var18 = var15 * var16; float var20 = var14 * var16; double var21 = 5.0D; if (par2EntityPlayer instanceof EntityPlayerMP) { var21 = ((EntityPlayerMP) par2EntityPlayer).theItemInWorldManager.getBlockReachDistance(); } Vec3 var23 = var13.addVector(var18 * var21, var17 * var21, var20 * var21); return par1World.rayTraceBlocks(var13, var23, par3); }
Example 10
Source Project: mocreaturesdev File: MoCModelBird.java License: GNU General Public License v3.0 | 5 votes |
@Override public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { head.rotateAngleX = -(f4 / 2.0F / 57.29578F); //head.rotateAngleY = f3 / 2.0F / 57.29578F; //fixed SMP bug head.rotateAngleY = f3 / 57.29578F; beak.rotateAngleY = head.rotateAngleY; leftleg.rotateAngleX = MathHelper.cos(f * 0.6662F) * f1; rightleg.rotateAngleX = MathHelper.cos((f * 0.6662F) + 3.141593F) * f1; rwing.rotateAngleZ = f2; lwing.rotateAngleZ = -f2; }
Example 11
Source Project: LiquidBounce File: AACHop3313.java License: GNU General Public License v3.0 | 5 votes |
@Override public void onUpdate() { if (!MovementUtils.isMoving() || mc.thePlayer.isInWater() || mc.thePlayer.isInLava() || mc.thePlayer.isOnLadder() || mc.thePlayer.isRiding() || mc.thePlayer.hurtTime > 0) return; if (mc.thePlayer.onGround && mc.thePlayer.isCollidedVertically) { // MotionXYZ float yawRad = mc.thePlayer.rotationYaw * 0.017453292F; mc.thePlayer.motionX -= MathHelper.sin(yawRad) * 0.202F; mc.thePlayer.motionZ += MathHelper.cos(yawRad) * 0.202F; mc.thePlayer.motionY = 0.405F; LiquidBounce.eventManager.callEvent(new JumpEvent(0.405F)); MovementUtils.strafe(); } else if (mc.thePlayer.fallDistance < 0.31F) { if (BlockUtils.getBlock(mc.thePlayer.getPosition()) instanceof BlockCarpet) // why? return; // Motion XZ mc.thePlayer.jumpMovementFactor = mc.thePlayer.moveStrafing == 0F ? 0.027F : 0.021F; mc.thePlayer.motionX *= 1.001; mc.thePlayer.motionZ *= 1.001; // Motion Y if (!mc.thePlayer.isCollidedHorizontally) mc.thePlayer.motionY -= 0.014999993F; } else mc.thePlayer.jumpMovementFactor = 0.02F; }
Example 12
Source Project: LiquidBounce File: Phase.java License: GNU General Public License v3.0 | 5 votes |
@EventTarget public void onPacket(final PacketEvent event) { final Packet<?> packet = event.getPacket(); if(packet instanceof C03PacketPlayer) { final C03PacketPlayer packetPlayer = (C03PacketPlayer) packet; if(modeValue.get().equalsIgnoreCase("AAC3.5.0")) { final float yaw = (float) MovementUtils.getDirection(); packetPlayer.x = packetPlayer.x - MathHelper.sin(yaw) * 0.00000001D; packetPlayer.z = packetPlayer.z + MathHelper.cos(yaw) * 0.00000001D; } } }
Example 13
Source Project: mocreaturesdev File: MoCModelCricket.java License: GNU General Public License v3.0 | 5 votes |
public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, boolean isFlying) { float legMov = 0F; float legMovB = 0F; float frontLegAdj = 0F; if (isFlying) { float WingRot = MathHelper.cos((f2 * 2.0F)) * 0.7F; RightWing.rotateAngleZ = WingRot; LeftWing.rotateAngleZ = -WingRot; legMov = (f1 * 1.5F); legMovB = legMov; frontLegAdj = 1.4F; } else { legMov = MathHelper.cos((f * 1.5F) + 3.141593F) * 2.0F * f1; legMovB = MathHelper.cos(f * 1.5F) * 2.0F * f1; } AntennaB.rotateAngleX = 2.88506F - legMov; FrontLegs.rotateAngleX = -0.8328009F + frontLegAdj + legMov; MidLegs.rotateAngleX = 1.070744F + legMovB; }
Example 14
Source Project: Hyperium File: RenderUtils.java License: GNU Lesser General Public License v3.0 | 5 votes |
public static void drawFilledCircle(int x, int y, float radius, int color) { GlStateManager.pushAttrib(); GlStateManager.pushMatrix(); GlStateManager.enableBlend(); GlStateManager.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO); GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GlStateManager.disableTexture2D(); GL11.glBegin(GL11.GL_TRIANGLE_FAN); for (int i = 0; i < 50; i++) { float px = x + radius * MathHelper.sin((float) (i * (6.28318530718 / 50))); float py = y + radius * MathHelper.cos((float) (i * (6.28318530718 / 50))); float alpha = (color >> 24 & 255) / 255.0F; float red = (color >> 16 & 255) / 255.0F; float green = (color >> 8 & 255) / 255.0F; float blue = (color & 255) / 255.0F; GL11.glColor4f(red, green, blue, alpha); GL11.glVertex2d(px, py); } GL11.glEnd(); GlStateManager.enableTexture2D(); GlStateManager.disableBlend(); GlStateManager.popAttrib(); GlStateManager.popMatrix(); GlStateManager.bindTexture(0); GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); }
Example 15
Source Project: mocreaturesdev File: MoCModelFirefly.java License: GNU General Public License v3.0 | 5 votes |
public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, boolean isFlying) { //super.setRotationAngles(f, f1, f2, f3, f4, f5); //bipedRightArm.rotateAngleX = MathHelper.cos((f * 0.6662F) + 3.141593F) * 2.0F * f1 * 0.5F; //bipedLeftArm.rotateAngleX = MathHelper.cos(f * 0.6662F) * 2.0F * f1 * 0.5F; float legMov = 0F; float legMovB = 0F; float frontLegAdj = 0F; if (isFlying) { float WingRot = MathHelper.cos((f2 * 1.8F)) * 0.8F; RightWing.rotateAngleZ = WingRot; LeftWing.rotateAngleZ = -WingRot; legMov = (f1 * 1.5F); legMovB = legMov; frontLegAdj = 1.4F; } else { legMov = MathHelper.cos((f * 1.5F) + 3.141593F) * 2.0F * f1; legMovB = MathHelper.cos(f * 1.5F) * 2.0F * f1; } FrontLegs.rotateAngleX = -0.8328009F + frontLegAdj + legMov; MidLegs.rotateAngleX = 1.070744F + legMovB; RearLegs.rotateAngleX = 1.249201F + legMov; }
Example 16
Source Project: mocreaturesdev File: MoCModelFox.java License: GNU General Public License v3.0 | 5 votes |
public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5) { Head.rotateAngleY = f3 / 57.29578F; Head.rotateAngleX = f4 / 57.29578F; Snout.rotateAngleY = Head.rotateAngleY;//f3 / 57.29578F; Snout.rotateAngleX = Head.rotateAngleX;//f4 / 57.29578F; //Snout.rotationPointX = 0.0F + ((f3 / 57.29578F) * 0.8F); Ears.rotateAngleY = Head.rotateAngleY;//f3 / 57.29578F; Ears.rotateAngleX = Head.rotateAngleX;//f4 / 57.29578F; //Ears.rotationPointX = 0.0F + ((f3 / 57.29578F) * 2.5F); Leg1.rotateAngleX = MathHelper.cos(f * 0.6662F) * 1.4F * f1; Leg2.rotateAngleX = MathHelper.cos((f * 0.6662F) + 3.141593F) * 1.4F * f1; Leg3.rotateAngleX = MathHelper.cos((f * 0.6662F) + 3.141593F) * 1.4F * f1; Leg4.rotateAngleX = MathHelper.cos(f * 0.6662F) * 1.4F * f1; }
Example 17
Source Project: Et-Futurum File: EntityTippedArrow.java License: The Unlicense | 5 votes |
@Override public void readSpawnData(ByteBuf buffer) { rotationYaw = buffer.readFloat(); shootingEntity = worldObj.getEntityByID(buffer.readInt()); motionX = buffer.readDouble(); motionY = buffer.readDouble(); motionZ = buffer.readDouble(); posX -= MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) * 0.16F; posY -= 0.10000000149011612D; posZ -= MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) * 0.16F; effect = new PotionEffect(buffer.readInt(), buffer.readInt(), buffer.readInt()); }
Example 18
Source Project: mocreaturesdev File: MoCModelDeer.java License: GNU General Public License v3.0 | 5 votes |
public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5) { Leg1.rotateAngleX = MathHelper.cos(f * 0.6662F) * 1.4F * f1; Leg2.rotateAngleX = MathHelper.cos((f * 0.6662F) + 3.141593F) * 1.4F * f1; Leg3.rotateAngleX = MathHelper.cos((f * 0.6662F) + 3.141593F) * 1.4F * f1; Leg4.rotateAngleX = MathHelper.cos(f * 0.6662F) * 1.4F * f1; }
Example 19
Source Project: mocreaturesdev File: MoCModelKitty.java License: GNU General Public License v3.0 | 4 votes |
public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5) { bipedHead.rotateAngleY = f3 / 57.29578F; bipedHead.rotateAngleX = f4 / 57.29578F; for (int i = 0; i < 9; i++) { bipedHeadParts[i].rotateAngleY = bipedHead.rotateAngleY; bipedHeadParts[i].rotateAngleX = bipedHead.rotateAngleX; } bipedHeadwear.rotateAngleY = bipedHead.rotateAngleY; bipedHeadwear.rotateAngleX = bipedHead.rotateAngleX; bipedRightArm.rotateAngleX = MathHelper.cos((f * 0.6662F) + 3.141593F) * 2.0F * f1 * 0.5F; bipedLeftArm.rotateAngleX = MathHelper.cos(f * 0.6662F) * 2.0F * f1 * 0.5F; bipedRightArm.rotateAngleZ = 0.0F; bipedLeftArm.rotateAngleZ = 0.0F; bipedRightLeg.rotateAngleX = MathHelper.cos(f * 0.6662F) * 1.4F * f1; bipedLeftLeg.rotateAngleX = MathHelper.cos((f * 0.6662F) + 3.141593F) * 1.4F * f1; bipedRightLeg.rotateAngleY = 0.0F; bipedLeftLeg.rotateAngleY = 0.0F; if (heldItemLeft != 0) { bipedLeftArm.rotateAngleX = (bipedLeftArm.rotateAngleX * 0.5F) - 0.3141593F; } if (heldItemRight != 0) { bipedRightArm.rotateAngleX = (bipedRightArm.rotateAngleX * 0.5F) - 0.3141593F; } if (isSwinging) { bipedRightArm.rotateAngleX = -2F + swingProgress; bipedRightArm.rotateAngleY = 2.25F - (swingProgress * 2.0F); } else { bipedRightArm.rotateAngleY = 0.0F; } bipedLeftArm.rotateAngleY = 0.0F; bipedTail.rotateAngleX = -0.5F; bipedTail.rotateAngleZ = bipedLeftLeg.rotateAngleX * 0.625F; }
Example 20
Source Project: mocreaturesdev File: MoCModelRay.java License: GNU General Public License v3.0 | 4 votes |
public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5) { //super.setRotationAngles(f, f1, f2, f3, f4, f5); float rotF = MathHelper.cos(f * 0.6662F) * 1.5F * f1; float f6 = 20F; Tail.rotateAngleY = rotF;//MathHelper.cos(f * 0.6662F) * 0.7F * f1; RWingA.rotateAngleZ = rotF; LWingA.rotateAngleZ = -rotF; rotF += (rotF / f6); RWingB.rotateAngleZ = rotF; LWingB.rotateAngleZ = -rotF; rotF += (rotF / f6); RWingC.rotateAngleZ = rotF; LWingC.rotateAngleZ = -rotF; rotF += (rotF / f6); RWingD.rotateAngleZ = rotF; LWingD.rotateAngleZ = -rotF; rotF += (rotF / f6); RWingE.rotateAngleZ = rotF; LWingE.rotateAngleZ = -rotF; rotF += (rotF / f6); RWingF.rotateAngleZ = rotF; LWingF.rotateAngleZ = -rotF; rotF += (rotF / f6); RWingG.rotateAngleZ = rotF; LWingG.rotateAngleZ = -rotF; if (attacking) { Tail.rotateAngleX = 0.5F; } else { Tail.rotateAngleX = 0F; } }