コード例 #1
0
  @Override
  public void onLivingUpdate() {
    if (this.worldObj.provider instanceof WorldProviderOrbit
        && ((WorldProviderOrbit) this.worldObj.provider).doSpinning) {
      ((WorldProviderOrbit) this.worldObj.provider).spinUpdate(this);
    }

    if (this.boundingBox != null && this.boundingBoxBefore == null) {
      this.boundingBoxBefore = this.boundingBox;
      this.boundingBox.setBounds(
          this.boundingBoxBefore.minX + 0.4,
          this.boundingBoxBefore.minY + 0.9,
          this.boundingBoxBefore.minZ + 0.4,
          this.boundingBoxBefore.maxX - 0.4,
          this.boundingBoxBefore.maxY - 0.9,
          this.boundingBoxBefore.maxZ - 0.4);
    } else if (this.boundingBox != null && this.boundingBoxBefore != null) {
      this.boundingBox.setBB(this.boundingBoxBefore);
    }

    super.onLivingUpdate();

    //		// If the player is on the moon, not airbourne and not riding anything
    //		if (this.worldObj != null && this.worldObj.provider instanceof GCMoonWorldProvider &&
    // this.onGround && this.ridingEntity == null)
    //		{
    //			int iPosX = (int)Math.floor(this.posX);
    //			int iPosY = (int)Math.floor(this.posY - 2);
    //			int iPosZ = (int)Math.floor(this.posZ);
    //
    //			// If the block below is the moon block
    //			if (this.worldObj.getBlock(iPosX, iPosY, iPosZ) == GCCoreBlocks.blockMoon)
    //			{
    //				// And is the correct metadata (moon turf)
    //				if (this.worldObj.getBlockMetadata(iPosX, iPosY, iPosZ) == 5)
    //				{
    //					// If it has been long enough since the last step
    //					if (this.distanceSinceLastStep > 0.09)
    //					{
    //						Vector3 pos = new Vector3(this);
    //						// Set the footprint position to the block below and add random number to stop
    // z-fighting
    //						pos.y = MathHelper.floor_double(this.posY - 1) + this.rand.nextFloat() / 100.0F;
    //
    //						// Adjust footprint to left or right depending on step count
    //						switch (this.lastStep)
    //						{
    //						case 0:
    //							pos.translate(new Vector3(Math.sin(Math.toRadians(-this.rotationYaw + 90)) * 0.25, 0,
    // Math.cos(Math.toRadians(-this.rotationYaw + 90)) * 0.25));
    //							break;
    //						case 1:
    //							pos.translate(new Vector3(Math.sin(Math.toRadians(-this.rotationYaw - 90)) * 0.25, 0,
    // Math.cos(Math.toRadians(-this.rotationYaw - 90)) * 0.25));
    //							break;
    //						}
    //
    //						ClientProxyCore.footprintRenderer.addFootprint(pos, this.rotationYaw);
    //
    //						// Increment and cap step counter at 1
    //						this.lastStep++;
    //						this.lastStep %= 2;
    //						this.distanceSinceLastStep = 0;
    //					}
    //					else
    //					{
    //						double motionSqrd = (this.motionX * this.motionX + this.motionZ * this.motionZ);
    //
    //						// Even when the player is still, motion isn't exactly zero
    //						if (motionSqrd > 0.001)
    //						{
    //							this.distanceSinceLastStep += motionSqrd;
    //						}
    //					}
    //				}
    //			}
    //		}

    if (!this.onGround && this.lastOnGround) {
      this.touchedGround = true;
    }

    if (this.getParachute()) {
      this.fallDistance = 0.0F;
    }

    PlayerGearData gearData = null;

    for (PlayerGearData gearData2 : ClientProxyCore.playerItemData) {
      if (gearData2
          .getPlayer()
          .getGameProfile()
          .getName()
          .equals(this.getGameProfile().getName())) {
        gearData = gearData2;
        break;
      }
    }

    this.usingParachute = false;

    if (gearData != null) {
      this.usingParachute = gearData.getParachute() != null;
    }

    if (this.getParachute() && this.onGround) {
      this.setParachute(false);
      FMLClientHandler.instance().getClient().gameSettings.thirdPersonView =
          this.getThirdPersonView();
    }

    if (!this.lastUsingParachute && this.usingParachute) {
      FMLClientHandler.instance()
          .getClient()
          .getSoundHandler()
          .playSound(
              new PositionedSoundRecord(
                  new ResourceLocation(GalacticraftCore.ASSET_PREFIX + "player.parachute"),
                  (float) this.posX,
                  (float) this.posY,
                  (float) this.posZ,
                  0.95F + this.rand.nextFloat() * 0.1F,
                  1.0F));
    }

    this.lastUsingParachute = this.usingParachute;
    this.lastOnGround = this.onGround;
  }