本文整理了Java中net.minecraft.util.math.MathHelper.sin()
方法的一些代码示例,展示了MathHelper.sin()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MathHelper.sin()
方法的具体详情如下:
包路径:net.minecraft.util.math.MathHelper
类名称:MathHelper
方法名:sin
暂无
代码示例来源:origin: Vazkii/Botania
private double func_82213_w(int p_82213_1_)
{
if (p_82213_1_ <= 0)
{
return posZ;
}
else
{
float f = (renderYawOffset + 180 * (p_82213_1_ - 1)) / 180.0F * (float)Math.PI;
float f1 = MathHelper.sin(f);
return posZ + f1 * 1.3D;
}
}
}
代码示例来源:origin: Vazkii/Botania
/**
* 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;
}
}
代码示例来源:origin: Vazkii/Botania
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);
}
代码示例来源:origin: Vazkii/Botania
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);
}
代码示例来源:origin: Vazkii/Botania
private static void renderItemInFirstPerson(AbstractClientPlayer player, float partialTicks, float interpPitch, EnumHand hand, float swingProgress, ItemStack stack, float equipProgress) throws Throwable {
// Cherry picked from ItemRenderer.renderItemInFirstPerson
boolean flag = hand == EnumHand.MAIN_HAND;
EnumHandSide enumhandside = flag ? player.getPrimaryHand() : player.getPrimaryHand().opposite();
GlStateManager.pushMatrix();
boolean flag1 = enumhandside == EnumHandSide.RIGHT;
float f = -0.4F * MathHelper.sin(MathHelper.sqrt(swingProgress) * (float)Math.PI);
float f1 = 0.2F * MathHelper.sin(MathHelper.sqrt(swingProgress) * ((float)Math.PI * 2F));
float f2 = -0.2F * MathHelper.sin(swingProgress * (float)Math.PI);
int i = flag1 ? 1 : -1;
GlStateManager.translate(i * f, f1, f2);
transformSideFirstPerson(enumhandside, equipProgress);
transformFirstPerson(enumhandside, swingProgress);
doRender(enumhandside, partialTicks, stack);
GlStateManager.popMatrix();
}
代码示例来源:origin: Vazkii/Botania
private static void transformFirstPerson(EnumHandSide p_187453_1_, float p_187453_2_)
{
int i = p_187453_1_ == EnumHandSide.RIGHT ? 1 : -1;
// Botania - added
GlStateManager.translate(p_187453_1_ == EnumHandSide.RIGHT ? 0.2F : 0.52F, -0.125F, p_187453_1_ == EnumHandSide.RIGHT ? 0.6F : 0.25F);
GlStateManager.rotate(p_187453_1_ == EnumHandSide.RIGHT ? 60F : 120F, 0F, 1F, 0F);
GlStateManager.rotate(30F, 0F, 0F, -1F);
// End add
float f = MathHelper.sin(p_187453_2_ * p_187453_2_ * (float)Math.PI);
GlStateManager.rotate(i * (45.0F + f * -20.0F), 0.0F, 1.0F, 0.0F);
float f1 = MathHelper.sin(MathHelper.sqrt(p_187453_2_) * (float)Math.PI);
GlStateManager.rotate(i * f1 * -20.0F, 0.0F, 0.0F, 1.0F);
GlStateManager.rotate(f1 * -80.0F, 1.0F, 0.0F, 0.0F);
GlStateManager.rotate(i * -45.0F, 0.0F, 1.0F, 0.0F);
}
代码示例来源:origin: Vazkii/Botania
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);
}
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
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 );
}
代码示例来源:origin: Vazkii/Botania
/**
* 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);
}
代码示例来源:origin: Vazkii/Botania
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());
}
代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2
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;
final float f8 = f3 * f5;
代码示例来源:origin: Vazkii/Botania
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);
}
代码示例来源:origin: Vazkii/Botania
@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;
}
}
}
}
代码示例来源:origin: PenguinSquad/Harvest-Festival
@Override
protected float handleRotationFloat(EntityDarkChick livingBase, float partialTicks) {
this.shadowSize = 0.3F;
float f = livingBase.oFlap + (livingBase.wingRotation - livingBase.oFlap) * partialTicks;
float f1 = livingBase.oFlapSpeed + (livingBase.destPos - livingBase.oFlapSpeed) * partialTicks;
return (MathHelper.sin(f) + 1.0F) * f1;
}
}
代码示例来源:origin: Vazkii/Botania
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);
}
代码示例来源:origin: SleepyTrousers/EnderIO
private void calculateWingAngle(float partialTicks) {
float flapComletion = prevWingRotation + (wingRotation - prevWingRotation) * partialTicks;
float onGroundTimerThing = prevDestPos + (destPos - prevDestPos) * partialTicks;
wingAngle = (MathHelper.sin(flapComletion) + 1.0F) * onGroundTimerThing;
if (onGround) {
wingAngle = (float) Math.toRadians(3);
}
}
代码示例来源:origin: WayofTime/BloodMagic
@SideOnly(Side.CLIENT)
public float getHeadRotationAngleX(float partialTick) {
if (this.sheepTimer > 4 && this.sheepTimer <= 36) {
float f = ((float) (this.sheepTimer - 4) - partialTick) / 32.0F;
return ((float) Math.PI / 5F) + ((float) Math.PI * 7F / 100F) * MathHelper.sin(f * 28.7F);
} else {
return this.sheepTimer > 0 ? ((float) Math.PI / 5F) : this.rotationPitch * 0.017453292F;
}
}
代码示例来源:origin: P3pp3rF1y/AncientWarfare2
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);
}
}
代码示例来源:origin: Vazkii/Botania
GlStateManager.pushMatrix();
GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F);
GlStateManager.rotate(MathHelper.sin(world.getCelestialAngleRadians(partialTicks)) < 0.0F ? 180.0F : 0.0F, 0.0F, 0.0F, 1.0F);
GlStateManager.rotate(90.0F, 0.0F, 0.0F, 1.0F);
float f6 = afloat[0];
float f12 = MathHelper.sin(f21);
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();
代码示例来源:origin: Azanor/Baubles
/**
* 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);
}
内容来源于网络,如有侵权,请联系作者删除!