Exemplo n.º 1
0
  private void updateFeet(EntityPlayerSP player, double motionX, double motionZ) {
    GCPlayerStatsClient stats = GCPlayerStatsClient.get(player);
    double motionSqrd = motionX * motionX + motionZ * motionZ;

    // If the player is on the moon, not airbourne and not riding anything
    if (motionSqrd > 0.001
        && player.worldObj != null
        && player.worldObj.provider instanceof WorldProviderMoon
        && player.ridingEntity == null
        && !player.capabilities.isFlying) {
      int iPosX = (int) Math.floor(player.posX);
      int iPosY = (int) Math.floor(player.posY - 1);
      int iPosZ = (int) Math.floor(player.posZ);
      BlockPos pos1 = new BlockPos(iPosX, iPosY, iPosZ);
      IBlockState state = player.worldObj.getBlockState(pos1);

      // If the block below is the moon block
      if (state.getBlock() == GCBlocks.blockMoon) {
        // And is the correct metadata (moon turf)
        if (state.getBlock().getMetaFromState(state) == 5) {
          // If it has been long enough since the last step
          if (stats.distanceSinceLastStep > 0.35) {
            Vector3 pos = new Vector3(player);
            // Set the footprint position to the block below and add random number to stop
            // z-fighting
            pos.y = MathHelper.floor_double(player.posY) + player.getRNG().nextFloat() / 100.0F;

            // Adjust footprint to left or right depending on step count
            switch (stats.lastStep) {
              case 0:
                pos.translate(
                    new Vector3(
                        Math.sin(Math.toRadians(-player.rotationYaw + 90)) * 0.25,
                        0,
                        Math.cos(Math.toRadians(-player.rotationYaw + 90)) * 0.25));
                break;
              case 1:
                pos.translate(
                    new Vector3(
                        Math.sin(Math.toRadians(-player.rotationYaw - 90)) * 0.25,
                        0,
                        Math.cos(Math.toRadians(-player.rotationYaw - 90)) * 0.25));
                break;
            }

            pos =
                WorldUtil.getFootprintPosition(
                    player.worldObj, player.rotationYaw - 180, pos, new BlockVec3(player));

            long chunkKey = ChunkCoordIntPair.chunkXZ2Int(pos.intX() >> 4, pos.intZ() >> 4);
            ClientProxyCore.footprintRenderer.addFootprint(
                chunkKey,
                player.worldObj.provider.getDimensionId(),
                pos,
                player.rotationYaw,
                player.getName());

            // Increment and cap step counter at 1
            stats.lastStep++;
            stats.lastStep %= 2;
            stats.distanceSinceLastStep = 0;
          } else {
            stats.distanceSinceLastStep += motionSqrd;
          }
        }
      }
    }
  }