private double func_82214_u(int p_82214_1_) { if (p_82214_1_ <= 0) { return posX; } else { float f = (renderYawOffset + 180 * (p_82214_1_ - 1)) / 180.0F * (float)Math.PI; float f1 = MathHelper.cos(f); return posX + f1 * 1.3D; } }
@Override public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { super.setRotationAngles(f, f1, f2, f3, f4, f5, entity); rightWingT.rotateAngleY = -(MathHelper.cos(f2 * 1.7F) * (float)Math.PI * 0.5F); leftWingT.rotateAngleY = MathHelper.cos(f2 * 1.7F) * (float)Math.PI * 0.5F; rightWingB.rotateAngleY = -(MathHelper.cos(f2 * 1.7F) * (float)Math.PI * 0.25F); leftWingB.rotateAngleY = MathHelper.cos(f2 * 1.7F) * (float)Math.PI * 0.25F; }
/** * Sets throwable heading based on an entity that's throwing it */ public void shoot(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.shoot((double)f, (double)f1, (double)f2, velocity, inaccuracy); this.motionX += entityThrower.motionX; this.motionZ += entityThrower.motionZ; if (!entityThrower.onGround) { this.motionY += entityThrower.motionY; } }
public EntityManaBurst(EntityPlayer player, EnumHand hand) { this(player.world); setBurstSourceCoords(new BlockPos(0, -1, 0)); setLocationAndAngles(player.posX, player.posY + player.getEyeHeight(), player.posZ, player.rotationYaw + 180, -player.rotationPitch); posX -= (hand == EnumHand.OFF_HAND ? -1 : 1) * MathHelper.cos((rotationYaw + 180) / 180.0F * (float) Math.PI) * 0.16F; posY -= 0.10000000149011612D; posZ -= (hand == EnumHand.OFF_HAND ? -1 : 1) * MathHelper.sin((rotationYaw + 180) / 180.0F * (float) Math.PI) * 0.16F; setPosition(posX, posY, posZ); float f = 0.4F; double mx = MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI) * f / 2D; double mz = -(MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI) * f) / 2D; double my = MathHelper.sin(rotationPitch / 180.0F * (float) Math.PI) * f / 2D; setMotion(mx, my, mz); }
public static RayTraceResult raytraceFromEntity(World worldIn, Entity playerIn, boolean useLiquids, double range) { 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 = range; // Botania - use custom range param, don't limit to reach distance /*if (playerIn instanceof net.minecraft.entity.player.EntityPlayerMP) { d3 = ((net.minecraft.entity.player.EntityPlayerMP)playerIn).interactionManager.getBlockReachDistance(); }*/ Vec3d vec3d1 = vec3d.add((double)f6 * d3, (double)f5 * d3, (double)f7 * d3); return worldIn.rayTraceBlocks(vec3d, vec3d1, useLiquids, !useLiquids, false); }
protected RayTraceResult raytraceFromEntity(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.add((double) f6 * d3, (double) f5 * d3, (double) f7 * d3); return worldIn.rayTraceBlocks(vec3d, vec3d1, useLiquids, !useLiquids, false); }
public static LookDirection getPlayerRay( final EntityPlayer playerIn, final float eyeOffset ) { double reachDistance = 5.0d; final double x = playerIn.prevPosX + ( playerIn.posX - playerIn.prevPosX ); final double y = playerIn.prevPosY + ( playerIn.posY - playerIn.prevPosY ) + playerIn.getEyeHeight(); final double z = playerIn.prevPosZ + ( playerIn.posZ - playerIn.prevPosZ ); final float playerPitch = playerIn.prevRotationPitch + ( playerIn.rotationPitch - playerIn.prevRotationPitch ); final float playerYaw = playerIn.prevRotationYaw + ( playerIn.rotationYaw - playerIn.prevRotationYaw ); final float yawRayX = MathHelper.sin( -playerYaw * 0.017453292f - (float) Math.PI ); final float yawRayZ = MathHelper.cos( -playerYaw * 0.017453292f - (float) Math.PI ); final float pitchMultiplier = -MathHelper.cos( -playerPitch * 0.017453292F ); final float eyeRayY = MathHelper.sin( -playerPitch * 0.017453292F ); final float eyeRayX = yawRayX * pitchMultiplier; final float eyeRayZ = yawRayZ * pitchMultiplier; if( playerIn instanceof EntityPlayerMP ) { reachDistance = ( (EntityPlayerMP) playerIn ).interactionManager.getBlockReachDistance(); } final Vec3d from = new Vec3d( x, y, z ); final Vec3d to = from.addVector( eyeRayX * reachDistance, eyeRayY * reachDistance, eyeRayZ * reachDistance ); return new LookDirection( from, to ); }
/** * Shifts the render for a bauble correctly to the head, including sneaking rotation. * Use for renders under {@link RenderType#HEAD}. */ public static void translateToHeadLevel(EntityPlayer player) { GlStateManager.translate(0, -player.getDefaultEyeHeight(), 0); if (player.isSneaking()) GlStateManager.translate(0.25F * MathHelper.sin(player.rotationPitch * (float) Math.PI / 180), 0.25F * MathHelper.cos(player.rotationPitch * (float) Math.PI / 180), 0F); }
public EntityManaBurst(IManaSpreader spreader, boolean fake) { this(((TileEntity)spreader).getWorld()); TileEntity tile = (TileEntity) spreader; this.fake = fake; setBurstSourceCoords(tile.getPos()); setLocationAndAngles(tile.getPos().getX() + 0.5, tile.getPos().getY() + 0.5, tile.getPos().getZ() + 0.5, 0, 0); rotationYaw = -(spreader.getRotationX() + 90F); rotationPitch = spreader.getRotationY(); float f = 0.4F; double mx = MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI) * f / 2D; double mz = -(MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI) * f) / 2D; double my = MathHelper.sin(rotationPitch / 180.0F * (float) Math.PI) * f / 2D; setMotion(mx, my, mz); }
double offY = MathHelper.cos( (float) ( Math.PI / 2.0f + p.rotationPitch * 0.017453292F ) ); double offZ = rX;
private void emitParticles(ItemStack stack, IManaSpreader spreader, boolean redstone) { float rotationYaw = -(spreader.getRotationX() + 90F); float rotationPitch = spreader.getRotationY(); // Lots of EntityThrowable copypasta float f = 0.3F; float mx = (float) (MathHelper.sin(rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI) * f / 2D); float mz = (float) (-(MathHelper.cos(rotationYaw / 180.0F * (float) Math.PI) * MathHelper.cos(rotationPitch / 180.0F * (float) Math.PI) * f) / 2D); float my = (float) (MathHelper.sin(rotationPitch / 180.0F * (float) Math.PI) * f / 2D); int storedColor = ItemLens.getStoredColor(stack); int hex = -1; TileEntity tile = (TileEntity) spreader; if(storedColor == 16) { hex = Color.HSBtoRGB(tile.getWorld().getTotalWorldTime() * 2 % 360 / 360F, 1F, 1F); } else if(storedColor >= 0) { hex = EnumDyeColor.byMetadata(storedColor).colorValue; } float r = ((hex & 0xFF0000) >> 16) / 255F; float g = ((hex & 0xFF00) >> 8) / 255F; float b = (hex & 0xFF) / 255F; Botania.proxy.wispFX(tile.getPos().getX() + 0.5, tile.getPos().getY() + 0.5, tile.getPos().getZ() + 0.5, r, g, b, 0.4F, mx, my, mz); }
private static void dodge(EntityPlayer player, boolean left) { if(player.capabilities.isFlying || !player.onGround || player.moveForward > 0.2 || player.moveForward < -0.2) return; float yaw = player.rotationYaw; float x = MathHelper.sin(-yaw * 0.017453292F - (float) Math.PI); float z = MathHelper.cos(-yaw * 0.017453292F - (float) Math.PI); Vector3 lookVec = new Vector3(x, 0, z); Vector3 sideVec = lookVec.crossProduct(new Vector3(0, left ? 1 : -1, 0)).multiply(1.25); player.motionX = sideVec.x; player.motionY = sideVec.y; player.motionZ = sideVec.z; PacketHandler.sendToServer(new PacketDodge()); }
final double d2 = p.prevPosZ + ( p.posZ - p.prevPosZ ) * f; final Vec3d vec3 = new Vec3d( d0, d1, d2 ); final float f3 = MathHelper.cos( -f2 * 0.017453292F - (float) Math.PI ); final float f4 = MathHelper.sin( -f2 * 0.017453292F - (float) Math.PI ); final float f5 = -MathHelper.cos( -f1 * 0.017453292F ); final float f6 = MathHelper.sin( -f1 * 0.017453292F ); final float f7 = f4 * f5;
@Override public void onUpdate() { super.onUpdate(); if(ticksExisted % 5 == 0) { List<EntitySlime> slimes = supertile.getWorld().getEntitiesWithinAABB(EntitySlime.class, new AxisAlignedBB(supertile.getPos().add(-RANGE, -RANGE, -RANGE), supertile.getPos().add(RANGE + 1, RANGE + 1, RANGE + 1))); for(EntitySlime slime : slimes) { if(slime.getEntityData().getBoolean(TAG_WORLD_SPAWNED) && !slime.isDead) { int size = slime.getSlimeSize(); int mul = (int) Math.pow(2, size); int mana = 1200 * mul; if(!slime.world.isRemote) { slime.setDead(); slime.playSound(size > 1 ? SoundEvents.ENTITY_SLIME_SQUISH : SoundEvents.ENTITY_SMALL_SLIME_SQUISH, 1, 0.02F); this.mana = Math.min(getMaxMana(), this.mana + mana); sync(); } for (int j = 0; j < mul * 8; ++j) { float f = slime.world.rand.nextFloat() * (float)Math.PI * 2.0F; float f1 = slime.world.rand.nextFloat() * 0.5F + 0.5F; float f2 = MathHelper.sin(f) * size * 0.5F * f1; float f3 = MathHelper.cos(f) * size * 0.5F * f1; float f4 = slime.world.rand.nextFloat() * size * 0.5F * f1; slime.world.spawnParticle(EnumParticleTypes.SLIME, slime.posX + f2, slime.getEntityBoundingBox().minY + f4, slime.posZ + f3, 0.0D, 0.0D, 0.0D); } break; } } } }
private void calculatePistonPosition2(float crankAngleRadians, float radius, float length) { float cA = MathHelper.cos(crankAngleRadians); float sA = MathHelper.sin(crankAngleRadians); float pistonPos2 = radius * cA + MathHelper.sqrt(length * length - radius * radius * sA * sA); float bx = sA * radius; float by = cA * radius; float cx = -2f; armAngle2 = (float) Math.atan2(cx - bx, pistonPos2 - by); } }
/** * Returns a value between 0.0F and 1.0F depending on the timer and duration of the animation. This value * starts at 1.0F and ends at 1.0F. The equation used is 0.5 + 0.5 * cos(2 PI * x + sin(2 * PI * x)). It * is smooth. */ public float getAnimationProgressTemporaryInvesed() { float x = 6.28318530718F * this.getAnimationFraction(); return 0.5F + 0.5F * MathHelper.cos(x + MathHelper.sin(x)); } }
public static float calculateLightRatio(World world) { int lightValue = EnumSkyBlock.SKY.defaultLightValue - world.getSkylightSubtracted(); float sunAngle = world.getCelestialAngleRadians(1.0F); if (sunAngle < (float) Math.PI) { sunAngle += (0.0F - sunAngle) * 0.2F; } else { sunAngle += (((float) Math.PI * 2F) - sunAngle) * 0.2F; } lightValue = Math.round(lightValue * MathHelper.cos(sunAngle)); lightValue = MathHelper.clamp(lightValue, 0, 15); return lightValue / 15f; }
public static BlockPos getPositionInOrbit(EntityAmphithere entity, World world, BlockPos orbit, Random rand) { float possibleOrbitRadius = (entity.orbitRadius + 10.0F); float radius = 10; float angle = (0.01745329251F * possibleOrbitRadius); double extraX = (double) (radius * MathHelper.sin((float) (Math.PI + angle))); double extraZ = (double) (radius * MathHelper.cos(angle)); BlockPos radialPos = new BlockPos(entity.posX + extraX, orbit.getY(), entity.posZ + extraZ); //world.setBlockState(radialPos.down(4), Blocks.QUARTZ_BLOCK.getDefaultState()); //world.setBlockState(orbit.down(4), Blocks.GOLD_BLOCK.getDefaultState()); entity.orbitRadius = possibleOrbitRadius; return radialPos; }
float f13 = MathHelper.cos(f21); BufferBuilder.pos(f12 * 120.0F, f13 * 120.0F, -f13 * 40.0F * afloat[3]).color(afloat[0], afloat[1], afloat[2], 0.0F).endVertex();
/** * Shifts the render for a bauble correctly to the head, including sneaking rotation. * Use for renders under {@link RenderType#HEAD}. */ public static void translateToHeadLevel(EntityPlayer player) { GlStateManager.translate(0, -player.getDefaultEyeHeight(), 0); if (player.isSneaking()) GlStateManager.translate(0.25F * MathHelper.sin(player.rotationPitch * (float) Math.PI / 180), 0.25F * MathHelper.cos(player.rotationPitch * (float) Math.PI / 180), 0F); }