net.minecraft.util.math.MathHelper.nextFloat()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(3.1k)|赞(0)|评价(0)|浏览(68)

本文整理了Java中net.minecraft.util.math.MathHelper.nextFloat()方法的一些代码示例,展示了MathHelper.nextFloat()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MathHelper.nextFloat()方法的具体详情如下:
包路径:net.minecraft.util.math.MathHelper
类名称:MathHelper
方法名:nextFloat

MathHelper.nextFloat介绍

暂无

代码示例

代码示例来源:origin: ldtteam/minecolonies

/**
 * Render little splashes around the fishing hook.
 * simulating fish movement.
 *
 * @param worldServer the server side world.
 */
private void renderLittleSplash(@NotNull final WorldServer worldServer)
{
  final double sinYPosition = (double) MathHelper.nextFloat(this.rand, 0.0F, 360.0F) * 0.017453292D;
  final double cosYPosition = MathHelper.nextFloat(this.rand, 25.0F, 60.0F);
  final double bubbleX = this.posX + (Math.sin(sinYPosition) * cosYPosition * 0.1);
  final double increasedYPosition = Math.floor(this.getEntityBoundingBox().minY) + 1.0;
  final double bubbleZ = this.posZ + (Math.cos(sinYPosition) * cosYPosition * 0.1);
  worldServer.spawnParticle(WATER_SPLASH,
   bubbleX,
   increasedYPosition,
   bubbleZ,
   2 + this.rand.nextInt(2),
   SUNKEN_OFFSET,
   0.0,
   SUNKEN_OFFSET,
   0.0);
}

代码示例来源:origin: ldtteam/minecolonies

private void renderBubble(final int fishingProgressStep, @NotNull final WorldServer worldServer)
{
  this.countdownFishNear -= fishingProgressStep;
  double bubbleY = 0.15;
  if (this.countdownFishNear < 20)
  {
    bubbleY = bubbleY + (double) (20 - this.countdownFishNear) * 0.05;
  }
  else if (this.countdownFishNear < 40)
  {
    bubbleY = bubbleY + (double) (40 - this.countdownFishNear) * 0.02;
  }
  else if (this.countdownFishNear < 60)
  {
    bubbleY = bubbleY + (double) (60 - this.countdownFishNear) * 0.01;
  }
  if (this.rand.nextDouble() < bubbleY)
  {
    renderLittleSplash(worldServer);
  }
  if (this.countdownFishNear <= 0)
  {
    this.relativeRotation = MathHelper.nextFloat(this.rand, 0.0F, 360.0F);
    this.countdownFishBites = MathHelper.getInt(this.rand, 20, 80);
  }
}

代码示例来源:origin: PrinceOfAmber/Cyclic

@Override
 protected void processImpact(RayTraceResult mop) {
  if (mop.entityHit != null) {
   float damage = MathHelper.nextFloat(world.rand, DAMAGE_MIN, DAMAGE_MAX);
   mop.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), damage);
  }
  else {
   // drop as item
   UtilItemStack.dropItemStackInWorld(world, mop.getBlockPos(), bullet);
  }
  this.setDead();
 }
}

代码示例来源:origin: PrinceOfAmber/Cyclic

@Override
protected void processImpact(RayTraceResult mop) {
 if (mop.entityHit != null) {
  if (isOwner(mop.entityHit)) {
   //i hit owner, im done
   dropAsItem();
  }
  else {
   float damage = MathHelper.nextFloat(world.rand, DAMAGE_MIN, DAMAGE_MAX);
   mop.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), damage);
   if (mop.entityHit instanceof EntityLivingBase) {
    EntityLivingBase living = (EntityLivingBase) mop.entityHit;
    if (living.isPotionActive(PotionEffectRegistry.STUN) == false) {
     living.addPotionEffect(new PotionEffect(PotionEffectRegistry.STUN, STUN_TICKS, 1));
    }
   }
  }
 }
 else {
  // hit a block or something, go back
  setIsReturning();
 }
}

代码示例来源:origin: PenguinSquad/Harvest-Festival

float f7 = MathHelper.nextFloat(rand, 0.0F, 360.0F) * 0.017453292F;
float f9 = MathHelper.nextFloat(rand, 25.0F, 60.0F);
double d12 = posX + (double) (MathHelper.sin(f7) * f9 * 0.1F);
double d14 = (double) ((float) MathHelper.floor(getEntityBoundingBox().minY) + 1.0F);
fishApproachAngle = MathHelper.nextFloat(rand, 0.0F, 360.0F);
ticksCatchableDelay = MathHelper.getInt(rand, 20, 80);

相关文章